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
SR4_MRD2_Switch Class Reference

Switch (turnout) operation using 1/2 of a SR4. More...

Public Member Functions

 SR4_MRD2_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_MRD2_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

 motor
 Motor device (SR4 outputs) More...
 
 pointsense
 Point sense device (SR4 inputs) More...
 
 ossensor
 Occupency sensor (MRD2) More...
 
 forwardsignal
 Signal at the points. More...
 
 reversemainsignal
 Signal at the straight frog end. More...
 
 reversedivergentsignal
 Signal at the divergent frog end. More...
 

Static Private Attributes

static _routes
 Route check validation object. More...
 

Detailed Description

Switch (turnout) operation using 1/2 of a SR4.

Above is a typical switch (turnout) using an Azatrax SR4 to control a Circuitron Tortoise Switch Machine and to sense the point position and an Azatrax MRD2 to sense occupation of the switch. (A high resolution PDF and a Xtrkcad layout file are included.)

Typical usage:

SR4 turnoutControl1 \
-this [Azatrax_OpenDevice 0400001234 $::Azatrax_idSR4Product]
# Disable inputs controlling outputs.
turnoutControl1 OutputRelayInputControl 0 0 0 0
# Switch 1 is controlled and sensed by the lower 1/2 of turnoutControl1
SR4_MRD2_Switch switch1 -motorobj turnoutControl1 -motorhalf lower \
-pointsenseobj turnoutControl1 \
-pointsensehalf lower -plate SwitchPlate1 \
-ossensorsn 0200001234
# Switch2 is controlled and sensed by the upper 1/2 of turnoutControl1
SR4_MRD2_Switch switch2 -motorobj turnoutControl1 -motorhalf upper \
-pointsenseobj turnoutControl1 \
-pointsensehalf upper -plate SwitchPlate2 \
-ossensorsn 0200001235

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 53 of file SR4_MRD2_Switch.tcl.

Constructor & Destructor Documentation

◆ SR4_MRD2_Switch()

SR4_MRD2_Switch::SR4_MRD2_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:
  • -motorobj Object (SR4) that controls the motor.
  • -motorhalf Which half: lower means Q1 and Q2, upper means Q3 and Q4.
  • -pointsenseobj Object (SR4) that senses the point state.
  • -pointsensehalf Which half: lower means I1 and I2, upper means I3 and I4.
  • -ossensorsn Serial number of the MRD2 that is sensing OS.
  • -diverttimeout Timeout, in seconds to allow for a train to clear the turnout when going on a divergent route.
  • -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()

SR4_MRD2_Switch::_entering ( )
protected

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

◆ _exiting()

SR4_MRD2_Switch::_exiting ( )
protected

Code to run when about to exit the OS.

◆ _gettruedirection()

SR4_MRD2_Switch::_gettruedirection ( option  )
private

A method to fake direction for frog facing switches.

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

◆ _settruedirection()

SR4_MRD2_Switch::_settruedirection ( option  ,
value   
)
private

A method to fake direction for frog facing switches.

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

◆ motor()

SR4_MRD2_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()

SR4_MRD2_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()

SR4_MRD2_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()

SR4_MRD2_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 SR4_MRD2_Switch::validate ( object  )
static

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

Parameters
objectSome object.

Member Data Documentation

◆ _routes

SR4_MRD2_Switch::_routes
staticprivate

Route check validation object.

Definition at line 169 of file SR4_MRD2_Switch.tcl.

◆ forwardsignal

SR4_MRD2_Switch::forwardsignal
private

Signal at the points.

Definition at line 85 of file SR4_MRD2_Switch.tcl.

◆ motor

SR4_MRD2_Switch::motor
private

Motor device (SR4 outputs)

Definition at line 73 of file SR4_MRD2_Switch.tcl.

◆ ossensor

SR4_MRD2_Switch::ossensor
private

Occupency sensor (MRD2)

Definition at line 81 of file SR4_MRD2_Switch.tcl.

◆ pointsense

SR4_MRD2_Switch::pointsense
private

Point sense device (SR4 inputs)

Definition at line 77 of file SR4_MRD2_Switch.tcl.

◆ reversedivergentsignal

SR4_MRD2_Switch::reversedivergentsignal
private

Signal at the divergent frog end.

Definition at line 93 of file SR4_MRD2_Switch.tcl.

◆ reversemainsignal

SR4_MRD2_Switch::reversemainsignal
private

Signal at the straight frog end.

Definition at line 89 of file SR4_MRD2_Switch.tcl.

SR4_MRD2_Switch
Switch (turnout) operation using 1/2 of a SR4.
Definition: SR4_MRD2_Switch.tcl:53