JMRI: Route Documentation

What are Routes?

Routes are collections of Turnouts and/or Sensors whose states may be set all at once. Also when a Route is triggered, a sound may be played, or a script may be run. For example, a Route may be set up to clear all turnouts on a mainline with one computer or fascia panel button. Routes may also be set up to control the setting of ladders of turnouts in staging areas or yards. Another use is to set layout turnouts to default positions when beginning an operating session. JMRI Routes are similar to the routes implemented in the Digitrax Chief system, except the JMRI Routes can mix turnouts controlled by different hardware systems, and also can set sensors, play a sound, or run a script.

Optionally a Route may be controlled by up to three sensors and/or by a control turnout. When a Route is created, or when it is read from a configuration file, the Route is 'activated'; it is set up to monitor automatically any changes in state of its control sensors and/or control turnout. When the controlling sensors or turnout change in the user-specified way, the Route is 'set' ('triggered'); included turnouts and included sensors are set as specified, and if specified, a sound is played or a script is run.

The Route Table contains an 'Enabled' column. For a Route to be triggered by its control sensors or its control turnout, it must be "enabled", that is its check box in the 'Enabled' column must be checked. You can uncheck this box to temporarily disable a Route from being triggered, i.e. prevent it from setting its turnouts, sensors, etc. when a control sensor or control turnout changes.

How to setup for adding or editing Routes:

First make sure the Turnout Table contains all turnouts involved in the Routes to be defined, and that the Sensor Table contains all sensors needed. Then select Tools>Route Table, and click the Add... button at the bottom of the table to bring up the Add/Edit Route window.

To add a new Route:

  1. Enter a system name, such as 'IR100'--any short name can be used provided it is different from the system name of other Routes.

    By convention, system names usually start with "IR" for Internal Route.

  2. Enter a user name. Any string of characters that is different from the user name of other Routes will be accepted, but it's wise to use a string that describes the intended use of the Route.

    Note that before JMRI version 1.5.6, there was a bug that prevented you from having more than one blank user name. In more recent versions, you can have as many Routes with blank user names as you'd like; these have to be referenced via their system names, of course.

  3. Select turnouts to be included in the new Route in the list of all defined turnouts, by clicking on the checkbox in the Include column. For each included turnout, use the combo box in the Set State column to select whether that included turnout is to be 'Set Closed', 'Set Thrown' or 'Toggle'd when the Route is 'Set'. Don't worry if everything isn't perfect. It's easy to edit this information later.

    Note that the Add/Edit Route window allows you to display 'All' Turnouts and Sensors or 'Included' Turnouts and Sensors. This is only for your convenience in checking that all desired turnouts and/or sensors have been included; it does not affect entered information.

  4. Similarly, select sensors to be included in the new Route in the list of all defined sensors, by clicking on the checkbox in the Include column. For each included sensor, use the combo box in the Set State column to select whether that sensor is to be 'Set Active', 'Set Inactive' or 'Toggle'd when the Route is 'Set'.

  5. If you want the Route to play a sound when it triggers, enter the file name of a sound file in the text box following 'Play sound file'. Clicking Set will bring up a file selection dialog to help locate the file. Once the file is located, clicking on its name in the dialog will copy it, complete with path, into the text box.

  6. Similarly if you want a script to be run when the Route triggers, enter its file name into the text box on the right. The Set button can be used as above to assist in entering script file information.

  7. If you want the setting of the Route to be controlled by one or more input sensors, enter their names (system name or user name) and select what kind of logic they'll obey. Logic choices are described in detail below.

    When you save and restore your Routes using a configuration file, the sensor name you enter here is used to recreate the route. A system name will always be associated with the same input Sensor. A user name can be moved to another input by changing the entries in the Sensor table. For example, "East OS Occupancy" could be changed from LocoNet sensor input LS12 to LS24 by just associating that user name with a different system name; this makes layout rewiring easy. User names entered here must exist however; if you change the sensor's user name from "East OS Occupancy" to "East Occupancy", the route won't load properly until you edit it to use the new name.

  8. Also optional, if you want to enable setting of the Route when a particular turnout changes state, enter a turnout name (system name or user name) and select the logic that it will obey. Logic choices are explained in detail below.

    When you save and restore your Routes using a configuration file, the turnout name you enter here is used to recreate the route. A system name will always be associated with the same turnout. A user name can be moved to another turnout by changing the entries in the Turnout table. For example, "Set Track 5" could be changed from LocoNet sensor turnout 105 to turnout 5 by just associating that user name with a different system name; this makes layout rewiring easy. User names entered here must exist however; if you change the turnout's user name from "Set Track 5" to "Set Trk 5", the route won't load properly until you edit it to use the new name.

  9. The "Added delay" entry is normally left at "0". When a Route sets it turnouts, it waits 250 milliseconds between turnout control commands. If this is not enough time between commands for your type of turnout control, you can increase the time between commands by entering an added delay (in milliseconds).

  10. Click the Add Route button at the bottom of the window. If everything is fine, a message stating "New Route added ... " will be displayed in the notes box near the bottom of the window. If there is trouble with anything, an error message will be displayed in the notes box; you should then correct the error and click Add Route again.

To edit an existing Route:

  1. Edit of an existing Route may be started in either of two ways:
    • Click on a Route's Edit button in the Route Table.
    • Enter the system name of the Route to be edited in the Add/Edit Route window and click the Edit Route button at the bottom of the Add/Edit Route window. This must be the same as the system name shown in the Route Table.
    The Add Route and Edit Route buttons in the Add/Edit Route window will change to Update Route and Cancel.
  2. Make whatever changes or additions you need to the information in the dialog. Note that the system name of the edited Route may not be changed, but the user name may be changed. Other items are as described above.
  3. After making changes to the Route information, click Update Route to change the selected Route. If everything is fine, a message stating "Route updated ... " will be displayed in the notes box near the bottom of the window. If there is any trouble, an error message will be displayed in the notes box, and the update is stopped for you to correct the error and click Update Route again.
  4. Click Cancel to exit edit mode without changing the selected Route. If the Add/Edit Route window is dismissed (closed) while in edit mode, Cancel is automatically selected, and no changes are made to the selected Route.

To set (trigger) a Route:

Routes may be 'set' by clicking the Set button in the State column of the Route Table. A Route may also be set by fascia panel buttons if sensors for these buttons are defined as control sensors in the Route information. If a control turnout is defined in the Route information, throwing or closing that turnout from your physical throttle will also trigger the Route. Note that control turnouts may be real turnouts, phantom turnouts, or internal turnouts as described below. A Route may also be triggered from a Logix, as the action of one of its conditionals. If you need more powerful logic to control your Route than a provided by the Route itself, consider using a Logix.

Note that enabled/disabled and 'veto' logic discussed below for control sensors and for the control turnout apply only to a Route's automated control mechanism. Neither 'disabled' nor 'veto' logic will prevent a Route from being set (triggered) using the Set button or from a Logix.

It's also useful to note that when a Route has been triggered and is actively sending commands to turnouts the Route is marked as busy until this operation is complete. A Route cannot be triggered again while it is busy, i.e. until its current operation is complete.

To save Routes to disk:

Routes are saved in your layout configuration file, along with turnouts, sensors, signal heads, lights, etc. To store this information on disk, use Store Configuration... in the File menu at the top of the Route Table (or other tables from the Tools menu), or select Store Panel... in the Panel menu. Note that the enabled/disabled state of each Route is not saved in the configuration file. When Routes are loaded from a configuration file, they are all enabled.

Controlling Routes from Sensors

The operation of a Route can be controlled by up to three sensors. These can be connected to occupancy detectors or switches on the layout, or even just used to operate the Route from a control panel on the computer. These sensors can be real sensors or internal sensors.

By default, when any one of the defined sensors goes to the active state, the Route will be set. This could be used to e.g. set a Route when a block became occupied, or when a button was pushed.

More powerful logic can also do things like "define Routes to have the position of a turnout follow the position of a panel switch". For this, each of the three Sensors has a "mode" associated with it, which can be:

"On Active"
The default method, the Route is triggered when the sensor goes active, e.g. "Throw turnout 12 when sensor 12 goes active"
"On Inactive"
The Route is triggered when the sensor goes inactive. For example, using the Route above, plus a second Route "Close turnout 12 when sensor 12 goes inactive" will have turnout 12 follow a panel switch connected to sensor 12 as it is flipped back and forth.
"On Change"
The Route is triggered when the sensor state changes, either from active to inactive or from inactive to active.
"Veto Active"
If this sensor is active, other sensors set to "On Active", "On Inactive" "On Change" will be ignored, and a control turnout set to "On Closed", "On Thrown", or "On Change" will also be ignored. This has several uses, e.g. to prevent throwing a turnout under a train when the block shows occupied.
"Veto Inactive"
Like veto active, but the other polarity logic.

Note that there is an implied "and/or" here. All of the 'veto' sensors and the 'veto' turnout, if there is one, must be in their non-veto state _and_ at least one of the triggering sensors or a triggering turnout must see the appropriate change for the Route to be set.

Controlling Routes from a Turnout

The setting (triggering) of a Route can be controlled from a turnout. This turnout can be a real physical turnout, a 'phantom' turnout (a DCC turnout number with no corresponding physical turnout), or an 'internal' turnout.

Similar to the control sensors discussed above, the control turnout has a "mode" associated with it, which can be:

"On Closed"
The default method, the Route is triggered when the turnout changes to the closed state.
"On Thrown"
The Route is triggered when the turnout changes to the thrown state.
"On Change"
The Route is triggered when the turnout state changes, either from closed to thrown or from thrown to closed.
"Veto Closed"
If this turnout is closed, sensors set to "On Active", "On Inactive" "On Change" will be ignored.
"Veto Thrown"
If this turnout is thrown, sensors set to "On Active", "On Inactive" "On Change" will be ignored.

A single 'veto' turnout or 'veto' sensor can prevent the Route from being triggered. All of the 'veto' sensors and the 'veto' turnout, if there is one, must be in their non-veto state _and_ at least one of the triggering sensors or a triggering turnout must see the appropriate change for the Route to be set.