Difference between revisions of "TD"

From Open Rail Data Wiki
Jump to navigation Jump to search
(Added sample messages)
m (Add elixir example)
(28 intermediate revisions by 7 users not shown)
Line 1: Line 1:
== Overview ==
+
The Train Describer feed provides low-level detail about the position of trains and their train reporting number through a network of [[TD_Berths|berths]].  Usually, but not always, a berth is associated with a signal - but there are locations (such as terminal platforms at stations) where there may be more than one berth.  From each berth, there are zero or more other berths which a train description may step in to.  A step between berths represents movement of the train from one berth to another.  Some of these steps may be one-way, some may be two-way.
  
The Train Describer feed contains message about Train movements at the Signal Berth Level. Messages come in 4 types, all in JSON format:
+
To access the TD data feed, you must select and subscribe to the appropriate geographical topic(s) on the ''My Feeds'' page on the Data Feeds website (see the [[About_the_feeds|about the feeds]] page.)
  
* CA - Berth Step
+
See also the [[List_of_Train_Describers|list of train describers]] page, where you will find information on specific TD's including user contributions & documentation provided by Network Rail such as S-Class data, maps and stepping data.
* CB - Berth Cancel
 
* CC - Berth Interpost
 
* CT - Heartbeat
 
  
Messages only exist for trains of [[headcode|headcodes]] classes, 1, 2 and 9.
+
= Topics =
  
== Messages ==
+
Train Describer messages (C-Class and S-Class) are presented on ActiveMQ topics:
  
Messages consist of a reference key and then the main JSON string.
+
The topic named 'TD_ALL_SIG_AREA' contains data from all train describers, and is not filtered.  The mappings for the other topics have not been updated for a number of years and thus may contain little or no data.
  
The Reference key is the message type followed by _MSG, all in Upper case.
+
{| class="wikitable"
 +
!Topic
 +
!Description
 +
|-
 +
|TD_ALL_SIG_AREA
 +
|All signalling areas
 +
|-
 +
|TD_SE_SIG_AREA
 +
|Scotland - East
 +
|-
 +
|TD_SW_SIG_AREA
 +
|Scotland - West
 +
|-
 +
|TD_LNE_NE_SIG_AREA
 +
|London North Eastern - North East
 +
|-
 +
|TD_MC_EM_SIG_AREA
 +
|Midlands & Continental - East Midlands
 +
|-
 +
|TD_LNE_GN_SIG_AREA
 +
|London North Eastern - Great Northern
 +
|-
 +
|TD_LNW_LC_SIG_AREA
 +
|London North Western - Lancashire and Cumbria
 +
|-
 +
|TD_LNW_C_SIG_AREA
 +
|London North Western - Central
 +
|-
 +
|TD_LNW_WMC_SIG_AREA
 +
|London North Western - West Midlands Central
 +
|-
 +
|TD_WCS_SIG_AREA
 +
|West Coast - South
 +
|-
 +
|TD_ANG_SIG_AREA
 +
|Anglia
 +
|-
 +
|TD_KENT_MCC_SIG_AREA
 +
|Kent and Midlands & Continental
 +
|-
 +
|TD_SUSS_SIG_AREA
 +
|Sussex
 +
|-
 +
|TD_WESS_SIG_AREA
 +
|Wessex
 +
|-
 +
|TD_WTV_SIG_AREA
 +
|Western - Thames Valley
 +
|-
 +
|TD_WWC_SIG_AREA
 +
|Western - West Country
 +
|-
 +
|TD_WWM_SIG_AREA
 +
|Western Wales and Marches
 +
|-
 +
|}
  
Each message can contain the keys,
+
= Message types =
  
* to
+
The Train Describer feed has seven message types, split into two classes. See individual pages for further details.
* time, in Milliseconds
 
* area_id, see [[TD_Areas]]
 
* msg_type
 
* from
 
* descr, the Train's [[headcode]]
 
* report_time, eg 0842, is 9:42 in the morning,
 
  
=== CA ===
+
* [[C_Class_Messages | C-Class Messages]] provide information about train describer berths and descriptions
 +
* [[S_Class_Messages | S-Class Messages]] provide signalling state information
  
Contains: to, time, area_id, msg_type, from, descr
+
= Cross-midnight bug =
 +
There is a known issue with the TD feed that can cause a very small number of messages to be given an incorrect timestamp.  The NR TD feed assumes that all TD events occur on the date they are received by the feed.  This assumption is almost always correct but can be wrong for messages received <1s before midnight.  Such messages can easily be spotted and corrected by comparing the timestamp in the message to the current time (in UTC) and adjusting by 24 hours if there is a large difference.
  
==== Example ====
+
The impact of this is very minor, usually only 3-5 messages out of the approx. 1.5-2 million published by the feed on a typical day.  However, it may affect latency monitoring of the feed, so affected messages should be corrected or ignored in such calculations.
  
  {
+
= Examples and Source Code =
    "CA_MSG": {
+
* [https://github.com/openraildata/td-example-python3 Python example]
      "to": "0041",
+
* [https://github.com/openraildata/td-trust-example-elixir Elixir example]
      "time": "1338289664000",
 
      "area_id": "LB",
 
      "msg_type": "CA",
 
      "from": "0033",
 
      "descr": "2T33"
 
    }
 
  }
 
  
=== CB ===
+
{{Navtable-DataFeeds}}
  
Contains: time, area_id, msg_type, from, descr
+
[[Category:Train Describer Data]]
 
+
[[Category:C Class Messages]]
==== Example ====
+
[[Category:S Class Messages]]
 
 
  {
 
    "CB_MSG": {
 
      "time": "1338289665000",
 
      "area_id": "SK",
 
      "msg_type": "CB",
 
      "from": "4333",
 
      "descr": "1U29"
 
    }
 
  }
 
 
 
=== CC ===
 
 
 
Contains: to, time, area_id, msg_type, descr
 
 
 
==== Example ====
 
 
 
  {
 
    "CC_MSG": {
 
      "to": "FN13",
 
      "time": "1338289665000",
 
      "area_id": "ZG",
 
      "msg_type": "CC",
 
      "descr": "1A40"
 
    }
 
  }
 
 
 
=== CT ===
 
 
 
Contains: time, area_id, msg_type, report_time
 
 
 
==== Example ====
 
 
 
  {
 
    "CT_MSG": {
 
      "time": "1338289669000",
 
      "area_id": "WJ",
 
      "msg_type": "CT",
 
      "report_time": "0842"
 
    }
 
  }
 

Revision as of 12:48, 17 July 2022

The Train Describer feed provides low-level detail about the position of trains and their train reporting number through a network of berths. Usually, but not always, a berth is associated with a signal - but there are locations (such as terminal platforms at stations) where there may be more than one berth. From each berth, there are zero or more other berths which a train description may step in to. A step between berths represents movement of the train from one berth to another. Some of these steps may be one-way, some may be two-way.

To access the TD data feed, you must select and subscribe to the appropriate geographical topic(s) on the My Feeds page on the Data Feeds website (see the about the feeds page.)

See also the list of train describers page, where you will find information on specific TD's including user contributions & documentation provided by Network Rail such as S-Class data, maps and stepping data.

Topics

Train Describer messages (C-Class and S-Class) are presented on ActiveMQ topics:

The topic named 'TD_ALL_SIG_AREA' contains data from all train describers, and is not filtered. The mappings for the other topics have not been updated for a number of years and thus may contain little or no data.

Topic Description
TD_ALL_SIG_AREA All signalling areas
TD_SE_SIG_AREA Scotland - East
TD_SW_SIG_AREA Scotland - West
TD_LNE_NE_SIG_AREA London North Eastern - North East
TD_MC_EM_SIG_AREA Midlands & Continental - East Midlands
TD_LNE_GN_SIG_AREA London North Eastern - Great Northern
TD_LNW_LC_SIG_AREA London North Western - Lancashire and Cumbria
TD_LNW_C_SIG_AREA London North Western - Central
TD_LNW_WMC_SIG_AREA London North Western - West Midlands Central
TD_WCS_SIG_AREA West Coast - South
TD_ANG_SIG_AREA Anglia
TD_KENT_MCC_SIG_AREA Kent and Midlands & Continental
TD_SUSS_SIG_AREA Sussex
TD_WESS_SIG_AREA Wessex
TD_WTV_SIG_AREA Western - Thames Valley
TD_WWC_SIG_AREA Western - West Country
TD_WWM_SIG_AREA Western Wales and Marches

Message types

The Train Describer feed has seven message types, split into two classes. See individual pages for further details.

Cross-midnight bug

There is a known issue with the TD feed that can cause a very small number of messages to be given an incorrect timestamp. The NR TD feed assumes that all TD events occur on the date they are received by the feed. This assumption is almost always correct but can be wrong for messages received <1s before midnight. Such messages can easily be spotted and corrected by comparing the timestamp in the message to the current time (in UTC) and adjusting by 24 hours if there is a large difference.

The impact of this is very minor, usually only 3-5 messages out of the approx. 1.5-2 million published by the feed on a typical day. However, it may affect latency monitoring of the feed, so affected messages should be corrected or ignored in such calculations.

Examples and Source Code


Network Rail Open Data Feeds
Data Feeds About the Feeds Account States Durable Subscriptions Example Code ( PHP / C# / Java / Ruby / Node.js) • Advanced UsesFAQ Release Notes
RTPPM RTPPM Feed
Train Movements Train Movements Feed Train Activation Train Cancellation Train Movement Train Reinstatement Change of Origin Change of Identity Change of Location TSPEED Field Planned Cancellations Cancellation Codes
TD TD Feed C-Class Messages S-Class Messages Train Describers TD Berths
VSTP VSTP Feed
TSR TSR Feed Route Codes
SCHEDULE SCHEDULE Feed Schedule and Location Records Association Records CIF Codes How Scheduling Works Allowances
Reference Data Reference Data Feed TOC Codes CIF Codes Delay Attribution Codes Identifying Locations (STANOX, TIPLOC, NLC and 3-Alpha Codes) STANOX Geographical Areas Train Planning data