Model Railroad System
2.2.1
|
This folder contains a collection of Tcl code to implement block occupancy detection, using various methods. At the very least, block detection results in signal aspect updates. Code for managing signals is in in the Signals folder.
There are two main ways to detect trains: using optical sensors or using current sensors. Optical sensors generally work via reflection (bouncing a light beam off the bottom of the train), although an across-the-tracks type is possible too. Current sensors work by sensing a current flow when a locomotive, lighted passenger car, or a freight car with resistors installed on its wheelsets passes onto an electrically isolated section of track. In any case, the sensor is connected to the computer somehow, either via USB or via a direct or indirect I/O bit or port.
There are several Tcl source files in this directory. Each contains a SNIT Abstract data type (also known as a Class). This abstract data type encapsulates a single block. All of these abstract data types include a method named occupiedp
, which returns a true or false result indicating whether or not the block is occupied. The constructor for these types include options or arguments that define the I/O device(s) that connect to whatever sensors are being used to detect block occupancy.
MRD2_Block.tcl contains an abstract data type (MRD2_Block) that implements blocks using one Azatrax MRD2U Sensor for each block.
C4TSR4_Block.tcl contains an abstract data type (C4TSR4_Block) that implements blocks using Circuits4Tracks Quad Occupancy Detectors connected to Azatrax SR4 modules using SSRs. One Circuits4Tracks Quad Occupancy Detector and one SR4 will handle 4 blocks.
C4TSMINI_Block.tcl contains an abstract data type (C4TSMINI_Block) that implements blocks using Circuits4Tracks Quad Occupancy Detectors connected to input pins of a Bruce Chubb C/MRI Super Mini (SMINI) board. A Bruce Chubb C/MRI Super Mini (SMINI) board has enough inputs to handle a number of Circuits4Tracks Quad Occupancy Detectors.
C4TTB_Block.tcl contains an abstract data type (C4TTB_Block) that implements blocks using Circuits4Tracks Quad Occupancy Detectors connected to the sensor inputs of a CTI Train Brain, Watchman, or Sentry board.Circuits4Tracks Quad Occupancy Detector connected to a
All three types have a common structure. The constructors take the form:
Eg:
There are a pair of common options, -previousblock
and -nextblock
, which are the names of the previous block in the forward direction and the name of the previous block in the reverse direction. Another pair of common options, -forwardsignalobj
and -reversesignalobj
, are the names of signal objects. Also there is the option, -direction
with sets the current operating direction for the block and can be forward
or reverse
. For blocks that only support traffic in one direction, use only the -previousblock
and -forwardsignalobj
options. The -direction
defaults to forward
. There are other object specific options that define how the sensor is accessed by the block object.
There are four common methods, two public and two private (the private methods should not be used by external code). The public methods are occupiedp
and propagate
. The occupiedp
method returns a true or false (logical) value that indicates whether the block is occupied or not. The propagate
method takes a signal aspect to 'propagate' to the previous block. The occupiedp
method is typically called from the occupied command script associated with a piece of track work.
The two private methods, _entering
and _exiting
are used to implement special handling when entering or leaving a block. Presently, the _entering
method sets the signal aspect and propagates signal aspects down to previous blocks and the _exiting
method does nothing. These methods can be extended to add additional functionality, as needed.