|
Model Railroad System 2.2.2
|
CTI Acela Serial Port Interface. More...
Namespaces | |
| namespace | 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... | |
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.
| unsigned short int ctiacela::addresstype |
Module address type.
An integer in the range from 0 to 65535, inclusive.
Filter threshold type.
An integer from 0 to 31, inclusive.
Momentium control type.
Integer in the range of 0 to 7, inclusive.
Speed type.
Integer in the range of 0 to 100, inclusive.
| unsigned char ctiacela::ubyte |
Unsigned byte type.
An integer in the range from 0 to 255, inclusive.
|
private |
Handle a service request.
|
private |
Read a single byte from the serial interface.
Used by methods that read responses.
| thebytevar | A name of a variable to put the byte read. Undefined if there was an error. |
|
private |
Read event method.
|
private |
Transmit buffer and wait for response.
| buffer | List of bytes to transmit. |
| responsebytes | Number of expected databytes (not counting the command ack byte) or N for a variable number of result bytes. |
| ctiacela::CTIAcela::Activate | ( | address | ) |
Activate a control.
| address | Address of the control. |
| ctiacela::CTIAcela::Blink | ( | address | , |
| pulsewidth | |||
| ) |
Blink a control.
| address | Address of the control. |
| pulsewidth | Pulsewidth in 10ths of a second |
| ctiacela::CTIAcela::ConfigureSensor | ( | address | , |
| threshold | , | ||
| select | , | ||
| polarity | |||
| ) |
Configure a sensor.
| address | Address of the sensor. |
| threshold | Filter threshold, 0-31. |
| select | Filter select, one of noise, bounce, gap, pr dirty. |
| polarity | Polarity, one of normal or invert. |
| ctiacela::CTIAcela::Control16 | ( | address | , |
| c1 | , | ||
| c2 | , | ||
| c3 | , | ||
| c4 | , | ||
| c5 | , | ||
| c6 | , | ||
| c7 | , | ||
| c8 | , | ||
| c9 | , | ||
| c10 | , | ||
| c11 | , | ||
| c12 | , | ||
| c13 | , | ||
| c14 | , | ||
| c15 | , | ||
| c16 | |||
| ) |
Configure 16 controls simultaneously.
| address | Address of the first control. |
| c1 | First control status, boolean true activates, boolean false deactivates. |
| c2 | Second control status, boolean true activates, boolean false deactivates. |
| c3 | Third control status, boolean true activates, boolean false deactivates. |
| c4 | Fourth control status, boolean true activates, boolean false deactivates. |
| c5 | Fifth control status, boolean true activates, boolean false deactivates. |
| c6 | Sixth control status, boolean true activates, boolean false deactivates. |
| c7 | Seventh control status, boolean true activates, boolean false deactivates. |
| c8 | Eighth control status, boolean true activates, boolean false deactivates. |
| c9 | Ninth control status, boolean true activates, boolean false deactivates. |
| c10 | Tenth control status, boolean true activates, boolean false deactivates. |
| c11 | Eleventh control status, boolean true activates, boolean false deactivates. |
| c12 | Twelth control status, boolean true activates, boolean false deactivates. |
| c13 | Thirteenth control status, boolean true activates, boolean false deactivates. |
| c14 | Fourteenth control status, boolean true activates, boolean false deactivates. |
| c15 | Fifteenth control status, boolean true activates, boolean false deactivates. |
| c16 | Sixteenth control status, boolean true activates, boolean false deactivates. |
| ctiacela::CTIAcela::Control4 | ( | address | , |
| c1 | , | ||
| c2 | , | ||
| c3 | , | ||
| c4 | |||
| ) |
Configure 4 controls simultaneously.
| address | Address of the first control. |
| c1 | First control status, boolean true activates, boolean false deactivates. |
| c2 | Second control status, boolean true activates, boolean false deactivates. |
| c3 | Third control status, boolean true activates, boolean false deactivates. |
| c4 | Fourth control status, boolean true activates, boolean false deactivates. |
| ctiacela::CTIAcela::Control8 | ( | address | , |
| c1 | , | ||
| c2 | , | ||
| c3 | , | ||
| c4 | , | ||
| c5 | , | ||
| c6 | , | ||
| c7 | , | ||
| c8 | |||
| ) |
Configure 8 controls simultaneously.
| address | Address of the first control. |
| c1 | First control status, boolean true activates, boolean false deactivates. |
| c2 | Second control status, boolean true activates, boolean false deactivates. |
| c3 | Third control status, boolean true activates, boolean false deactivates. |
| c4 | Fourth control status, boolean true activates, boolean false deactivates. |
| c5 | Fifth control status, boolean true activates, boolean false deactivates. |
| c6 | Sixth control status, boolean true activates, boolean false deactivates. |
| c7 | Seventh control status, boolean true activates, boolean false deactivates. |
| c8 | Eighth control status, boolean true activates, boolean false deactivates. |
| ctiacela::CTIAcela::CTIAcela | ( | name | , |
| port | , | ||
| ... | |||
| ) |
Constructor: open a connection to the CTI Acela.
| name | The name of this instance. |
| port | Name of the serial port connected to theCTI Acela. |
| ... | Options:
|
| ctiacela::CTIAcela::Deactive | ( | address | ) |
Deactive a control.
| address | Address of the control. |
| ctiacela::CTIAcela::EmergencyStop | ( | ) |
Emergency Stop.
Stop all trains.
| ctiacela::CTIAcela::HaveData | ( | ) |
|
staticprivate |
Return the high byte of address.
| addr | Address word (16-bits) |
|
staticprivate |
Return the low byte of address.
| addr | Address word (16-bits) |
| ctiacela::CTIAcela::NetworkOffline | ( | ) |
Bring the network offline.
| ctiacela::CTIAcela::NetworkOnline | ( | ) |
Bring the network online.
| ctiacela::CTIAcela::OnlineP | ( | ) |
|
staticprivate |
pack 4 bits
| b1 | First bit |
| b2 | Second bit |
| b3 | Third bit |
| b4 | Fourth bit |
|
staticprivate |
pack 4 bits
| b1 | First bit |
| b2 | Second bit |
| b3 | Third bit |
| b4 | Fourth bit |
| b5 | Fifth bit |
| b6 | Sixth bit |
| b7 | Seventh bit |
| b8 | Eighth bit |
| ctiacela::CTIAcela::Poll | ( | ) |
Poll the network configuration.
| ctiacela::CTIAcela::PulseOff | ( | address | , |
| pulsewidth | |||
| ) |
Pulse Off a control.
| address | Address of the control. |
| pulsewidth | Pulsewidth in 10ths of a second |
| ctiacela::CTIAcela::PulseOn | ( | address | , |
| pulsewidth | |||
| ) |
Pulse On a control.
| address | Address of the control. |
| pulsewidth | Pulsewidth in 10ths of a second |
| ctiacela::CTIAcela::Query | ( | ) |
Query sensor change state.
| ctiacela::CTIAcela::Read | ( | address | ) |
Read the state of a sensor.
| address | Address of the sensor. |
| ctiacela::CTIAcela::Read16 | ( | address | ) |
Read the state of sixteen sensors.
| address | Address of the first sensor. |
| ctiacela::CTIAcela::Read4 | ( | address | ) |
Read the state of four sensors.
| address | Address of the first sensor. |
| ctiacela::CTIAcela::Read8 | ( | address | ) |
Read the state of eight sensors.
| address | Address of the first sensor. |
| ctiacela::CTIAcela::ReadAll | ( | ) |
Read all sensors.
| ctiacela::CTIAcela::ReadRevision | ( | ) |
Read CTI Acela firmware revision.
| ctiacela::CTIAcela::ResetNetwork | ( | ) |
Reset the network.
| ctiacela::CTIAcela::ReverseBlink | ( | address | , |
| pulsewidth | |||
| ) |
Reverse Blink a control.
| address | Address of the control. |
| pulsewidth | Pulsewidth in 10ths of a second |
| ctiacela::CTIAcela::Signal2 | ( | address | , |
| lamp1 | , | ||
| lamp2 | , | ||
| yellow | = "off" |
||
| ) |
Control 2-lamp signals.
| address | Address of first lamp. |
| lamp1 | Lamp 1 control, one of off, on, blink, or reverseblink. |
| lamp2 | Lamp 2 control, one of off, on, blink, or reverseblink. |
| yellow | Yellow control, one of off, on, blink, or reverseblink. |
| ctiacela::CTIAcela::Signal3 | ( | address | , |
| lamp1 | , | ||
| lamp2 | , | ||
| lamp3 | |||
| ) |
Control 3-lamp signals.
| address | Address of first lamp. |
| lamp1 | Lamp 1 control, one of off, on, blink, or reverseblink. |
| lamp2 | Lamp 2 control, one of off, on, blink, or reverseblink. |
| lamp3 | Lamp 3control, one of off, on, blink, or reverseblink. |
| ctiacela::CTIAcela::Signal4 | ( | address | , |
| lamp1 | , | ||
| lamp2 | , | ||
| lamp3 | , | ||
| lamp4 | |||
| ) |
Control 4-lamp signals.
| address | Address of first lamp. |
| lamp1 | Lamp 1 control, one of off, on, blink, or reverseblink. |
| lamp2 | Lamp 2 control, one of off, on, blink, or reverseblink. |
| lamp3 | Lamp 3 control, one of off, on, blink, or reverseblink. |
| lamp4 | Lamp 4 control, one of off, on, blink, or reverseblink. |
| ctiacela::CTIAcela::SignalBrightness | ( | brightness | ) |
Set signal brightness.
| brightness | Signal brightness. |
| ctiacela::CTIAcela::SignalSettings | ( | blinkrate | , |
| yellowhue | |||
| ) |
Set Signal Settings.
| blinkrate | Blink rate in 10ths of a second |
| yellowhue | Mix of red and green to get yellow as a percentage of green vs red: 128 is 50/50. |
| ctiacela::CTIAcela::SRQControl | ( | enable | = "yes" | ) |
Enable or disable SRQ messages.
| enable | Boolean, if true enable SRQ messages. |
| ctiacela::CTIAcela::Throttle | ( | address | , |
| speed | , | ||
| momentum | , | ||
| brake | , | ||
| direction | , | ||
| idle | |||
| ) |
Throttle command.
| address | Address of the throttle. |
| speed | Speed (0-100). |
| momentum | Momentum Control (0 minimum, 7 maximum). |
| brake | Brake control (boolean: true is on). |
| direction | Direction control (forward or reverse). |
| idle | Idle Voltage Control (boolean: true is on). |
|
static |
Type validation method.
Validate object as a CTIAcela instance.
| object | The object to validate. |
| ctiacela::CTIAcela::~CTIAcela | ( | ) |
The destructor restores the serial port's state and closes it.
|
private |
Timeout flag.
|
staticprivate |
CTI Module Map.
| ctiacela::ctiacela |
|
private |
Flag set to true (yes) when sensor data is available.
|
staticprivate |
Filter Select Bits.
|
staticprivate |
Lamp Bits.
|
staticprivate |
Loop control for read attempts.
|
private |
Flag set to false (no) when the network goes offline.
|
staticprivate |
Opcodes.
|
staticprivate |
Responses.
|
private |
Terminal file descriptor.