Model Railroad System  2.2.1
Namespaces | Classes | Typedefs | Functions | Variables
CTIAcela

CTI Acela Serial Port Interface. More...

Namespaces

 ctiacela
 CTI Acela Tcl Serial Port Interface.
 

Classes

class  ctiacela::CTIAcela
 Main CTIAcela interface class. More...
 

Typedefs

typedef int ctiacela::addresstype
 Module address type. More...
 
typedef int ctiacela::ubyte
 Unsigned byte type. More...
 
typedef int ctiacela::speedtype
 Speed type. More...
 
typedef int ctiacela::momtype
 Momentium control type. More...
 
typedef int ctiacela::filterthreshtype
 Filter threshold type. More...
 

Functions

static ctiacela::CTIAcela::validate (object)
 Type validation method. More...
 
 ctiacela::CTIAcela::CTIAcela (name, port,...)
 Constructor: open a connection to the CTI Acela. More...
 
 ctiacela::CTIAcela::~CTIAcela ()
 The destructor restores the serial port's state and closes it. More...
 
 ctiacela::CTIAcela::HaveData ()
 
 ctiacela::CTIAcela::OnlineP ()
 
 ctiacela::CTIAcela::_handleSRQ ()
 Handle a service request. More...
 
static ctiacela::CTIAcela::highbyte (addr)
 Return the high byte of address. More...
 
static ctiacela::CTIAcela::lowbyte (addr)
 Return the low byte of address. More...
 
 ctiacela::CTIAcela::Activate (address)
 Activate a control. More...
 
 ctiacela::CTIAcela::Deactive (address)
 Deactive a control. More...
 
 ctiacela::CTIAcela::PulseOn (address, pulsewidth)
 Pulse On a control. More...
 
 ctiacela::CTIAcela::PulseOff (address, pulsewidth)
 Pulse Off a control. More...
 
 ctiacela::CTIAcela::Blink (address, pulsewidth)
 Blink a control. More...
 
 ctiacela::CTIAcela::ReverseBlink (address, pulsewidth)
 Reverse Blink a control. More...
 
 ctiacela::CTIAcela::Control4 (address, c1, c2, c3, c4)
 Configure 4 controls simultaneously. More...
 
 ctiacela::CTIAcela::Control8 (address, c1, c2, c3, c4, c5, c6, c7, c8)
 Configure 8 controls simultaneously. More...
 
 ctiacela::CTIAcela::Control16 (address, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16)
 Configure 16 controls simultaneously. More...
 
static ctiacela::CTIAcela::pack4 (b1, b2, b3, b4)
 pack 4 bits More...
 
static ctiacela::CTIAcela::pack8 (b1, b2, b3, b4, b5, b6, b7, b8)
 pack 4 bits More...
 
 ctiacela::CTIAcela::Throttle (address, speed, momentum, brake, direction, idle)
 Throttle command. More...
 
 ctiacela::CTIAcela::EmergencyStop ()
 Emergency Stop. More...
 
 ctiacela::CTIAcela::Signal2 (address, lamp1, lamp2, yellow="off")
 Control 2-lamp signals. More...
 
 ctiacela::CTIAcela::Signal3 (address, lamp1, lamp2, lamp3)
 Control 3-lamp signals. More...
 
 ctiacela::CTIAcela::Signal4 (address, lamp1, lamp2, lamp3, lamp4)
 Control 4-lamp signals. More...
 
 ctiacela::CTIAcela::SignalSettings (blinkrate, yellowhue)
 Set Signal Settings. More...
 
 ctiacela::CTIAcela::SignalBrightness (brightness)
 Set signal brightness. More...
 
 ctiacela::CTIAcela::ConfigureSensor (address, threshold, select, polarity)
 Configure a sensor. More...
 
 ctiacela::CTIAcela::Read (address)
 Read the state of a sensor. More...
 
 ctiacela::CTIAcela::Read4 (address)
 Read the state of four sensors. More...
 
 ctiacela::CTIAcela::Read8 (address)
 Read the state of eight sensors. More...
 
 ctiacela::CTIAcela::Read16 (address)
 Read the state of sixteen sensors. More...
 
 ctiacela::CTIAcela::ReadAll ()
 Read all sensors. More...
 
 ctiacela::CTIAcela::SRQControl (enable="yes")
 Enable or disable SRQ messages. More...
 
 ctiacela::CTIAcela::Query ()
 Query sensor change state. More...
 
 ctiacela::CTIAcela::ResetNetwork ()
 Reset the network. More...
 
 ctiacela::CTIAcela::NetworkOnline ()
 Bring the network online. More...
 
 ctiacela::CTIAcela::NetworkOffline ()
 Bring the network offline. More...
 
 ctiacela::CTIAcela::Poll ()
 Poll the network configuration. More...
 
 ctiacela::CTIAcela::ReadRevision ()
 Read CTI Acela firmware revision. More...
 
 ctiacela::CTIAcela::_transmit (buffer, responsebytes=0)
 Transmit buffer and wait for response. More...
 
 ctiacela::CTIAcela::_readevent ()
 Read event method. More...
 
 ctiacela::CTIAcela::_readbyte (thebytevar)
 Read a single byte from the serial interface. More...
 

Variables

 ctiacela::ctiacela
 
static ctiacela::CTIAcela::Responses
 Responses. More...
 
static ctiacela::CTIAcela::Opcodes
 Opcodes. More...
 
static ctiacela::CTIAcela::LampBits
 Lamp Bits. More...
 
static ctiacela::CTIAcela::FilterSelectBits
 Filter Select Bits. More...
 
static ctiacela::CTIAcela::CTI_DeviceMap
 CTI Module Map. More...
 
 ctiacela::CTIAcela::ttyfd
 Terminal file descriptor. More...
 
 ctiacela::CTIAcela::dataavailable
 Flag set to true (yes) when sensor data is available. More...
 
 ctiacela::CTIAcela::networkonline
 Flag set to false (no) when the network goes offline. More...
 
 ctiacela::CTIAcela::_timeout
 Timeout flag. More...
 
static ctiacela::CTIAcela::maxtries
 Loop control for read attempts. More...
 

Detailed Description

CTI Acela Serial Port Interface.

This is a cross-platform implementation of the host (computer) side of the CTI Acela Serial Port Interface.

Basically, the way this code works is to use a SNIT class (described in the CTIAcela type) to interface to the serial port, which may have one or more CTI modules (Train Brain, Dash-8, Watchman, Signalman, Smart Cab, etc.). A given class instance interfaces to all of the modules attached to a given serial port.

Author
Robert Heller <heller@deepsoft.com>

Typedef Documentation

◆ addresstype

unsigned short int ctiacela::addresstype

Module address type.

An integer in the range from 0 to 65535, inclusive.

◆ filterthreshtype

Filter threshold type.

An integer from 0 to 31, inclusive.

◆ momtype

Momentium control type.

Integer in the range of 0 to 7, inclusive.

◆ speedtype

Speed type.

Integer in the range of 0 to 100, inclusive.

◆ ubyte

unsigned char ctiacela::ubyte

Unsigned byte type.

An integer in the range from 0 to 255, inclusive.

Function Documentation

◆ _handleSRQ()

ctiacela::CTIAcela::_handleSRQ ( )
private

Handle a service request.

◆ _readbyte()

ctiacela::CTIAcela::_readbyte ( thebytevar  )
private

Read a single byte from the serial interface.

Used by methods that read responses.

Parameters
thebytevarA name of a variable to put the byte read. Undefined if there was an error.
Returns
false on error and and true on success.

◆ _readevent()

ctiacela::CTIAcela::_readevent ( )
private

Read event method.

◆ _transmit()

ctiacela::CTIAcela::_transmit ( buffer  ,
responsebytes  = 0 
)
private

Transmit buffer and wait for response.

Parameters
bufferList of bytes to transmit.
responsebytesNumber of expected databytes (not counting the command ack byte) or N for a variable number of result bytes.
Returns
the response, either a single byte or a list of bytes.

◆ Activate()

ctiacela::CTIAcela::Activate ( address  )

Activate a control.

Parameters
addressAddress of the control.

◆ Blink()

ctiacela::CTIAcela::Blink ( address  ,
pulsewidth   
)

Blink a control.

Parameters
addressAddress of the control.
pulsewidthPulsewidth in 10ths of a second

◆ ConfigureSensor()

ctiacela::CTIAcela::ConfigureSensor ( address  ,
threshold  ,
select  ,
polarity   
)

Configure a sensor.

Parameters
addressAddress of the sensor.
thresholdFilter threshold, 0-31.
selectFilter select, one of noise, bounce, gap, pr dirty.
polarityPolarity, one of normal or invert.

◆ Control16()

ctiacela::CTIAcela::Control16 ( address  ,
c1  ,
c2  ,
c3  ,
c4  ,
c5  ,
c6  ,
c7  ,
c8  ,
c9  ,
c10  ,
c11  ,
c12  ,
c13  ,
c14  ,
c15  ,
c16   
)

Configure 16 controls simultaneously.

Parameters
addressAddress of the first control.
c1First control status, boolean true activates, boolean false deactivates.
c2Second control status, boolean true activates, boolean false deactivates.
c3Third control status, boolean true activates, boolean false deactivates.
c4Fourth control status, boolean true activates, boolean false deactivates.
c5Fifth control status, boolean true activates, boolean false deactivates.
c6Sixth control status, boolean true activates, boolean false deactivates.
c7Seventh control status, boolean true activates, boolean false deactivates.
c8Eighth control status, boolean true activates, boolean false deactivates.
c9Ninth control status, boolean true activates, boolean false deactivates.
c10Tenth control status, boolean true activates, boolean false deactivates.
c11Eleventh control status, boolean true activates, boolean false deactivates.
c12Twelth control status, boolean true activates, boolean false deactivates.
c13Thirteenth control status, boolean true activates, boolean false deactivates.
c14Fourteenth control status, boolean true activates, boolean false deactivates.
c15Fifteenth control status, boolean true activates, boolean false deactivates.
c16Sixteenth control status, boolean true activates, boolean false deactivates.

◆ Control4()

ctiacela::CTIAcela::Control4 ( address  ,
c1  ,
c2  ,
c3  ,
c4   
)

Configure 4 controls simultaneously.

Parameters
addressAddress of the first control.
c1First control status, boolean true activates, boolean false deactivates.
c2Second control status, boolean true activates, boolean false deactivates.
c3Third control status, boolean true activates, boolean false deactivates.
c4Fourth control status, boolean true activates, boolean false deactivates.

◆ Control8()

ctiacela::CTIAcela::Control8 ( address  ,
c1  ,
c2  ,
c3  ,
c4  ,
c5  ,
c6  ,
c7  ,
c8   
)

Configure 8 controls simultaneously.

Parameters
addressAddress of the first control.
c1First control status, boolean true activates, boolean false deactivates.
c2Second control status, boolean true activates, boolean false deactivates.
c3Third control status, boolean true activates, boolean false deactivates.
c4Fourth control status, boolean true activates, boolean false deactivates.
c5Fifth control status, boolean true activates, boolean false deactivates.
c6Sixth control status, boolean true activates, boolean false deactivates.
c7Seventh control status, boolean true activates, boolean false deactivates.
c8Eighth control status, boolean true activates, boolean false deactivates.

◆ CTIAcela()

ctiacela::CTIAcela::CTIAcela ( name  ,
port  ,
  ... 
)

Constructor: open a connection to the CTI Acela.

Parameters
nameThe name of this instance.
portName of the serial port connected to theCTI Acela.
...Options:
  • -srqhandler Script to run when there is a sense state change.

◆ Deactive()

ctiacela::CTIAcela::Deactive ( address  )

Deactive a control.

Parameters
addressAddress of the control.

◆ EmergencyStop()

ctiacela::CTIAcela::EmergencyStop ( )

Emergency Stop.

Stop all trains.

◆ HaveData()

ctiacela::CTIAcela::HaveData ( )
Returns
Yes, if there is data available.

◆ highbyte()

static ctiacela::CTIAcela::highbyte ( addr  )
staticprivate

Return the high byte of address.

Parameters
addrAddress word (16-bits)
Returns
upper 8 bits

◆ lowbyte()

static ctiacela::CTIAcela::lowbyte ( addr  )
staticprivate

Return the low byte of address.

Parameters
addrAddress word (16-bits)
Returns
lower 8 bits

◆ NetworkOffline()

ctiacela::CTIAcela::NetworkOffline ( )

Bring the network offline.

◆ NetworkOnline()

ctiacela::CTIAcela::NetworkOnline ( )

Bring the network online.

◆ OnlineP()

ctiacela::CTIAcela::OnlineP ( )
Returns
Yes, if the network is online.

◆ pack4()

static ctiacela::CTIAcela::pack4 ( b1  ,
b2  ,
b3  ,
b4   
)
staticprivate

pack 4 bits

Parameters
b1First bit
b2Second bit
b3Third bit
b4Fourth bit
Returns
a byte with the bits packed.

◆ pack8()

static ctiacela::CTIAcela::pack8 ( b1  ,
b2  ,
b3  ,
b4  ,
b5  ,
b6  ,
b7  ,
b8   
)
staticprivate

pack 4 bits

Parameters
b1First bit
b2Second bit
b3Third bit
b4Fourth bit
b5Fifth bit
b6Sixth bit
b7Seventh bit
b8Eighth bit
Returns
a byte with the bits packed.

◆ Poll()

ctiacela::CTIAcela::Poll ( )

Poll the network configuration.

Returns
a list of modules on the network.

◆ PulseOff()

ctiacela::CTIAcela::PulseOff ( address  ,
pulsewidth   
)

Pulse Off a control.

Parameters
addressAddress of the control.
pulsewidthPulsewidth in 10ths of a second

◆ PulseOn()

ctiacela::CTIAcela::PulseOn ( address  ,
pulsewidth   
)

Pulse On a control.

Parameters
addressAddress of the control.
pulsewidthPulsewidth in 10ths of a second

◆ Query()

ctiacela::CTIAcela::Query ( )

Query sensor change state.

Returns
true if sensors changed state since the last Query call.

◆ Read()

ctiacela::CTIAcela::Read ( address  )

Read the state of a sensor.

Parameters
addressAddress of the sensor.
Returns
the sensor state as a boolean value.

◆ Read16()

ctiacela::CTIAcela::Read16 ( address  )

Read the state of sixteen sensors.

Parameters
addressAddress of the first sensor.
Returns
the state of sisteen sensors as a sixteen element list of boolean values.

◆ Read4()

ctiacela::CTIAcela::Read4 ( address  )

Read the state of four sensors.

Parameters
addressAddress of the first sensor.
Returns
the state of four sensors as a four element list of boolean values.

◆ Read8()

ctiacela::CTIAcela::Read8 ( address  )

Read the state of eight sensors.

Parameters
addressAddress of the first sensor.
Returns
the state of eight sensors as an eight element list of boolean values.

◆ ReadAll()

ctiacela::CTIAcela::ReadAll ( )

Read all sensors.

Returns
the state of all sensors as a list of boolean values.

◆ ReadRevision()

ctiacela::CTIAcela::ReadRevision ( )

Read CTI Acela firmware revision.

Returns
a two element list containing the major and minor revision numbers of the Acela

◆ ResetNetwork()

ctiacela::CTIAcela::ResetNetwork ( )

Reset the network.

◆ ReverseBlink()

ctiacela::CTIAcela::ReverseBlink ( address  ,
pulsewidth   
)

Reverse Blink a control.

Parameters
addressAddress of the control.
pulsewidthPulsewidth in 10ths of a second

◆ Signal2()

ctiacela::CTIAcela::Signal2 ( address  ,
lamp1  ,
lamp2  ,
yellow  = "off" 
)

Control 2-lamp signals.


Parameters
addressAddress of first lamp.
lamp1Lamp 1 control, one of off, on, blink, or reverseblink.
lamp2Lamp 2 control, one of off, on, blink, or reverseblink.
yellowYellow control, one of off, on, blink, or reverseblink.

◆ Signal3()

ctiacela::CTIAcela::Signal3 ( address  ,
lamp1  ,
lamp2  ,
lamp3   
)

Control 3-lamp signals.


Parameters
addressAddress of first lamp.
lamp1Lamp 1 control, one of off, on, blink, or reverseblink.
lamp2Lamp 2 control, one of off, on, blink, or reverseblink.
lamp3Lamp 3control, one of off, on, blink, or reverseblink.

◆ Signal4()

ctiacela::CTIAcela::Signal4 ( address  ,
lamp1  ,
lamp2  ,
lamp3  ,
lamp4   
)

Control 4-lamp signals.


Parameters
addressAddress of first lamp.
lamp1Lamp 1 control, one of off, on, blink, or reverseblink.
lamp2Lamp 2 control, one of off, on, blink, or reverseblink.
lamp3Lamp 3 control, one of off, on, blink, or reverseblink.
lamp4Lamp 4 control, one of off, on, blink, or reverseblink.

◆ SignalBrightness()

ctiacela::CTIAcela::SignalBrightness ( brightness  )

Set signal brightness.

Parameters
brightnessSignal brightness.

◆ SignalSettings()

ctiacela::CTIAcela::SignalSettings ( blinkrate  ,
yellowhue   
)

Set Signal Settings.

Parameters
blinkrateBlink rate in 10ths of a second
yellowhueMix of red and green to get yellow as a percentage of green vs red: 128 is 50/50.

◆ SRQControl()

ctiacela::CTIAcela::SRQControl ( enable  = "yes")

Enable or disable SRQ messages.

Parameters
enableBoolean, if true enable SRQ messages.

◆ Throttle()

ctiacela::CTIAcela::Throttle ( address  ,
speed  ,
momentum  ,
brake  ,
direction  ,
idle   
)

Throttle command.

Parameters
addressAddress of the throttle.
speedSpeed (0-100).
momentumMomentum Control (0 minimum, 7 maximum).
brakeBrake control (boolean: true is on).
directionDirection control (forward or reverse).
idleIdle Voltage Control (boolean: true is on).

◆ validate()

static ctiacela::CTIAcela::validate ( object  )
static

Type validation method.

Validate object as a CTIAcela instance.

Parameters
objectThe object to validate.

◆ ~CTIAcela()

ctiacela::CTIAcela::~CTIAcela ( )

The destructor restores the serial port's state and closes it.

Variable Documentation

◆ _timeout

ctiacela::CTIAcela::_timeout
private

Timeout flag.

◆ CTI_DeviceMap

ctiacela::CTIAcela::CTI_DeviceMap
staticprivate

CTI Module Map.

◆ ctiacela

ctiacela::ctiacela

◆ dataavailable

ctiacela::CTIAcela::dataavailable
private

Flag set to true (yes) when sensor data is available.

◆ FilterSelectBits

ctiacela::CTIAcela::FilterSelectBits
staticprivate

Filter Select Bits.

◆ LampBits

ctiacela::CTIAcela::LampBits
staticprivate

Lamp Bits.

◆ maxtries

ctiacela::CTIAcela::maxtries
staticprivate

Loop control for read attempts.

◆ networkonline

ctiacela::CTIAcela::networkonline
private

Flag set to false (no) when the network goes offline.

◆ Opcodes

ctiacela::CTIAcela::Opcodes
staticprivate

Opcodes.

◆ Responses

ctiacela::CTIAcela::Responses
staticprivate

Responses.

◆ ttyfd

ctiacela::CTIAcela::ttyfd
private

Terminal file descriptor.