In this example, a timer is used to hold a train for a specific time using a light signal, for example, in a station.
The starting point for this example is a signal that is linked to two beacons: one for deceleration and a second for precise stopping. How this works is described in Chapter 4.3 "Config - Linking Actions" for both IR beacons and NFC beacons.
To implement the time-controlled stop, add two timers and a trigger to the signal.
The trigger should activate when any locomotive reaches the beacon directly in front of the signal and stops there. To do this, open the signal's config, click on the signal under "Actions," and then click the plus button to the right of "Products and Actions":
Then select "Trigger" and click "OK." In the example, the new trigger is named "B-Einfahrt-re-trg."
In the same way, create the two timers "B-Einfahrt-freigeben" and "B-Einfahrt-sperren." After creating them, you should give the new action a suitable name by clicking the "..." button next to "Name" in "Action Details." Only then should you edit the individual scripts.
For the trigger, click the "Source" button to select the beacon as the source of the event. The actual trigger event is the locomotive. Since the time control should work for every locomotive, nothing is selected under "Trigger." The asterisk in "on (MAC)" appears automatically after selecting the source.
The letter passed to the script is the command that the locomotive received from the beacon. You use this to start the timer for changing the signal to green only when the locomotive has stopped ('h'). The second "If" reacts to all other commands and does nothing except reset the trigger so that it reacts again on the next stop.
To start the timer in the script for stop ('h'), click on the line "If 'BA2' from == 'h'" and then on "Add." In the popup, select the command "call." Then, in the list under "Execute action," select the previously created timer "B-Einfahrt-freigeben."
Note: A trigger only activates if the value passed differs from its own. To do this, the trigger stores the last received value. You can see the value a trigger has in the control panel by selecting the appropriate action group (usually "Trigger"):
The timer for opening the signal ("B-Einfahrt-freigeben") contains only a single command. Namely, a call ("call") of the function Green (Hp1_Light) of the light signal:
To make the light signal turn red again after the locomotive has passed, add the start of the timer for closing the signal ("B-Einfahrt-sperren") to the function "Hp1_Light ('f')" :
The timer for closing the signal ("B-Einfahrt-sperren") contains only a single command. Namely, a call ("call") of the function Red (Hp0_Light) of the light signal: