Model Railroad System
2.2.1
|
Low-level Raildriver I/O functions. More...
#include <RaildriverIO.h>
Public Types | |
enum | Eventmask_bits { NONE_M = 0, REVERSER_M = 1 << 0, THROTTLE_M = 1 << 1, AUTOBRAKE_M = 1 << 2, INDEPENDBRK_M = 1 << 3, BAILOFF_M = 1 << 4, WIPER_M = 1 << 5, HEADLIGHT_M = 1 << 6, DIGITAL1_M = 1 << 7, DIGITAL2_M = 1 << 8, DIGITAL3_M = 1 << 9, DIGITAL4_M = 1 << 10, DIGITAL5_M = 1 << 11, DIGITAL6_M = 1 << 12 } |
Event Masks. More... | |
enum | Eventcodes { NONE = 0, REVERSER, THROTTLE, AUTOBRAKE, INDEPENDBRK, BAILOFF, WIPER, HEADLIGHT, DIGITAL1, DIGITAL2, DIGITAL3, DIGITAL4, DIGITAL5, DIGITAL6 } |
Event Codes. More... | |
Public Member Functions | |
RaildriverIO (const char *path, char **outmessage=NULL) | |
Constructor. More... | |
~RaildriverIO () | |
Destructor. More... | |
void | SetLEDS (const char *ledstring, char **outmessage=NULL) |
Set the Speedometer LEDs. More... | |
void | SpeakerOn (char **outmessage=NULL) |
Turn the speaker on. More... | |
void | SpeakerOff (char **outmessage=NULL) |
Turn the speaker off. More... | |
unsigned char | GetReverser () const |
Get Reverser value (0-255). More... | |
unsigned char | GetThrottle () const |
Get Throttle value (0-255). More... | |
unsigned char | GetAutoBrake () const |
Get Auto Brake value (0-255). More... | |
unsigned char | GetIndependBrake () const |
Get Indepenent Brake value (0-255). More... | |
unsigned char | GetBailOff () const |
Get Bail Off value (0-255). More... | |
unsigned char | GetHeadlight () const |
Get Headlight value (0-255). More... | |
unsigned char | GetWiper () const |
Get Wiper value (0-255). More... | |
bool | GetBlueButton1 () const |
Get Blue Button 1. More... | |
bool | GetBlueButton2 () const |
Get Blue Button 2. More... | |
bool | GetBlueButton3 () const |
Get Blue Button 3. More... | |
bool | GetBlueButton4 () const |
Get Blue Button 4. More... | |
bool | GetBlueButton5 () const |
Get Blue Button 5. More... | |
bool | GetBlueButton6 () const |
Get Blue Button 6. More... | |
bool | GetBlueButton7 () const |
Get Blue Button 7. More... | |
bool | GetBlueButton8 () const |
Get Blue Button 8. More... | |
bool | GetBlueButton9 () const |
Get Blue Button 9. More... | |
bool | GetBlueButton10 () const |
Get Blue Button 10. More... | |
bool | GetBlueButton11 () const |
Get Blue Button 11. More... | |
bool | GetBlueButton12 () const |
Get Blue Button 12. More... | |
bool | GetBlueButton13 () const |
Get Blue Button 13. More... | |
bool | GetBlueButton14 () const |
Get Blue Button 14. More... | |
bool | GetBlueButton15 () const |
Get Blue Button 15. More... | |
bool | GetBlueButton16 () const |
Get Blue Button 16. More... | |
bool | GetBlueButton17 () const |
Get Blue Button 17. More... | |
bool | GetBlueButton18 () const |
Get Blue Button 18. More... | |
bool | GetBlueButton19 () const |
Get Blue Button 19. More... | |
bool | GetBlueButton20 () const |
Get Blue Button 20. More... | |
bool | GetBlueButton21 () const |
Get Blue Button 21. More... | |
bool | GetBlueButton22 () const |
Get Blue Button 22. More... | |
bool | GetBlueButton23 () const |
Get Blue Button 23. More... | |
bool | GetBlueButton24 () const |
Get Blue Button 24. More... | |
bool | GetBlueButton25 () const |
Get Blue Button 25. More... | |
bool | GetBlueButton26 () const |
Get Blue Button 26. More... | |
bool | GetBlueButton27 () const |
Get Blue Button 27. More... | |
bool | GetBlueButton28 () const |
Get Blue Button 28. More... | |
bool | GetZoomUp () const |
Get Zoom Up. More... | |
bool | GetZoopDown () const |
Get Zoom Down. More... | |
bool | GetPanUp () const |
Get Pan Up. More... | |
bool | GetPanRight () const |
Get Pan Right. More... | |
bool | GetPanDown () const |
Get Pan Down. More... | |
bool | GetPanLeft () const |
Get Pan Left. More... | |
bool | GetRangeUp () const |
Get Range Up. More... | |
bool | GetRangeDown () const |
Get Range Down. More... | |
bool | GetEBrakeUp () const |
Get Emergency Brake Up. More... | |
bool | GetEBrakeDown () const |
Get Emergency Brake Down. More... | |
bool | GetAlert () const |
Get Alert. More... | |
bool | GetSand () const |
Get Sand. More... | |
bool | GetPantograph () const |
Get Pantograph. More... | |
bool | GetBell () const |
Get Bell. More... | |
bool | GetWhistleUp () const |
Get Whistle Up. More... | |
bool | GetWhistleDown () const |
Get Whistle Down. More... | |
unsigned char | GetProductCodeId () const |
Get Product Code Id. More... | |
bool | ReadInputs (Eventmask_bits &mask, int &status) |
Poll the interface. More... | |
Private Member Functions | |
RaildriverIO () | |
Default constructor. More... | |
Private Attributes | |
hid_device * | rdriverdev |
Rail Driver Device. More... | |
union { | |
unsigned char ReportBuffer [14] | |
Event Buffer. More... | |
struct bytes { | |
unsigned char Reverser | |
Reverser lever, 0-255. More... | |
unsigned char Throttle | |
Throttle / Dynamic Brake lever, 0-255. More... | |
unsigned char AutoBrake | |
Automatic Brake lever, 0-255. More... | |
unsigned char IndependBrake | |
Independent Brake lever, 0-255. More... | |
unsigned char BailOff | |
Bail Off (Independent Brake lever), 0-255. More... | |
unsigned char Wiper | |
Wiper switch, 0-255. More... | |
unsigned char Headlight | |
Headlight switch, 0-255. More... | |
unsigned char Digital1 | |
Blue Buttons 1-8. More... | |
unsigned char Digital2 | |
Blue Buttons 9-16. More... | |
unsigned char Digital3 | |
Blue Buttons 17-24. More... | |
unsigned char Digital4 | |
Blue Buttons 25-28, Zoom, Pan Buttons. More... | |
unsigned char Digital5 | |
Pan, Cab buttons. More... | |
unsigned char Digital6 | |
Cab Buttons, Whistle Switch. More... | |
unsigned char ProductCodeId | |
Product Code Id, usually 210. More... | |
} theBytes | |
} | RDInput |
Event data. More... | |
Static Private Attributes | |
static const unsigned short int | PIEngineering |
Rail Driver vendor code. More... | |
static const unsigned short int | RailDriverModernDesktop |
Rail Driver product code. More... | |
static const int | LEDCommand |
LED Command code. More... | |
static const int | SpeakerCommand |
Speaker command code. More... | |
Low-level Raildriver I/O functions.
This class implements the low-level Raildriver I/O functions and provides access to the two endpoints, one input (controls, switches, and buttons) and one output (LED display and speaker switch).
The Raildriver ``game'' console contains a collection of levers, buttons, and switches that simulate a locomotive control stand. There is a reverser lever, a throttle, two brake levers, switches for the lights and wipers, and buttons, switches, and levers for things like the bell, alerter, whistle (or horn), sand, pantograph, and other functions, plus a collection of general purpose buttons that can be programmed to provide any other function. The console also contains a three digit seven-segment display and there is a built in speaker.
Raildriverio 1.0.0
libraildriverio 1.0.0
Event Codes.
These are the event codes for the Rail Driver's report message. There is a code for each of the thirteen bytes in the report buffer.
Event Masks.
These are the mask bits for the Rail Driver's report message. Each bit represents one of the thirteen bytes in the report buffer.
RaildriverIO::RaildriverIO | ( | const char * | path, |
char ** | outmessage = NULL |
||
) |
Constructor.
The argument is the bus number and device number that identifies the specific device. Finds and opens the device and initializes various data objects, generally preparing for I/O to the connnected rail driver console.
path | The path name or the empty string or NULL. |
outmessage | Receives error messages. |
RaildriverIO::~RaildriverIO | ( | ) |
Destructor.
Closes the device and free up system resources.
|
inlineprivate |
Default constructor.
This constructor is never called. It is made private to force a compiler error if an attempt is made to use it.
References PIEngineering.
|
inline |
Get Alert.
References RDInput.
|
inline |
Get Auto Brake value (0-255).
References RDInput.
|
inline |
Get Bail Off value (0-255).
References RDInput.
|
inline |
Get Bell.
References RDInput.
|
inline |
Get Blue Button 1.
References RDInput.
|
inline |
Get Blue Button 10.
References RDInput.
|
inline |
Get Blue Button 11.
References RDInput.
|
inline |
Get Blue Button 12.
References RDInput.
|
inline |
Get Blue Button 13.
References RDInput.
|
inline |
Get Blue Button 14.
References RDInput.
|
inline |
Get Blue Button 15.
References RDInput.
|
inline |
Get Blue Button 16.
References RDInput.
|
inline |
Get Blue Button 17.
References RDInput.
|
inline |
Get Blue Button 18.
References RDInput.
|
inline |
Get Blue Button 19.
References RDInput.
|
inline |
Get Blue Button 2.
References RDInput.
|
inline |
Get Blue Button 20.
References RDInput.
|
inline |
Get Blue Button 21.
References RDInput.
|
inline |
Get Blue Button 22.
References RDInput.
|
inline |
Get Blue Button 23.
References RDInput.
|
inline |
Get Blue Button 24.
References RDInput.
|
inline |
Get Blue Button 25.
References RDInput.
|
inline |
Get Blue Button 26.
References RDInput.
|
inline |
Get Blue Button 27.
References RDInput.
|
inline |
Get Blue Button 28.
References RDInput.
|
inline |
Get Blue Button 3.
References RDInput.
|
inline |
Get Blue Button 4.
References RDInput.
|
inline |
Get Blue Button 5.
References RDInput.
|
inline |
Get Blue Button 6.
References RDInput.
|
inline |
Get Blue Button 7.
References RDInput.
|
inline |
Get Blue Button 8.
References RDInput.
|
inline |
Get Blue Button 9.
References RDInput.
|
inline |
Get Emergency Brake Down.
References RDInput.
|
inline |
Get Emergency Brake Up.
References RDInput.
|
inline |
Get Headlight value (0-255).
References RDInput.
|
inline |
Get Indepenent Brake value (0-255).
References RDInput.
|
inline |
Get Pan Down.
References RDInput.
|
inline |
Get Pan Left.
References RDInput.
|
inline |
Get Pan Right.
References RDInput.
|
inline |
Get Pantograph.
References RDInput.
|
inline |
Get Pan Up.
References RDInput.
|
inline |
Get Product Code Id.
This is a unsigned char value filled in upon reading the input report buffer from the Raildriver.
References RDInput, and ReadInputs().
|
inline |
Get Range Down.
References RDInput.
|
inline |
Get Range Up.
References RDInput.
|
inline |
Get Reverser value (0-255).
References RDInput.
|
inline |
Get Sand.
References RDInput.
|
inline |
Get Throttle value (0-255).
References RDInput.
|
inline |
Get Whistle Down.
References RDInput.
|
inline |
Get Whistle Up.
References RDInput.
|
inline |
Get Wiper value (0-255).
References RDInput.
|
inline |
Get Zoom Up.
References RDInput.
|
inline |
Get Zoom Down.
References RDInput.
bool RaildriverIO::ReadInputs | ( | Eventmask_bits & | mask, |
int & | status | ||
) |
Poll the interface.
Called in the event loop. Returns true if something has changed, that is if any of the bytes in the freshly read report buffer are different from the stored report buffer.
mask | Mask of changed bits. This parameter is updated to reflect any changed state information. |
status | IO Status of the read. |
Referenced by GetProductCodeId().
void RaildriverIO::SetLEDS | ( | const char * | ledstring, |
char ** | outmessage = NULL |
||
) |
Set the Speedometer LEDs.
Does a bulk write to set the speedometer LEDs on the Raid Driver unit.
void RaildriverIO::SpeakerOff | ( | char ** | outmessage = NULL | ) |
Turn the speaker off.
void RaildriverIO::SpeakerOn | ( | char ** | outmessage = NULL | ) |
Turn the speaker on.
unsigned char RaildriverIO::AutoBrake |
Automatic Brake lever, 0-255.
unsigned char RaildriverIO::BailOff |
Bail Off (Independent Brake lever), 0-255.
unsigned char RaildriverIO::Digital1 |
Blue Buttons 1-8.
This is an 8-bit bit field.
unsigned char RaildriverIO::Digital2 |
Blue Buttons 9-16.
This is an 8-bit bit field.
unsigned char RaildriverIO::Digital3 |
Blue Buttons 17-24.
This is an 8-bit bit field.
unsigned char RaildriverIO::Digital4 |
Blue Buttons 25-28, Zoom, Pan Buttons.
This is an 8-bit bit field.
unsigned char RaildriverIO::Digital5 |
Pan, Cab buttons.
This is an 8-bit bit field.
unsigned char RaildriverIO::Digital6 |
Cab Buttons, Whistle Switch.
This is an 8-bit bit field.
unsigned char RaildriverIO::Headlight |
Headlight switch, 0-255.
unsigned char RaildriverIO::IndependBrake |
Independent Brake lever, 0-255.
|
staticprivate |
LED Command code.
This is the command code used to change the LED display.
|
staticprivate |
Rail Driver vendor code.
This is the vendor code PI Engineering was granted for their USB products.
Referenced by RaildriverIO().
unsigned char RaildriverIO::ProductCodeId |
Product Code Id, usually 210.
|
staticprivate |
Rail Driver product code.
This is the product PI Engineering uses for their Rail Driver consoles.
union { ... } RaildriverIO::RDInput |
Event data.
This is the report buffer used to hold the state of all of the levers, switches, and buttons on the Rail Driver console. It is a union of a fourteen byte buffer and a struct of bytes, one for each lever or switch or bit fields representing single buttons.
Referenced by GetAlert(), GetAutoBrake(), GetBailOff(), GetBell(), GetBlueButton1(), GetBlueButton10(), GetBlueButton11(), GetBlueButton12(), GetBlueButton13(), GetBlueButton14(), GetBlueButton15(), GetBlueButton16(), GetBlueButton17(), GetBlueButton18(), GetBlueButton19(), GetBlueButton2(), GetBlueButton20(), GetBlueButton21(), GetBlueButton22(), GetBlueButton23(), GetBlueButton24(), GetBlueButton25(), GetBlueButton26(), GetBlueButton27(), GetBlueButton28(), GetBlueButton3(), GetBlueButton4(), GetBlueButton5(), GetBlueButton6(), GetBlueButton7(), GetBlueButton8(), GetBlueButton9(), GetEBrakeDown(), GetEBrakeUp(), GetHeadlight(), GetIndependBrake(), GetPanDown(), GetPanLeft(), GetPanRight(), GetPantograph(), GetPanUp(), GetProductCodeId(), GetRangeDown(), GetRangeUp(), GetReverser(), GetSand(), GetThrottle(), GetWhistleDown(), GetWhistleUp(), GetWiper(), GetZoomUp(), and GetZoopDown().
|
private |
Rail Driver Device.
This is the HID device structure for the device.
unsigned char RaildriverIO::ReportBuffer[14] |
Event Buffer.
This is the I/O buffer used to hold the information about the state of the Rail Driver console.
unsigned char RaildriverIO::Reverser |
Reverser lever, 0-255.
|
staticprivate |
Speaker command code.
This is the command code used to toggle the speaker state.
struct { ... } ::bytes RaildriverIO::theBytes |
unsigned char RaildriverIO::Throttle |
Throttle / Dynamic Brake lever, 0-255.
unsigned char RaildriverIO::Wiper |
Wiper switch, 0-255.