Model Railroad System  2.2.1
Classes | Public Member Functions | Private Member Functions | Friends | List of all members
azatrax::SL2 Class Reference

SL2 I/O Class. More...

#include <sl2.h>

Inheritance diagram for azatrax::SL2:
azatrax::Azatrax

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...
 
- Public Member Functions inherited from azatrax::Azatrax
 ~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

- Public Types inherited from azatrax::Azatrax
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 Public Member Functions inherited from azatrax::Azatrax
static int NumberOfOpenDevices ()
 Open device count. More...
 
static char ** AllConnectedDevices ()
 List serial numbers of all connected devices. More...
 
static AzatraxOpenDevice (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...
 
- Protected Member Functions inherited from azatrax::Azatrax
 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 Protected Member Functions inherited from azatrax::Azatrax
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...
 
- Protected Attributes inherited from azatrax::Azatrax
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 Protected Attributes inherited from azatrax::Azatrax
static int deviceOpenCount
 Device open count. More...
 

Detailed Description

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.

Author
Robert Heller <heller@deepsoft.com>

Constructor & Destructor Documentation

◆ SL2()

azatrax::SL2::SL2 ( const char *  serialnumber,
char **  outmessage = NULL 
)
inlineprivate

Base constructor.

Parameters
serialnumberThe serial number of the device to open.
outmessageTo hold an error message, if any.

◆ ~SL2()

azatrax::SL2::~SL2 ( )
inline

Member Function Documentation

◆ Input_1_Enabled()

bool azatrax::SL2::Input_1_Enabled ( ) const
inline

◆ Input_2_Enabled()

bool azatrax::SL2::Input_2_Enabled ( ) const
inline

◆ Input_3_Enabled()

bool azatrax::SL2::Input_3_Enabled ( ) const
inline

◆ Input_4_Enabled()

bool azatrax::SL2::Input_4_Enabled ( ) const
inline

◆ Motor_1_Direction()

bool azatrax::SL2::Motor_1_Direction ( ) const
inline

◆ Motor_1_State()

bool azatrax::SL2::Motor_1_State ( ) const
inline

◆ Motor_2_Direction()

bool azatrax::SL2::Motor_2_Direction ( ) const
inline

◆ Motor_2_State()

bool azatrax::SL2::Motor_2_State ( ) const
inline

◆ OutputRelayInputControl()

ErrorCode azatrax::SL2::OutputRelayInputControl ( bool  I1,
bool  I2,
bool  I3,
bool  I4 
)
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).

Parameters
I1Enable/Disable I1.
I2Enable/Disable I2.
I3Enable/Disable I3.
I4Enable/Disable I4.

References azatrax::Azatrax::cmd_OutputRelayInputControl, and azatrax::Azatrax::send2Bytes().

◆ Sense_1()

bool azatrax::SL2::Sense_1 ( ) const
inline

◆ Sense_2()

bool azatrax::SL2::Sense_2 ( ) const
inline

◆ Sense_3()

bool azatrax::SL2::Sense_3 ( ) const
inline

◆ Sense_4()

bool azatrax::SL2::Sense_4 ( ) const
inline

◆ SetQ1negQ2pos()

ErrorCode azatrax::SL2::SetQ1negQ2pos ( ) const
inline

Sets output terminal Q1 to negative, Q2 to positive.

References azatrax::Azatrax::cmd_Q1negQ2pos, and azatrax::Azatrax::sendByte().

◆ SetQ1posQ2neg()

ErrorCode azatrax::SL2::SetQ1posQ2neg ( ) const
inline

Sets output terminal Q1 to positive, Q2 to negative.

References azatrax::Azatrax::cmd_Q1posQ2neg, and azatrax::Azatrax::sendByte().

◆ SetQ1Q2open()

ErrorCode azatrax::SL2::SetQ1Q2open ( ) const
inline

Outputs Q1 & Q2 both set to open circuit (disconnects switch machine #1)

References azatrax::Azatrax::cmd_Q1Q2open, and azatrax::Azatrax::sendByte().

◆ SetQ3negQ4pos()

ErrorCode azatrax::SL2::SetQ3negQ4pos ( ) const
inline

Sets output terminal Q3 to negative, Q4 to positive.

References azatrax::Azatrax::cmd_Q3negQ4pos, and azatrax::Azatrax::sendByte().

◆ SetQ3posQ4neg()

ErrorCode azatrax::SL2::SetQ3posQ4neg ( ) const
inline

Sets output terminal Q3 to positive, Q4 to negative.

References azatrax::Azatrax::cmd_Q3posQ4neg, and azatrax::Azatrax::sendByte().

◆ SetQ3Q4open()

ErrorCode azatrax::SL2::SetQ3Q4open ( ) const
inline

Outputs Q3 & Q4 both set to open circuit (disconnects switch machine #2)

References azatrax::Azatrax::cmd_Q3Q4open, and azatrax::Azatrax::sendByte().

Friends And Related Function Documentation

◆ Azatrax

friend class Azatrax
friend