You are here: Wiki > start > usertrack > interface_gateway

Table of Contents

Interface Gateway
Introduction
Subscribing
Messages Sent From The Server
Train Describer (TD)
Signalling Data
Track Circuit Data
Point Data
Signal Data
Route Calls
Messages Sent To The Server
Train Describer (TD)
Route Requests & Signal cancellations
Points & Flags

Interface Gateway

Introduction

The SimSig Interface gateway allows SimSig to generate messages to the outside world in a specific format similar to that of the Network Rail Open data feeds.

This page aims to document the uses of Interface Gateways, and the format of messages that SimSig produces.

Subscribing

In order to receive messages from the interface gateway you will need to have some sort of STOMP client.

You will need to subscribe to the following topic.

topic:TD_ALL_SIG_AREA

An example STOMP client written in Python 2.7 can be found On Headshot119s Github . Please note this is a very basic client designed only to print messages received onto the standard output.

Messages Sent From The Server

Each of the messages that can be sent by the simulation server, to connected clients on the gateway are documented in this section.

Train Describer (TD)

Train Describer messages give information about the state of the Train Describers in the simulation.

There are three messages message types.

Message Format

Messages are sent in JSON format.

{"CA_MSG":{"area_id":"north_wales_coast","from":"GN17","to":"BR60","descr":"2R43","msg_type":"CA","time":"566"}}

{"CB_MSG":{"area_id":"north_wales_coast","from":"BR60","descr":"2R43","msg_type":"CB","time":"668"}}

{"CC_MSG":{"area_id":"north_wales_coast","to":"GN17","descr":"2R43","msg_type":"CC","time":"456"}}

Message Types

Type Name Notes
CA Berth Step Description steps from the "from" berth, to the "to" berth.
CB Berth Cancel Description steps from the "from" berth to nowhere.
CC Berth Interpose Description steps into the "to" berth from nowhere.

Message Fields

Field CA CB CC Notes
area_id T T T Simulation the message was sent from. Note the format is the .sim file name
from T T ID of the TD berth the description was stepped from. GN17 - Gaerwen 17
to T T ID of the TD berth the description was stepped to. BR60 - Bangor 60
descr T T T The string that stepped. 2R43
msg_type T T T The type of message.
time T T T Time the message was sent. Measured in seconds from midnight. "time":"566" = 00:09:26

In certain simulations, it is possible that the TDs shown on the screen are not what is shown in the data feeds. This can be noted specifically around approach berths, where one berth may cover what the simulation sees as several within the data.

Signalling Data

Signalling data messages give information about the state of points, track circuits, signals, routes and some other data. Each one is described in detail.

Message Types

Type Name Notes
SG Signalling Refresh Updates an object's state

All signal data messages are of type SG.

Track Circuit Data

Message Format

{"SG_MSG":{"area_id":"north_wales_coast","obj_id":"TLJ176","obj_type":"track","clear":"False","msg_type":"SG","time":"2975"}}

{"SG_MSG":{"area_id":"north_wales_coast","obj_id":"TLJ176","obj_type":"track","clear":"True","msg_type":"SG","time":"3010"}}

Message Fields

Field Name Notes
area_id Simulation the message was sent from. Note the format is the .sim file name
object_id Name of the track circuit prefixed with "T"
object_type The type of object
clear True - Track Clear, False - Track Occupied
msg_type The type of message.
time Time the message was sent. Measured in seconds from midnight. "time":"2975" = 00:49:35

Point Data

Message Format

{"SG_MSG":{"area_id":"north_wales_coast","obj_id":"PLJ451","obj_type":"point","dn":"False","dr":"True","cn":"False","cr":"True","kn":"False","kr":"False","msg_type":"SG","time":"5967"}}

Message Fields

Note messages are received for each point end. A crossover will therefore generate two messages.

Field Name Notes
area_id Simulation the message was sent from. Note the format is the .sim file name
object_id Name of the point prefixed with "P"
object_type The type of object
dn True - Detected normal, False - Not Detected normal
dr True - Detected reverse, False - Not Detected reverse
cn True - Called normal, False - Not Called normal
cr True - Called reverse, False - Not Called reverse
kn True - Keyed normal, False - Not Keyed normal
kr True - Keyed reverse, False - Not Keyed reverse
msg_type The type of message.
time Time the message was sent. Measured in seconds from midnight. "time":"5704" = 01:39:28

Signal Data

Message Format

{"SG_MSG":{"area_id":"north_wales_coast","obj_id":"SAE59","obj_type":"signal","aspect":"6","bpull":"False","rset":"True","appr_lock":"False","lp":"True","auto":"False","msg_type":"SG","time":"5704"}}

Message Fields

Field Name Notes
area_id Simulation the message was sent from. Note the format is the .sim file name
object_id Name of the signal - predixed with "S"
object_type The type of object
aspect Aspect the signal is displaying. See Aspect chart for details
bpull Was the signal cancelled by the user. True / False
rset Is a route set from the signal True / False (always True for auto signals and repeaters
appr_lock Is the signal approach locked. True / False
lp Is the signal lamp proved. True / False
auto Is the auto button set (for controlled signals), or emergency replacement button not pressed (ie automatic signal allowed to show proceed). True / False
trts Is the TRTS associated with this signal flashing? True / False
msg_type The type of message.
time Time the message was sent. Measured in seconds from midnight. "time":"5704" = 01:39:28
Aspect Chart
Number Aspect
0 Red
1 Shunt
2 Yellow
3 Flashing Yellow
4 Double Yellow
5 Flashing Double Yellow
6 Green

Note that a signal which is out will report the aspect that it should be showing, but lamp proving will go false.

=

Flag Data

Flags are used in SimSig for various things. In this example this flag is used to control the state of the Abergele - Rhyl Absolute Block Train On Line lights (0 Off, 1 On)

Message Format

{"SG_MSG":{"area_id":"north_wales_coast","obj_id":"LAERHTL","obj_type":"flag","state":"1","msg_type":"SG","time":"5704"}}

Message Fields

Field Name Notes
area_id Simulation the message was sent from. Note the format is the .sim file name
object_id Name of the flag - prefixed with "L"
object_type The type of object
state The value of the flag. Can be 0 - 63. Generally 0 is false, 1 is true.
msg_type The type of message.
time Time the message was sent. Measured in seconds from midnight. "time":"5704" = 01:39:28

Route Calls

Route calls are detailed in several lines of events, most of which have been detailed above.

The Route Call

Message Format

{"SG_MSG":{"area_id":"north_wales_coast","obj_id":"RAE59AM","obj_type":"route","is_set":"True","msg_type":"SG","time":"32"}}

Message Fields

Field Name Notes
area_id Simulation the message was sent from. Note the format is the .sim file name
obj_id Is the name of the route, prefixed R. Generally speaking the left hand most route will be A (or 1) with Z (or 26) being the right most route. The last latter indicates the class of route. M - Main, S - Shunt, C - Call on, V - Virtual
obj_type Type of Object (Route)
is_set Has the route been set? True / False
msg_type The type of message.
time Time the message was sent. Measured in seconds from midnight. "time":"182" = 00:03:01

Indicating Reserved Tracks

When a route is called, the route is indicated in SimSig by white subroute lights (one track will contain one locked subroute; one subroute exists in exactly one track). These messages are outlined as:

Message Format

{"SG_MSG":{"area_id":"north_wales_coast","obj_id":"ULJ176-BA","obj_type":"ulc","locked":"False","overlap":"","msg_type":"SG","time":"32"}}

Message Fields

Field Name Notes
area_id Simulation the message was sent from. Note the format is the .sim file name
obj_id The sub-route of the track which has been called. The last two letters indicate which ends of the track circuits have been lit up, and the order in which they where lit.
obj_type Type of object (ulc)
locked Whether the subroute is locked. True / False
overlap Whether the subroute is locked as part of an overlap (True) or as part of the main route (False) True / False
msg_type The type of message.
time Time the message was sent. Measured in seconds from midnight. "time":"32" = 00:32:00

Messages Sent To The Server

Each of the messages that can be sent by the client to the server, are documented in this section.

Train Describer (TD)

Train Describer messages allow you interpose, cancel, or step a description.

Message Format

Messages are sent in JSON format.

{"ca_msg":{"from":"HJ9","to":"HJ13","descr":"1234"}}

{"cb_msg":{"from":"HJ10"}}

{"cc_msg":{"to":"HJ6","descr":"TEST"}}

Message Types

Type Name Notes
CA Berth Step Description steps from the "from" berth, to the "to" berth.
CB Berth Cancel Description steps from the "from" berth to nowhere.
CC Berth Interpose Description steps into the "to" berth from nowhere.

Message Fields

Field CA CB CC Notes
from T T ID of the TD berth the description is to step from.
to T T ID of the TD berth the description is to step to.
descr T T T The string that is to be stepped.

Route Requests & Signal cancellations

Route request messages allow you to set routes, either by knowing the route ID, or by inputting a pair of signals.

Message Format

Messages are sent in JSON format.

{"routerequest":{"route":"RHJ1AM"}}

{"routerequest":{"fromSignal":"SHJ3","toSignal":"SHJ5"}}

{"bpull":{"signal":"SHJ10"}}

Message Types

Type Name Notes
routerequest Route Request Request the simulation set a route
bpull Cancel Signal Request the simulation cancel a route

Message Fields

Field Name Notes
route The route for the simulation to attempt to set.
fromSignal The signal which will form the entry signal of a route request.
toSignal The signal which will form the exit signal of a route request.
signal The signal which will be cancelled as part of the request.

Points & Flags

Point and flag messages allow you to change the position of points, and to set the state of flags within the simulation.

Message Format

Messages are sent in JSON format.

{"sigobjstate":{"object":"PHJ33A","keyN":"1"}}

{"sigobjstate":{"object":"PHJ33B","keyR":"1"}}

{"sigobjstate":{"object":"LWHJINTCON","state":"true"}}

Message Types

Type Name Notes
sigobjstate Route Request Request the simulation set a route
bpull Cancel Signal Request the simulation cancel a route

Message Fields

Field Name Notes
object The object on which to perform the action.
keyN Change the Normal key state (1 to key to normal, 0 to remove the key)
keyR Change the Reverse key state (1 to key to reverse, 0 to remove the key)
state Change the state of the flag (true or false)

Last edited by headshot119 on 22/01/2020 at 20:30