This software receives train running and route set messages from the open data provided by Traffic Management Finland (CC BY 4.0). There is a bit register which the received messages modify as defined in the message rules. The contents of the bit register is send to shift-and-store circuits such as 4094. These ICs can control LEDs, relays etc.
There can be any reasonable number of the shift-and-store registers.
RECV will blink always when a message is received. ACK will blink when
a message which causes an action to be taken is received.
ERR is set before the first message is received or the previous message
has been received over a minute ago. In this case, the socket will be
reconnected.
Configuration is a JSON file.
{
"bits": 8,
"initialPattern": "00000000",
"rules": [{
"station": "HKI",
"action": "PULSE",
"type": "OCCUPY",
"bit": 0
}
]
}bits(mandatory) number of the controlled bitsinitialPatternthe state of the bits when the program is started, must be0or1- if missing or too short, zero will be usedrulessee the definition in below
There can be any number of rules. Each rule must contain at least station,
bit, and action. See all the possible rules in the list below.
station(mandatory) station codebit(mandatory) bit numberaction(mandatory) action to do, see the list belowtypeOCCUPY, RELEASE, ROUTESET, ROUTESET_C or ROUTESET_StrackSectiontrack section codefromprevious station codefromSectionprevious track section codetonext station codetoSectionnext track section code
In case of route set messages, previous and next station or section refers to the previous or next route section element in the route set message.
Types OCCUPY and RELEASE react to train running messages.
Types ROUTESET, ROUTESET_C and ROUTESET_S react to
route set messages. The last two types refer to cancelling
a route or setting a shunting route.
AUTOOCCUPY message sets the bit, RELEASE clearsAUTOINVsame asAUTObut inverted outputSETCLEARPULSEgives a positive pulse, length ~100 msTOGGLEchanges the current state to the opposite
Make sure that you have a recent version of Node installed:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs
Clone the repository:
git clone https://github.com/ttsirkia/adilok-raspberry.git
Move to the correct directory and install the required libraries:
npm install
Modify the configuration file and start the program:
node adilok-raspberry.js
The configuration file is by default read from the current directory. However, you can give any other config file as an optional parameter.
Use the command line parameter --debug to start the program in debug mode.
It allows to set and clear bits by giving the corresponding bit number.
You can also use --livedebug to start the normal mode together with the
debug mode.
Do not use this software for any safety-critical purposes!
This software is licensed under the MIT license.
