Skip to content

Station Controller API

jeno96 edited this page Jan 16, 2019 · 31 revisions

This is a MQTT interface, to use MoDeS3 resources.

Messages

Status Messages

Segment State

Status info about a segment if it is enabled or disabled.
Segment State changed messages are sent automatically by StationControllerAPI.
"state" has the current state.

Topic: segment/state
{"segmentID":1,"state":0} //disabled
{"segmentID":1,"state":1} //enabled

In addition, to extend basic functionality, you can request manually to get Segment State current state.
Just send:

Topic: segment/state
{"segmentID":1,"getstate":"one"}  //for one segment
{"getstate":"every"}               //for every segments

Turnout State

Status info about a turnout’s reference state, if it is straight or divergent.
Turnout State changed messages are sent automatically by StationControllerAPI.
"state" has the current state.

Topic: turnout/state
{"turnoutID":1,"state":"straight"}
{"turnoutID":1,"state":"divergent"} 

In addition, to extend basic functionality, you can request manually to get Turnout State current state.
Just send:

Topic: turnout/state
{"turnoutID":1,"getstate":"one"}  //for one state
{"getstate":"every"}               //for every states

Segment Occupancy

Status info about which segment has train on it.
Segment Occupancy messages are sent automatically by StationControllerAPI.
"state" has the current state.

Topic: segment/occupancy
{"segmentID":1,"occupancy":"occupied"}
{"segmentID":1,"occupancy":"free"}

In addition, to extend basic functionality, you can request manually to get Occupancy.
Just send:

Topic: segment/occupancy
{"segmentID":1,"getoccupancy":"one"}  //for one segment
{"getoccupancy":"every"}               //for every segment

Command Messages

Segment State Command

Change Segment State to enabled or disabled.

Topic: command/segment
{"segmentID":1,"state":0} //disabled
{"segmentID":1,"state":1} //enabled

Change every Segment State to enabled or disabled.

Topic: command/segment
{"stateAll":0} //disabled
{"stateAll":1} //enabled

Segment Occupancy Command

Set Segment Occupancy.

Topic: command/occupancy
{"segmentID":1,"occupancy":"occupied"}
{"segmentID":1,"occupancy":"free"}

Turnout State Command

Change Turnout State to straight or divergent.

Topic: command/turnout
{"turnoutID":1,"state":"straight"}
{"turnoutID":1,"state":"divergent"} 

Train Speed Command

Set Train speed and direction

Topic: command/train
{"trainID":"taurus","speed":0, "direction":"forward"} 
{"trainID":"piros","speed":126, "direction":"backward"}  //max 126
{"trainID":"sncf","speed":64, "direction":"backward"} 

Clone this wiki locally