Model Railroad System  2.2.2
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
C4TSMINI_Block Class Reference

Block occupation detection using Circuits4Tracks Quad Occupancy Detectors and Azatrax SR4s. More...

Public Member Functions

 C4TSMINI_Block (name,...)
 Constructor: initialize the block object. More...
 
 occupiedp ()
 The occupiedp method returns yes or no (true or false) indicating block occupation. 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 C4TSMINI_Block type. More...
 

Private Member Functions

 _entering ()
 Method for entering a block. More...
 
 _exiting ()
 Method for exiting a block. More...
 

Private Attributes

 node
 SMINI node object. More...
 
 forwardsignal
 Signal object (typically a three color, one head block signal. More...
 
 reversesignal
 Signal object (typically a three color, one head block signal. More...
 
 isoccupied
 Saved occupation state. More...
 

Detailed Description

Block occupation detection using Circuits4Tracks Quad Occupancy Detectors and Azatrax SR4s.

Above is a simple diagram for using Circuits4Tracks Quad Occupancy Detectors for block occupation detection. A Circuits4Tracks Quad Occupancy board has four current sensors. One wires one side of the track power (either DCC or DC) to a common rail and the other side through the Circuits4Tracks Quad Occupancy Detector to rails isolated with gaps (possibly with insulating rail joiners). This code uses a Chubb SMINI board to connect a Circuits4Tracks Quad Occupancy Detectors to the computer via a serial interface.

Typical usage:

Four blocks in a loop:

# 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
# The first four bits of the first port are wired to the Circuits4Tracks
# Quad Occupancy Detector
C4TSR4_Block block1 -nodeobj SMINI0 -port 0 -bit 0 -signalobj signal1
C4TSR4_Block block2 -nodeobj SMINI0 -port 0 -bit 1 -signalobj signal2 -previousblock block1
C4TSR4_Block block3 -nodeobj SMINI0 -port 0 -bit 2 -signalobj signal3 -previousblock block2
C4TSR4_Block block4 -nodeobj SMINI0 -port 0 -bit 3 -signalobj signal4 -previousblock block3
block1 configure -previousblock block4
Block occupation detection using Circuits4Tracks Quad Occupancy Detectors and Azatrax SR4s.

A Schematic of the layout would look like this:

For the track work elements use "blockN occupiedp" for the track work elements' occupied command: eg Block1 would have 'block1 occupiedp' as its occupied command, that is its edit window would look like:

The other three blocks would be similar.

Then in the Main Loop, you would have:

while {true} {
MainWindow ctcpanel invoke Block1
MainWindow ctcpanel invoke Block2
MainWindow ctcpanel invoke Block3
MainWindow ctcpanel invoke Block4
update;# Update display
}
Author
Robert Heller <heller@deepsoft.com>

Definition at line 62 of file C4TSMINI_Block.tcl.

Constructor & Destructor Documentation

◆ C4TSMINI_Block()

C4TSMINI_Block::C4TSMINI_Block ( name  ,
  ... 
)

Constructor: initialize the block object.

Create a lowlevel node object and install it as a component. Install the blocks signal (created elsewhere).

Parameters
nameName of the block object
...Options:
  • -nodeobj This is the Cmri node for this block. This is a CmriNode object, defined in the Control Support package. This option is read-only and must be set at creation time.
  • -port The input port on the Cmri node. This is an integer greater or equal to 0. This option is read-only and can only be set at creation time. The default is 0.
  • -bit This defines the input bit on the input port for this block. This is an integer from 0 to 7 inclusive and is read-only and can only be set at creation time. The default is 0.
  • -forwardsignalobj This block's forward signal. This option is read-only and can only be set at creation time. The default is the empty string.
  • -reversesignalobj This block's reverse signal. This option is read-only and can only be set at creation time. The default is the empty string.
  • -previousblock Previous block (next block in reverse) – used for 'propagating' signal aspects and must be a C4TSMINI_Block type object. The default is the empty string.
  • -nextblock Next block (previous block in reverse) – used for 'propagating' signal aspects and must be a C4TSMINI_Block type object. The default is the empty string.
  • -direction Current running direction, either the word forward or reverse. The default is forward.

Member Function Documentation

◆ _entering()

C4TSMINI_Block::_entering ( )
private

Method for entering a block.

◆ _exiting()

C4TSMINI_Block::_exiting ( )
private

Method for exiting a block.

◆ occupiedp()

C4TSMINI_Block::occupiedp ( )

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

◆ propagate()

C4TSMINI_Block::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 (not used).
...Options:
  • -direction The direction of the propagation.

◆ validate()

static C4TSMINI_Block::validate ( object  )
static

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

Member Data Documentation

◆ forwardsignal

C4TSMINI_Block::forwardsignal
private

Signal object (typically a three color, one head block signal.

Definition at line 85 of file C4TSMINI_Block.tcl.

◆ isoccupied

C4TSMINI_Block::isoccupied
private

Saved occupation state.

Definition at line 93 of file C4TSMINI_Block.tcl.

◆ node

C4TSMINI_Block::node
private

SMINI node object.

Definition at line 81 of file C4TSMINI_Block.tcl.

◆ reversesignal

C4TSMINI_Block::reversesignal
private

Signal object (typically a three color, one head block signal.

Definition at line 89 of file C4TSMINI_Block.tcl.