Dispatcher System

The Dispatcher System is a set of Python tools to extend the capabilities of the Dispatcher.


This is an automated system designed to enable you to run trains using the Dispatcher system between locations (normally sidings or stations, but really any set of blocks) designated by yourself.

Provided you have set up a system as described in System Requirements, by pressing a few buttons on theSystem Generation Panel, a complete system will be set up for you complete with Transits, Train Info files, and buttons for you to press which will route trains across your layout.

A network will be set up behind the scenes which will find the best route from the train's location to the required location, and set in place a set of transits which will guide the train to the required location.

The train will either stop at all stations on the route, or travel without stopping at intermediate stops, depending on whether express or stopping mode is selected

Provision is made for multiple train operation, the trains stopping for each other. This is a feature of Dispatcher, but the system allows easy selecting of each train to control each one.

Steps in setting up the system

There are several stages to set up the system for automatic train running:

Fulfil the prerequisites, which include having speed profiled your locos that you wish to run with the system

System Requirements

To use the Dispatcher System there are several prerequisites

Running Stage1 — Editing the panel

Run DispatcherSystem.py in the main jython directory. You will get something like this:

You are prompted to run Stage1 which adds all the icons required to run the system on a new panel.

if the old panel name was WR.xml, the new panel will be WR_icons.xml

Some checks are done first

The following checks are made

If no trains are present in the roster with speed profiles, this will be picked up, and can be corrected at run time.

When the icons file is produced, a message similar to the following will be produced:

A new panel has been created. You should close down and load the new panel, instead of the original.


The panel will have been created by loading the original xml file (in this case WR.ml), editing the details and saving to a new file (WR_icons.xml).

If there were any unsaved edits in the original file these will not be present in the new file, but you will not lose them provided you save them either to the original file or another file once Stage1 has completed. We advise saving all edits before running Stage1, so they are picked up.

Running Stage2 Producing the signal logic, transits and train info files

PanelPro should be restarted and the icons file produced in stage 1 should be loaded.

A screen similar to the following will be produced:

Once the Stage2 button is pressed one gets a confirmatory messages:

The signal logic is produced, then the following confirmatory message appears:

Transits required to move the train from stop to stop will be produced, and corresponding train-info files which contain the information required for running the train are produced. Some of the information is overwritten when the train-info files are used such as the train name, so train info files do not have to be produced for each train.

Train-info files are produced for each route allowed, and all routes are allowed which are physically possible to travel. Train-info files are produced for forward and reverse operation, so there can be quite a number produced.

Once the transits and train-info files are produced we get a message:

You should then restart JMRI and load the run panel instead of the icons panel, in this example WR_run.xml

Running Stage3 Final Checks

Restart JMRI and load the newly produced run panel, in our example WR_run.xml

Run dispatcher System again to get

Click Stage3 and one gets two screens opening,the Dispatcher options screen and another saying the options that need to be set for the Dispatcher system to work

Set the required option and we get a message reminding you to save the changed options

Select the dispatcher window that has opened automatically and click => Save Options

Running the Program

To run the system it is advised to have the thread monitor running (Panels => Thread Monitor)

You will notice several buttons in the top RH corner.


The first two start and end the threads required for the program to run. The threads need to be in operation for the other buttons to work. The threads can be viewed by clicking Panels | Thread Monitor on the PanelPro Window.


To run the system the following needs to be set up

  1. Place a train on the layout. If you wish to simulate the train to get an idea of how the system will operate click the bottom left button of a station which will make the station occupied.
  2. Register the train with the dispatcher system telling the system what way it s facing so the system knows what trainsit to use to move the train (forwards or backwards). Press the 'Setup Train in Section' button to do this.
  3.  Set up a dispatch. This can be done in several ways.
    1. Click the Run Dispatch Button and click a station button and specify which registered train will move towards that station
    2. Setup a Route and run the route. A Route consists of a path joining several stations. The stations joined can be anywhere on the layout no matter how far apart they are, and the system will find valid paths between the stations.The station buttons can be used to either setup a dispatch or setup a route depending upon whether "Setup Route or "Run Dispatch" is selected. The route is run by pressing the "Run Route" button.
    3. Setup routes, Setup Scheduled Trains and then start the scheduler.
  4. If a physical train is on the layout at the start of the dispatch the train should move. If you have just made the block occupied with no physical train you can press the 'Simulate the Dispatched Train' button to get an idea of how the train will run. The train will simulate much quicker than a real train and takes no account of the train length.
  5. Announcements can be activated by pressing the 'Enable Announcements' button. This is off by default as they can get a but irritating.

Press the run button. The Express Train and the Run Dispatch options will be highlighted and the run Dispatch option will cause the following prompt to be displayed:


Register a Train

The first step is to register a train in a siding or at a stop. If you are simulating the system to see whether it will work before running trains you may press the bottom left hand small button which will make the section occupied. Drive a train to the required stop, and press Setup Train in Siding.

We need to tell the system which way the train is pointing.

suppose we have the following layout


Choosing the Train

We click SetupTrain in siding

If the train is siding 1b as indicated one gets the following message


Where if we click the dropdown we get all the trains in the system with a speed profile. We choose the required train and click OK

Register the Direction the train is facing

The following message then pops up


Select the correct direction and click OK.

The train will appear in the memory location for the block


Set up a dispatch

To set up a dispatch a train (or several trains bust be registered with the system, and located in a stop).

Clicking a red button will allow a dispatch to be set up to that location.

Suppose one has the following layout with a train in siding1. Click the Passing Loop button as indicated to set up a dispatch to Passing Loop.


There is an express icon. If set the train type will default to express (moves without stopping at intermediate stations), If unset, will default to stopping as shown.



Select the required train from the drop down, and a dispatch will be set up to the next stop (Siding1A).


The train will start moving, and the speed indicated in the Auto trains window.


The train will move to Siding1B, stop and the dispatch will terminate, another dispatch will start up to the next stop which will be to passing loop.

Setup a Route

Click 'Setup Route'. The following message will be displayed:


You now press the red section (station) buttons to set the route. The first button will be the start of the route.


The subsequent buttons will be the intermediate stations. At each station you will be asjked:


You will be told what station you have selected and be asked whether to:

If you press complete route, a route will be automatically set up with the name being the amalgam of the start station and the end section. If a route already exists with that name, an index will be appended. The name of the route can be changed bu clicking the 'View / Edit Route' button or the View Route button on the pop-up.


Run Route

To run a route a route must already have been set up. Click Run Route


You will be prompted with all the routes you have set up


Choose the required route and click OK.

If you have no train in a station registered with the system, or all trains registered are being dispatched you will get the following message:


Put a train in a station, register it and try again. In the below example we have one train available 'Class 20'


You will then get the following message:


  1. Stop at End of Route: The train will travel from its current position to the start of the route, travel along the route, then stop
  2. return to start position: The train will travel from its current position to the start of the route, travel along the route, then return to the start position
  3. return to start position and repeat: As (2) but repeat forever

Schedule Route

To store the routes we have used the mechanism provided by Operations which normally provides instructions to move trains manually. To schedule the trains we use the scheduling mechanism of Operations.

To check that we have some routes setup we press 'View/Edit Routes'.

To schedule these routes we press 'View/Edit Scheduled Trains'. Here we have set up 3 trains to be scheduled.


To setup a new train press 'Add...'. To see the route press Edit for the particular train. For instructions on how to set up the trains you can l ook at the help for Operations which can be seen by pressing Help | Window Help.

The mechanism is quite straightforward and you probably can setup the train without any further help.

On Add train you will get the following pop-up


Note that you have to fill in

  1. Train Name (this is arbitrary. The actual train that will run is the train sitting in the start position of the route
  2. Description (this can be left blank, but if the following key words are entered (any order) they will have the following effect
    1. skip : the train will be ignored when scheduling takes place
    2. repeat : the train will go along the route, then repeat forever
    3. stopping : the train will normally go direct from station to station on the route. Stopping will cause the train to stop at any station it passes on the route

All other entries can be ignored as the Dispatcher System does not use them.

Run scheduled trains

If the trains have been scheduled in the Operations scheduler as described above pressing the 'Start Scheduler' button will start the scheduler at a midnight on a fast clock 1 times the normal speed.


If you wish to change the start time (trains may start later) or wish to change other parameters press Set scheduler start time.


I recommend changing the fast clock to 10 times normal speed, and the fast clock time to whatever you require, but at least a few minutes before the first train to be scheduled.

You may wish to view the fast clock. I like the analog clock so there is a button 'Show Analog Clock', but if you wish to see another clock change the code or use the menu on PanelPro | Tools | Clocks.

To start the scheduler press 'Start Scheduler' and the clock will start and the trains set up to be dispatched will start when the fast clock gets to the correct time.

Features of the Dispatcher System

  1. The Dispatcher system is designed to run trains from station to station. The system has been set up with a network graph which allows the system to get the shortest path between two stations, and this is used to get the route between the two stations. At present if a train is in a station en route, the system will not re-route to avoid the train, and the train may get stuck. Care must be taken when running trains.