Model Railroad System
2.2.1
|
#include <sr4.h>
Classes | |
union | status1_union |
Status byte 1 union type (Outputs) More... | |
union | status2_union |
Status byte 2 union type (Input sense) More... | |
union | status3_union |
Status byte 3 union type (Input Control Status) More... | |
Public Member Functions | |
~SR4 () | |
ErrorCode | BlinkRelays (bool Q1, bool Q2, bool Q3, bool Q4, uint8_t speed) |
Blink relay contacts. More... | |
ErrorCode | RelaysOff (bool Q1, bool Q2, bool Q3, bool Q4) |
Set output relay contacts off. More... | |
ErrorCode | RelaysOn (bool Q1, bool Q2, bool Q3, bool Q4) |
Set output relay contacts on. More... | |
ErrorCode | PulseRelays (bool Q1, bool Q2, bool Q3, bool Q4, uint8_t duration) |
Pulse output relay contacts. More... | |
ErrorCode | OutputRelayInputControl (bool I1, bool I2, bool I3, bool I4) |
Enable/Disable descrete input lines from affecting outputs. More... | |
bool | Sense_1_Latch () const |
Sense 1, return true if input line 1 was activated since last get status. More... | |
bool | Sense_2_Latch () const |
Sense 2, return true if input line 2 was activated since last get status. More... | |
bool | Sense_3_Latch () const |
Sense 3, return true if input line 3 was activated since last get status. More... | |
bool | Sense_4_Latch () const |
Sense 4, return true if input line 4 was activated since last get status. More... | |
bool | Q1_State () const |
Q1 state, return true if Q1 is closed. More... | |
bool | Q2_State () const |
Q2 state, return true if Q2 is closed. More... | |
bool | Q3_State () const |
Q3 state, return true if Q3 is closed. More... | |
bool | Q4_State () const |
Q4 state, return true if Q4 is closed. More... | |
bool | Input_1_Enabled () const |
Input 1 enabled? Return true if I1 can affect outputs. More... | |
bool | Input_2_Enabled () const |
Input 2 enabled? Return true if I2 can affect outputs. More... | |
bool | Input_3_Enabled () const |
Input 3 enabled? Return true if I3 can affect outputs. More... | |
bool | Input_4_Enabled () const |
Input 4 enabled? Return true if I4 can affect outputs. More... | |
bool | Sense_1_Live () const |
Sense 1, return true if input line 1 is now activated. More... | |
bool | Sense_2_Live () const |
Sense 2, return true if input line 2 is now activated. More... | |
bool | Sense_3_Live () const |
Sense 3, return true if input line 3 is now activated. More... | |
bool | Sense_4_Live () const |
Sense 4, return true if input line 4 is now activated. More... | |
![]() | |
~Azatrax () | |
Base destructor. More... | |
ErrorCode | RestoreLEDFunction () const |
Restore LED function. More... | |
ErrorCode | Identify_1 () const |
Identify 1. More... | |
ErrorCode | GetStateData () |
Get State Data. More... | |
uint8_t | PacketCount () const |
Packet count. More... | |
const char * | SerialNumber () const |
Serial Number. More... | |
const char * | MyProduct () const |
My product name. More... | |
unsigned short int | MyProductId () const |
My product code. More... | |
Private Member Functions | |
SR4 (const char *serialnumber, char **outmessage=NULL) | |
Base constructor. More... | |
Friends | |
class | Azatrax |
Additional Inherited Members | |
![]() | |
enum | commands { cmd_SetChan1 =0x31, cmd_SetChan2 =0x32, cmd_ClearExternallyChanged =0x34, cmd_DisableExternal =0x37, cmd_EnableExternal =0x38, cmd_Q1posQ2neg =0x39, cmd_Q1negQ2pos =0x3A, cmd_Q1Q2open =0x3F, cmd_Q3posQ4neg =0x49, cmd_Q3negQ4pos =0x4A, cmd_Q3Q4open =0x4F, cmd_RestoreLEDFunction =0x50, cmd_Identify_1 =0x51, cmd_Identify_2 =0x52, cmd_Identify_1_2 =0x53, cmd_ResetStopwatch =0x54, cmd_GetStateData =0x57, cmd_OutputRelayBlink =0x61, cmd_OutputRelayOff =0x67, cmd_OutputRelayOn =0x6B, cmd_OutputRelayPulse =0x6D, cmd_OutputRelayInputControl =0x6E } |
Command codes. More... | |
enum | DeviceConnectionList { _InitSize = 10, _GrowSize = 10 } |
Device connection list constants. More... | |
enum | { idAzatraxVendor = 0x265F, idMRDProduct = 0xfcb2, idSL2Product = 0xfca1, idSR4Product = 0xfca2 } |
Azatrax vendor and product codes. More... | |
![]() | |
static int | NumberOfOpenDevices () |
Open device count. More... | |
static char ** | AllConnectedDevices () |
List serial numbers of all connected devices. More... | |
static Azatrax * | OpenDevice (const char *serialnumber, unsigned short int idProduct=0, char **outmessage=NULL) |
Open an Azatrax device by serial number. More... | |
static unsigned short int | ProductIdCode (const char *productName) |
Product id code. More... | |
![]() | |
Azatrax (const char *serialnumber, unsigned short int idProduct, char **outmessage=NULL) | |
Base constructor. More... | |
ErrorCode | sendByte (uint8_t commandByte) const |
Send a command byte. More... | |
ErrorCode | send2Bytes (uint8_t commandByte, uint8_t byte2) const |
Send a command byte with 1 data byte. More... | |
ErrorCode | send3Bytes (uint8_t commandByte, uint8_t byte2, uint8_t byte3) const |
Send a command bytewith 2 data bytes. More... | |
![]() | |
static bool | IsThisTheAzatraxWeAreLookingFor (libusb_device *dev, const char *serialnumber, unsigned short int idProduct) |
Is this the device we want? More... | |
static unsigned short int | GetProductId (libusb_device *dev, const char *serialnumber, unsigned short int idProductMatch=0) |
Return the matching product id for this device and serial number. More... | |
![]() | |
struct libusb_device_handle * | handle |
USB Device Handle. More... | |
char | mySerialNumber [10] |
Serial number buffer. More... | |
unsigned short int | myProductId |
Product id. More... | |
struct azatrax::Azatrax::StateDataPacket | stateDataPacket |
![]() | |
static int | deviceOpenCount |
Device open count. More... | |
SR4 I/O Class.
SR4 interface class.
This class implements the interface logic for a SR4-U device.
The constructor opens a connection to a SR4-U device, given its serial number. Each SR4-U device has a unique, factory defined serial number, which is printed on a sticker attached to the module. This serial number is much like the MAC address of an Ethernet interface. The destructor closes the connection to the device and frees any resources allocated.
The class provides methods to send commands to the device, read back its state and interrogate the state read back. This way each class instance encapsulates each device instance.
|
inlineprivate |
Base constructor.
serialnumber | The serial number of the device to open. |
outmessage | To hold an error message, if any. |
|
inline |
|
inline |
Blink relay contacts.
Sets output relay contacts to blinking state.
Q1 | Blink relay Q1. |
Q2 | Blink relay Q2. |
Q3 | Blink relay Q3. |
Q4 | Blink relay Q4. |
speed | Blink speed: 0 is 4hz, 1 is 2hz, 2 is 1hz, and 3 is .5hz. |
References azatrax::Azatrax::cmd_OutputRelayBlink, and azatrax::Azatrax::send3Bytes().
|
inline |
Input 1 enabled? Return true if I1 can affect outputs.
References azatrax::SR4::status3_union::input_1_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SR4::status3_union::theBits, and azatrax::SR4::status3_union::theByte.
|
inline |
Input 2 enabled? Return true if I2 can affect outputs.
References azatrax::SR4::status3_union::input_2_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SR4::status3_union::theBits, and azatrax::SR4::status3_union::theByte.
|
inline |
Input 3 enabled? Return true if I3 can affect outputs.
References azatrax::SR4::status3_union::input_3_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SR4::status3_union::theBits, and azatrax::SR4::status3_union::theByte.
|
inline |
Input 4 enabled? Return true if I4 can affect outputs.
References azatrax::SR4::status3_union::input_4_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SR4::status3_union::theBits, and azatrax::SR4::status3_union::theByte.
|
inline |
Enable/Disable descrete input lines from affecting outputs.
When enabled, I1 & I2 affect Q1 & Q2 (switch 1), I3 & I4 affect Q3 & Q4 (switch 2).
I1 | Enable/Disable I1. |
I2 | Enable/Disable I2. |
I3 | Enable/Disable I3. |
I4 | Enable/Disable I4. |
References azatrax::Azatrax::cmd_OutputRelayInputControl, and azatrax::Azatrax::send2Bytes().
|
inline |
Pulse output relay contacts.
Q1 | Pulse Q1. |
Q2 | Pulse Q2. |
Q3 | Pulse Q3. |
Q4 | Pulse Q4. |
duration | Pulse duration in 0.5 second units. |
References azatrax::Azatrax::cmd_OutputRelayPulse, and azatrax::Azatrax::send3Bytes().
|
inline |
Q1 state, return true if Q1 is closed.
References azatrax::SR4::status1_union::Q1_state, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SR4::status1_union::theBits, and azatrax::SR4::status1_union::theByte.
|
inline |
Q2 state, return true if Q2 is closed.
References azatrax::SR4::status1_union::Q2_state, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SR4::status1_union::theBits, and azatrax::SR4::status1_union::theByte.
|
inline |
Q3 state, return true if Q3 is closed.
References azatrax::SR4::status1_union::Q3_state, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SR4::status1_union::theBits, and azatrax::SR4::status1_union::theByte.
|
inline |
Q4 state, return true if Q4 is closed.
References azatrax::SR4::status1_union::Q4_state, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SR4::status1_union::theBits, and azatrax::SR4::status1_union::theByte.
|
inline |
Set output relay contacts off.
Q1 | Turn off Q1. |
Q2 | Turn off Q2. |
Q3 | Turn off Q3. |
Q4 | Turn off Q4. |
References azatrax::Azatrax::cmd_OutputRelayOff, and azatrax::Azatrax::send2Bytes().
|
inline |
Set output relay contacts on.
Q1 | Turn on Q1. |
Q2 | Turn on Q2. |
Q3 | Turn on Q3. |
Q4 | Turn on Q4. |
References azatrax::Azatrax::cmd_OutputRelayOn, and azatrax::Azatrax::send2Bytes().
|
inline |
Sense 1, return true if input line 1 was activated since last get status.
References azatrax::SR4::status2_union::sense_1, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
inline |
Sense 1, return true if input line 1 is now activated.
References azatrax::SR4::status2_union::sense_1, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status4, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
inline |
Sense 2, return true if input line 2 was activated since last get status.
References azatrax::SR4::status2_union::sense_2, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
inline |
Sense 2, return true if input line 2 is now activated.
References azatrax::SR4::status2_union::sense_2, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status4, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
inline |
Sense 3, return true if input line 3 was activated since last get status.
References azatrax::SR4::status2_union::sense_3, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
inline |
Sense 3, return true if input line 3 is now activated.
References azatrax::SR4::status2_union::sense_3, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status4, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
inline |
Sense 4, return true if input line 4 was activated since last get status.
References azatrax::SR4::status2_union::sense_4, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
inline |
Sense 4, return true if input line 4 is now activated.
References azatrax::SR4::status2_union::sense_4, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status4, azatrax::SR4::status2_union::theBits, and azatrax::SR4::status2_union::theByte.
|
friend |