Model Railroad System  2.2.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
C4TSMINI_Switch Class Reference

Switch (turnout) operation using a Chubb SMINI board and a Circuits4Tracks Quad OD for OS detection. More...

Public Member Functions

 C4TSMINI_Switch (name,...)
 Constructor: initialize the switch object. More...
 
 occupiedp ()
 The occupiedp method returns yes or no (true or false) indicating block (OS) occupation. More...
 
 pointstate ()
 The pointstate method returns normal if the points are aligned to the main route and reverse if the points are aligned to the divergent route. More...
 
 motor (route)
 The motor method sets the switch motor to align the points for the specificed route. More...
 
 propagate (aspect, from,...)
 Method used to propagate distant signal states back down the line. More...
 

Static Public Member Functions

static validate (object)
 Type validating code Raises an error if object is not either the empty string or a SR4_C4TSR4_Switch type. More...
 

Protected Member Functions

 _entering ()
 Code to run when just entering the OS Sets the signal aspects and propagates signal state. More...
 
 _exiting ()
 Code to run when about to exit the OS. More...
 

Private Member Functions

 _settruedirection (option, value)
 A method to fake direction for frog facing switches. More...
 
 _gettruedirection (option)
 A method to fake direction for frog facing switches. More...
 

Private Attributes

 node
 SMINI node object. More...
 
 isoccupied
 Saved occupation state. More...
 

Static Private Attributes

static _motorbits
 Motor bit values. More...
 
static _pointsense
 Point sense bit values. More...
 
static _routes
 Route check validation object. More...
 

Detailed Description

Switch (turnout) operation using a Chubb SMINI board and a Circuits4Tracks Quad OD for OS detection.

Above is a typical switch (turnout) using an Chubb SMINI board to control a Circuitron Tortoise Switch Machine and to sense the point position and a Circuits4Track quad occupancy detector to sense occupation of the switch.

Typical usage:

# Connect to the cmribus through a USB RS485 adapter at /dev/ttyUSB0
CmriSupport::CmriNode openport /dev/ttyUSB0
# SMINI board at address 0
CmriSupport::CmriNode SMINI0 -type SMINI -address 0
# Switch 1 is controled by bits 0 and 1 of output port 0
# Switch 1 points are sensed by bits 0 and 1 of input port 0
# Switch 1 OS is detected on bit 0 of input port 1
C4TSMINI_Switch switch1 -nodeobj SMINI0 -motorport 0 -motorbit 0 \
-pointsenseport 0 -pointsensebit 0 \
-plate SwitchPlate1 \
-ossensorport 1 -osbit 0
# Switch 2 is controled by bits 0 and 1 of output port 1
# Switch 2 points are sensed by bits 2 and 3 of input port 0
# Switch 2 OS is detected on bit 1 of input port 1
C4TSMINI_Switch switch2 -nodeobj SMINI0 -motorport 1 -motorbit 0 \
-pointsenseport 0 -pointsensebit 2 \
-plate SwitchPlate2 \
-ossensorport 1 -osbit 1

For the track work elements use "switchN occupiedp" for the track work elements' occupied script and use "switchN pointstate" for the track work elements' state script. For the switch plate use "switchN motor normal" for the normal script and "switchN motor reverse" for the reverse script.

Then in the Main Loop, you would have:

while {true} {
MainWindow ctcpanel invoke Switch1
MainWindow ctcpanel invoke Switch2
MainWindow ctcpanel invoke SwitchPlate1
MainWindow ctcpanel invoke SwitchPlate2
update;# Update display
}
Author
Robert Heller <heller@deepsoft.com>

Definition at line 57 of file C4TSMINI_Switch.tcl.

Constructor & Destructor Documentation

◆ C4TSMINI_Switch()

C4TSMINI_Switch::C4TSMINI_Switch ( name  ,
  ... 
)

Constructor: initialize the switch object.

Create a low level sensor object and install it as a component. Install the switch's signals, motor, and point sense objects.

Parameters
nameName of the switch object
...Options:
  • -nodeobj Cmri node object
  • -motorport Output port number for motor control.
  • -motorbit First (of two) motor control bits.
  • -pointsenseport Input port for point sense.
  • -pointsensebit First (of two) point sense bits.
  • -ossensorport Input port for OS sense.
  • -osbit This defines the input bit on the input port for OS sense.
  • -direction The current direction of travel. Forward always means entering at the point end.
  • -forwarddirection The logial forward direction. Set this to reverse for a frog facing switch. Default is forward and it is readonly and can only be set during creation.
  • -forwardsignalobj The signal object protecting the points. Presumed to be a two headed signal, with the upper head relating to the main (straight) route and the lower head relating to the divergent route. The upper head has three colors: red, yellow, and green. The lower head only two: red and green.
  • -reversemainsignalobj The signal object protecting the straight frog end. Presumed to be single headed (with number plate).
  • -reversedivergentsignalobj The signal object protecting the divergent frog end. Presumed to be single headed (with number plate).
  • -previousblock The block connected to the point end.
  • -nextmainblock The block connected to the straight frog end.
  • -nextdivergentblock The block connected to the divergent frog end.
  • -plate The name of the switch plate for this switch.

Member Function Documentation

◆ _entering()

C4TSMINI_Switch::_entering ( )
protected

Code to run when just entering the OS Sets the signal aspects and propagates signal state.

◆ _exiting()

C4TSMINI_Switch::_exiting ( )
protected

Code to run when about to exit the OS.

◆ _gettruedirection()

C4TSMINI_Switch::_gettruedirection ( option  )
private

A method to fake direction for frog facing switches.

Parameters
optionThis is always -direction.
Returns
Either forward or reverse.

◆ _settruedirection()

C4TSMINI_Switch::_settruedirection ( option  ,
value   
)
private

A method to fake direction for frog facing switches.

Parameters
optionThis is always -direction.
valueEither forward or reverse.

◆ motor()

C4TSMINI_Switch::motor ( route  )

The motor method sets the switch motor to align the points for the specificed route.

Parameters
routeThe desired route. A value of normal means align the points to the main (straight) route and a value of reverse means align the points to the divergent route.

◆ occupiedp()

C4TSMINI_Switch::occupiedp ( )

The occupiedp method returns yes or no (true or false) indicating block (OS) occupation.

Returns
Yes or no, indicating whether the OS is occupied.

◆ pointstate()

C4TSMINI_Switch::pointstate ( )

The pointstate method returns normal if the points are aligned to the main route and reverse if the points are aligned to the divergent route.

If the state cannot be determined, a value of unknown is returned.

Returns
Normal or reverse, indicating the point state.

◆ propagate()

C4TSMINI_Switch::propagate ( aspect  ,
from  ,
  ... 
)

Method used to propagate distant signal states back down the line.

Parameters
aspectThe signal aspect that is being propagated.
fromThe propagating block.
...Options:
  • -direction The direction of the propagation.

◆ validate()

static C4TSMINI_Switch::validate ( object  )
static

Type validating code Raises an error if object is not either the empty string or a SR4_C4TSR4_Switch type.

Parameters
objectSome object.

Member Data Documentation

◆ _motorbits

C4TSMINI_Switch::_motorbits
staticprivate

Motor bit values.

Definition at line 86 of file C4TSMINI_Switch.tcl.

◆ _pointsense

C4TSMINI_Switch::_pointsense
staticprivate

Point sense bit values.

Definition at line 90 of file C4TSMINI_Switch.tcl.

◆ _routes

C4TSMINI_Switch::_routes
staticprivate

Route check validation object.

Definition at line 165 of file C4TSMINI_Switch.tcl.

◆ isoccupied

C4TSMINI_Switch::isoccupied
private

Saved occupation state.

Definition at line 82 of file C4TSMINI_Switch.tcl.

◆ node

C4TSMINI_Switch::node
private

SMINI node object.

Definition at line 78 of file C4TSMINI_Switch.tcl.

C4TSMINI_Switch
Switch (turnout) operation using a Chubb SMINI board and a Circuits4Tracks Quad OD for OS detection.
Definition: C4TSMINI_Switch.tcl:57