Model Railroad System 2.2.2
|
#include <sl2.h>
Classes | |
union | status1_union |
Status byte 1 union type (Output states) More... | |
union | status2_union |
Status byte 2 union type (Input sense) More... | |
union | status3_union |
Status byte 3 union type (Input control state) More... | |
Public Member Functions | |
~SL2 () | |
ErrorCode | SetQ1posQ2neg () const |
Sets output terminal Q1 to positive, Q2 to negative. More... | |
ErrorCode | SetQ1negQ2pos () const |
Sets output terminal Q1 to negative, Q2 to positive. More... | |
ErrorCode | SetQ1Q2open () const |
Outputs Q1 & Q2 both set to open circuit (disconnects switch machine #1) More... | |
ErrorCode | SetQ3posQ4neg () const |
Sets output terminal Q3 to positive, Q4 to negative. More... | |
ErrorCode | SetQ3negQ4pos () const |
Sets output terminal Q3 to negative, Q4 to positive. More... | |
ErrorCode | SetQ3Q4open () const |
Outputs Q3 & Q4 both set to open circuit (disconnects switch machine #2) More... | |
ErrorCode | OutputRelayInputControl (bool I1, bool I2, bool I3, bool I4) |
Enable/Disable descrete input lines from affecting outputs. More... | |
bool | Sense_1 () const |
Sense 1, return true if input line 1 was activated since last get status. More... | |
bool | Sense_2 () const |
Sense 2, return true if input line 2 was activated since last get status. More... | |
bool | Sense_3 () const |
Sense 3, return true if input line 3 was activated since last get status. More... | |
bool | Sense_4 () const |
Sense 4, return true if input line 4 was activated since last get status. More... | |
bool | Motor_1_Direction () const |
Motor 1 direction, return true if Q1 is positive. More... | |
bool | Motor_1_State () const |
Motor 1 state, return true if Q1 and Q2 are on. More... | |
bool | Motor_2_Direction () const |
Motor 2 direction, return true if Q3 is positive. More... | |
bool | Motor_2_State () const |
Motor 2 state, return true if Q3 and Q4 are on. 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... | |
![]() | |
~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 | |
SL2 (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... | |
SL2 I/O Class.
SL2 interface class.
This class implements the interface logic for a SL2-U device.
The constructor opens a connection to a SL2-U device, given its serial number. Each SL2-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 |
Input 1 enabled? Return true if I1 can affect outputs.
References azatrax::SL2::status3_union::input_1_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SL2::status3_union::theBits, and azatrax::SL2::status3_union::theByte.
|
inline |
Input 2 enabled? Return true if I2 can affect outputs.
References azatrax::SL2::status3_union::input_2_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SL2::status3_union::theBits, and azatrax::SL2::status3_union::theByte.
|
inline |
Input 3 enabled? Return true if I3 can affect outputs.
References azatrax::SL2::status3_union::input_3_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SL2::status3_union::theBits, and azatrax::SL2::status3_union::theByte.
|
inline |
Input 4 enabled? Return true if I4 can affect outputs.
References azatrax::SL2::status3_union::input_4_enabled, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status3, azatrax::SL2::status3_union::theBits, and azatrax::SL2::status3_union::theByte.
|
inline |
Motor 1 direction, return true if Q1 is positive.
References azatrax::SL2::status1_union::motor_1_direction, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SL2::status1_union::theBits, and azatrax::SL2::status1_union::theByte.
|
inline |
Motor 1 state, return true if Q1 and Q2 are on.
References azatrax::SL2::status1_union::motor_1_state, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SL2::status1_union::theBits, and azatrax::SL2::status1_union::theByte.
|
inline |
Motor 2 direction, return true if Q3 is positive.
References azatrax::SL2::status1_union::motor_2_direction, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SL2::status1_union::theBits, and azatrax::SL2::status1_union::theByte.
|
inline |
Motor 2 state, return true if Q3 and Q4 are on.
References azatrax::SL2::status1_union::motor_2_state, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status1, azatrax::SL2::status1_union::theBits, and azatrax::SL2::status1_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 |
Sense 1, return true if input line 1 was activated since last get status.
References azatrax::SL2::status2_union::sense_1, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SL2::status2_union::theBits, and azatrax::SL2::status2_union::theByte.
|
inline |
Sense 2, return true if input line 2 was activated since last get status.
References azatrax::SL2::status2_union::sense_2, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SL2::status2_union::theBits, and azatrax::SL2::status2_union::theByte.
|
inline |
Sense 3, return true if input line 3 was activated since last get status.
References azatrax::SL2::status2_union::sense_3, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SL2::status2_union::theBits, and azatrax::SL2::status2_union::theByte.
|
inline |
Sense 4, return true if input line 4 was activated since last get status.
References azatrax::SL2::status2_union::sense_4, azatrax::Azatrax::stateDataPacket, azatrax::Azatrax::StateDataPacket::status2, azatrax::SL2::status2_union::theBits, and azatrax::SL2::status2_union::theByte.
|
inline |
Sets output terminal Q1 to negative, Q2 to positive.
References azatrax::Azatrax::cmd_Q1negQ2pos, and azatrax::Azatrax::sendByte().
|
inline |
Sets output terminal Q1 to positive, Q2 to negative.
References azatrax::Azatrax::cmd_Q1posQ2neg, and azatrax::Azatrax::sendByte().
|
inline |
Outputs Q1 & Q2 both set to open circuit (disconnects switch machine #1)
References azatrax::Azatrax::cmd_Q1Q2open, and azatrax::Azatrax::sendByte().
|
inline |
Sets output terminal Q3 to negative, Q4 to positive.
References azatrax::Azatrax::cmd_Q3negQ4pos, and azatrax::Azatrax::sendByte().
|
inline |
Sets output terminal Q3 to positive, Q4 to negative.
References azatrax::Azatrax::cmd_Q3posQ4neg, and azatrax::Azatrax::sendByte().
|
inline |
Outputs Q3 & Q4 both set to open circuit (disconnects switch machine #2)
References azatrax::Azatrax::cmd_Q3Q4open, and azatrax::Azatrax::sendByte().
|
friend |