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 bitsinitialPattern
the state of the bits when the program is started, must be0
or1
- if missing or too short, zero will be usedrules
see 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 belowtype
OCCUPY, RELEASE, ROUTESET, ROUTESET_C or ROUTESET_StrackSection
track section codefrom
previous station codefromSection
previous track section codeto
next station codetoSection
next 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.
AUTO
OCCUPY message sets the bit, RELEASE clearsAUTOINV
same asAUTO
but inverted outputSET
CLEAR
PULSE
gives a positive pulse, length ~100 msTOGGLE
changes 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.