LogixNG Reference - Yard Ladder Example

A staging yard contains four tracks accessed using a three turnout ladder. When a track label is clicked, the turnouts will be changed to line the route. The track labels are internal sensors using a JMRI Sensor Group. The sensor group will have one active sensor.

yard ladder panel

The logic for the ladder is based on a CSV table that defines the path for each staging track.

yard ladder table

The LogixNG listens for changes to the sensor group members. When a sensor becomes active, the LogixNG uses the table information to set the route. To support multiple staging yards, use the LogixNG Clipboard to clone the logic and change the CSV table name in rows A1 and B1.

yard ladder logixng

LogixNG Features

Listen on beans - Table :: A1
The track sensor names from the Track column are used to build a list of sensors to trigger the logic. These are the sensors in the Sensor Group.
Find table row or column :: B1
The active sensor is used to find the appropriate row in the table. The cells in the row are using to build a local variable Map, rowMap, which has the column name as the key with the cell content as the value.
For each :: B2
For each is used to iterate through a list items, such as all the sensor. In this case the rowMap.keySet() formala is used. keySet() is a Java method which returns a list of keys from a Map. In this example, the turnout names.
If Then Else :: C2
In addition to the Always execute option, the Evaluate needed expressions option is used. If the stateName local variable is empty, the rest of the formula is skipped since the expression is already false.
Local variable Map
The Find in table action converts the row of turnout states into a local variable Map. Each row of the map contains a key/value pair. In this example, the key is the column turnout name and the value is the Closed/Thrown/empty state.
Formulas
Formulas are used in B2, C1 and the If statement in C2. The If formula is similar to the Logix Antecedent but uses the Java syntax.

Download

File name: yard-ladder-example.zip

Contents:

yard-ladder-example.xml configuration:


Return to the Reference TOC