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

Block occupation detection using Azatrax MRD2Us. More...

Public Member Functions

 MRD2_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 MRD2_Block type. More...
 

Private Member Functions

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

Private Attributes

 sensor
 MRD2 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...
 

Detailed Description

Block occupation detection using Azatrax MRD2Us.

Above is a simple diagram for using Azatrax MRD2Us for block occupation detection. The Azatrax MRD2U has two IR sensors and one can be use to test for entering a block and one for leaving a block.

Typical usage:

Four blocks in a loop:

MRD2_Block block1 -sensorsn 0200001234 -forwardsignalobj signal1
MRD2_Block block2 -sensorsn 0200001235 -forwardsignalobj signal2 -previousblock block1
MRD2_Block block3 -sensorsn 0200001236 -forwardsignalobj signal3 -previousblock block2
MRD2_Block block4 -sensorsn 0200001237 -forwardsignalobj signal4 -previousblock block3
block1 configure -previousblock block4

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 51 of file MRD2_Block.tcl.

Constructor & Destructor Documentation

◆ MRD2_Block()

MRD2_Block::MRD2_Block ( name  ,
  ... 
)

Constructor: initialize the block object.

Create a low level sensor object and install it as a component. Install the blocks signal (created elsewhere).

Parameters
nameName of the block object
...Options:
  • -sensorsn Serial number of the MRD2U for this block. This option is read-only and must be set at creation time.
  • -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 MRD2_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 MRD2_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()

MRD2_Block::_entering ( )
private

Method for entering a block.

◆ _exiting()

MRD2_Block::_exiting ( )
private

Method for exiting a block.

◆ occupiedp()

MRD2_Block::occupiedp ( )

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

◆ propagate()

MRD2_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 MRD2_Block::validate ( object  )
static

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

Member Data Documentation

◆ forwardsignal

MRD2_Block::forwardsignal
private

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

Definition at line 72 of file MRD2_Block.tcl.

◆ reversesignal

MRD2_Block::reversesignal
private

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

Definition at line 76 of file MRD2_Block.tcl.

◆ sensor

MRD2_Block::sensor
private

MRD2 object.

Definition at line 68 of file MRD2_Block.tcl.

MRD2_Block
Block occupation detection using Azatrax MRD2Us.
Definition: MRD2_Block.tcl:51