Elekdra ScriptingThe functionallity of Elekdra and some clients can be extended by some user implemented scripts. This goes beyond what is already possible with the XML configuration. Index
Elekdra signal commandingWithout scripts, there are two ways to send commands to signals:
With a script the user has a lot more flexibility. The following new possibilities are available now: More than one commandThe script can send an arbitrary sequence of LocoNet commands. For example a two armed signal can get two commands, one for each arm. Please see this JavaScript implementation as an example. Address arithmeticsSome DCC light signal decoders need only a single command but distinguish aspects by different addresses. The configuraton of the signal can define a base address, the script sends a command to this base address plus an offset that selects the actual aspect. Aspect merging
Sometimes the dependency between the aspect of the mandatory signal and
a distant signal on the same mast are beyond simply commanding the distant
signal to How to embed the scripts into the configuration
You define the scripts in one or more configuration blocks
Elekdra Script ClientThis program is currently being implemented. The design goals are:
What can be accessed from the script?The script has access to several functionallities of the Java program that it was started by. Logging
Elekdra and all known clients use a software library called
Log4J
in order to write logging messages into a text file.
A logger object that gives the script access to this system
is available by the name
You can call logging
methods. Loconet
Methods that send to
Digitrax
LocoNet can be accessed via the symbol Technical backgroundAll examples are using JavaScript as language, because the Oracle Java Runtime Environment already comes with an integration of this script language. I recommend that you choose the same language unless you really know what you are doing. But in theory every language that has a JSR-226 compliant Java integration can be used, if it is found in the 'classpath'.
|