DE EN

Scripts

TransportControl uses a script system to adapt the controlled transport system logistically and visually to the current requirements. There are three different types of scripts. Each type allows the customization of its own area.

At run-time scripts can be edited with the FULL access level via the browser UI. Changes are stored on the server and are globally and immediately effective.

When creating or editing scripts the syntax of JavaScript has to be observed. Syntax errors are displayed with the corresponding line number in the script table of the browser UI, but only when the script has been called by the program at least once. 

The examples were tested with the current TransportControl version. Compatibility with older versions cannot be guaranteed.


Type SERVER

Scripts of type SERVER are called and executed by the core loop of the central TransportControl Server. Here, the logistics of a controlled system can be adapted. Some input signals don't have a predefined meaning in TransportControl and can be linked with actions only by using SERVER scripts. For example, it is possible to create jobs or to block segments if vehicles are located in predefined positions or if stations transmit signals.

The modular code block of a script corresponds to a function activated by TransportControl according to the interval selected. Three objects are transferred to this function: 

  1. targetList: Array - includes all targets (vehicles and stations) logged-in on the system
  2. self: Script class - the script currently being executed
  3. h: Helper class - provides various supporting functions. 

By using these four objects more objects will become available. Public features and functions of each object can be directly accessed within the scripts. In the following list of functions Java data types are used to illustrate the underlying classes.

Script-Examples - Type Server


Type UPDATE

Scripts of type UPDATE are executed repeatedly within the browser UI, taking into account the set interval. They are usually used for the customization of the map. Theoretically, however, each parameter and function from the source code of the UI can be manipulated or called. A full description of all possibilities is beyond the scope, so only the most common applications are presented in this documentation.

Script-Examples - Type Update


Type CUSTOM

Scripts of the Typ CUSTOM will be executed, if a mobil optimised custom UI will be requested via the address bar of the web browser. 

While the header and footer are predefined, the content can be designed via a custom script. If no active script is found during the call, a corresponding error message appears. The Custom UI is called using the following URL: 

http://[SERVERIP]:[SERVERPORT]/transportcontrol/?script=[UINAME]

Script-Examples - Type Custom