EULYNX implementation for Python
Install pylynx using pip:
pip install git+https://github.com/phSch08/pyLYNX
To send EULYNX messages from python an additional RaSTA bridge is required. You can use and adapt the docker-compose file provided in this repository to start the bridge and a simulated signal.
Check out example.py
to see how to use pyLYNX.
The following example shows, how to send messages with a running RaSTA bridge:
from pyLYNX.pyLYNX import pyLYNX
with pyLYNX("<BRIDGE_IP>:<BRIDGE_PORT>") as srv:
srv.send_message(message)
You can generate a message to send with the provided classes EulynxSignal
and EulynxPoint
:
Import
from pyLYNX.messages.signal import EulynxSignal, EULYNXSignalAspect, EulynxSignalLuminosity
PDI Version Check
pdi_version_check(sender_id: str, receiver_id: str)
sender_id
: id of the sending instance (Bridge)receiver_id
: id of the receiving signal
Initialization Request
initialization_request(sender_id: str, receiver_id: str)
sender_id
: id of the sending instance (Bridge)receiver_id
: id of the receiving signal
Indicate Signal Aspect
indicate_signal_aspect(sender_id : str, receiver_id : str, signal_aspect : bytes)
sender_id
: id of the sending instance (Bridge)receiver_id
: id of the receiving signalsignal_aspect
: signal aspect to display. Use the provided classEulynxSignalAspect
class EulynxSignalAspect:
stop_danger = bytes.fromhex('01')
proceed_clear = bytes.fromhex('04')
flashing_clear1 = bytes.fromhex('05')
flashing_clear2 = bytes.fromhex('06')
approach_caution = bytes.fromhex('07')
expect_stop = bytes.fromhex('08')
shunting_allowed = bytes.fromhex('02')
shunting_allowed2 = bytes.fromhex('09')
ignore_signal = bytes.fromhex('0A')
Set Luminosity
set_luminosity(sender_id : str, receiver_id : str, luminosity : bytes)
sender_id
: id of the sending instance (Bridge)receiver_id
: id of the receiving signalluminosity
: the luminosity of the signal. Use the provided classEulynxSignalLuminosity
class EulynxSignalLuminosity:
day = bytes.fromhex('01')
night = bytes.fromhex('02')
deleted = bytes.fromhex('FE')
Import
from pyLYNX.messages.point import EulynxPoint, PointPosition
PDI Version Check
pdi_version_check(sender_id: str, receiver_id: str)
sender_id
: id of the sending instance (Bridge)receiver_id
: id of the receiving point
Initialization Request
initialization_request(sender_id: str, receiver_id: str)
sender_id
: id of the sending instance (Bridge)receiver_id
: id of the receiving point
Move Point
move_point(sender_id : str, receiver_id : str, point_position : bytes)
sender_id
: id of the sending instance (Bridge)receiver_id
: id of the receiving pointluminosity
: the position, the point should move to. Use the provided classPointPosition
class PointPosition:
right = bytes.fromhex('01')
left = bytes.fromhex('02')