Using actions, actioncontrols and actionconditions it is possible to setup a extensive way of setting routes. When looking at this example, it is assumed that the reader has the basic knowledge of how to define objects in Rocrail and how to set Rocrail properties. Building a plan as described here can get complex and methodical working is highly recommended
In this example outputs are used as start and target buttons. For this some special svg symbols are used. Also, because these outputs are used for the logic only and do not really exsist on the layout, two command stations are used. One command station uses the virtual command station and has ID virt, the other is a real command station (in the downloadable example also the virtual command station) with ID real. All objects that are used for logic only must have virt as ID in their properties, all objects that are real, such as the switches have ID real in their properties.
Let's have a look at the plan first.
There are square start buttons and round destination buttons. A route is set by clicking a start button. The logic then highlights all possible destination buttons. Clicking a highlighted destination button will set the route and lock it until the start button is turned off again.
First, routes have to be defined between the starting points and the destinations. Give this some thought, when looking at the example, a route from west to track 3 is identical to a route from track 3 to west, so only one route is defined. You also see a null route in the table. The null route is an empty route used to reset any active route and to reset the route locking.
After defining the routes, actions have to be defined to activate the routes. For every route an equivalent action is defined, also for the null route.
Actions also have to be defined for the start and destination buttons. Each start button gets an action that will turn it off: (also note that the button is actually an output). Only outputs can be used in this case, since it is possible to set an output to three different states, off, on and active. Off and on are self-explaining, active is a state where the output does not change, but is represented on the screen in a different colour, the active state is used to highlight the possible destination buttons. This also means that 3 svg symbols are needed for the 3 states (on, off and active).
For the destination buttons two actions have to be defined, one to turn it active (high;light it) and on to turn if off:
Finally, two actions are added to turn route locking on and off. These actions control a accessory (switch). An accessory was choosen because a nice svg symbol has been published on the forum a long time ago, an output could have been used just as with the start and destination buttons.
To every start button actioncontrols have to be added. First actions to turn off all destination buttons are added when the start button goes on. Next, actions to turn off all other start buttons when this start button goes on are added, each with an action condition that the start button is only turned off when it is on. Then, actions that set all possible destination buttons from this start point to active are added, again when this start button goes on. Next step, actions that turn the destination buttons off when the start button goes off are added. Finally, route action null is added when the start button goes off.
The actual route selection is done by actions added to the destination buttons. All possible route actions leading to a particular start button are added to that start button. Which route to set depends on the state of the different start and destinations buttons, this is checked for every route action in the action conditions. For example, in the destination button in track 1 the route West-Tr1 is added. This route is activated when the start button West is on, destination button East is active and the accessory locked is at turnout (off).
It is also possible to use the destination buttons as a via button. Driving from West to East is possible over track 1 and over track 2. After pressing start west, destination track 1, 2, 3 and east light up. When destination east is pressed, destination track 3 turns off (not a possible route from west to east), pressing destination track 1 or track 2 selects the track over which will driven from west to east. This explains why the action condition that destination east must be active is part of the action control for route west to track 1. When east is not active the logic must check for routes from west to east.
The locking of the routes is achieved by adding the action Lock-routes to every route, except route null. Action Lock-routes set the accessory locked to straight (on). This prevents "stealing" a route. Once a route has been set, pressing another valid destination button will not change routes. Unlocking can only be done by turning off the start button (or clicking to locked symbol, but that counts as deliberately overriding the security mechanism). This activates route null, route null contains the unlocking action Unlock-routes that sets accessory locked to turnout (off).
The zip file below contains the plan file with all the actions, controls etc, the special svg symbols, its own ini file and a batch file to start Rocrail and Rocview with this plan and this ini file. Put the batch file aanzetten route_action.bat, the plan file demo_route_action.xml, the occupancy file demo_r_a_occ.xml and the ini file demo_r_a.ini in your Rocrail directory and all the svg symbols in the theme directory that you use. Use the batch file to start everything. The plan has been designed with Rocrail Air 1.3, but it should also work with Rocrail Act 1.2