TD: Difference between revisions

From Open Rail Data Wiki
Added sample messages
Restructured page, made more factual
Line 1: Line 1:
== Overview ==
== Overview ==


The Train Describer feed contains message about Train movements at the Signal Berth Level. Messages come in 4 types, all in JSON format:
=== What on earth is this? ===


* CA - Berth Step
The TD 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.
* CB - Berth Cancel
* CC - Berth Interpost
* CT - Heartbeat


Messages only exist for trains of [[headcode|headcodes]] classes, 1, 2 and 9.
From each berth, there are zero or more other berths which a train description may move, or 'step' in to.  Some of these may be one-way, some may be two-way.


== Messages ==
=== Message types ===


Messages consist of a reference key and then the main JSON string.
The Train Describer feed has four message types:


The Reference key is the message type followed by _MSG, all in Upper case.
* CA - Berth Step, where a description moves 'from' a berth, 'to' another berth
 
* CB - Berth Cancel, where a description is removed from a berth
Each message can contain the keys,
* CC - Berth Interpose, where a description is interposed (placed in to) a berth
 
* CT - Heartbeat
* to
* 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 ===
 
Contains: to, time, area_id, msg_type, from, descr
 
==== Example ====
 
  {
    "CA_MSG": {
      "to": "0041",
      "time": "1338289664000",
      "area_id": "LB",
      "msg_type": "CA",
      "from": "0033",
      "descr": "2T33"
    }
  }
 
=== CB ===
 
Contains: time, area_id, msg_type, from, descr
 
==== Example ====
 
  {
    "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 ===
With the exception of the CT message type, TD messages include a four-character train description.  At present, only class 1, 2 and 9 trains are included in the feed.


Contains: time, area_id, msg_type, report_time
== Format ==


==== Example ====
Messages are sent in JSON format, as follows:


  {
* {"CA_MSG"=>{"time"=>"1349696911000", "area_id"=>"SK", "msg_type"=>"CA", "from"=>"3647", "to"=>"3649", "descr"=>"1F42"}}
    "CT_MSG": {
* {"CB_MSG"=>{"time"=>"1349696911000", "area_id"=>"G1", "msg_type"=>"CB", "from"=>"G669", "descr"=>"2J01"}}
      "time": "1338289669000",
* {"CC_MSG"=>{"time"=>"1349696911000", "area_id"=>"G1", "msg_type"=>"CC", "descr"=>"2J01", "to"=>"G669"}}
      "area_id": "WJ",
* {"CT_MSG"=>{"time"=>"1349696911000", "area_id"=>"SA", "msg_type"=>"CT", "report_time"=>"1249"}}
      "msg_type": "CT",
      "report_time": "0842"
    }
  }

Revision as of 11:54, 8 October 2012

Overview

What on earth is this?

The TD 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 move, or 'step' in to. Some of these may be one-way, some may be two-way.

Message types

The Train Describer feed has four message types:

  • CA - Berth Step, where a description moves 'from' a berth, 'to' another berth
  • CB - Berth Cancel, where a description is removed from a berth
  • CC - Berth Interpose, where a description is interposed (placed in to) a berth
  • CT - Heartbeat

With the exception of the CT message type, TD messages include a four-character train description. At present, only class 1, 2 and 9 trains are included in the feed.

Format

Messages are sent in JSON format, as follows:

  • {"CA_MSG"=>{"time"=>"1349696911000", "area_id"=>"SK", "msg_type"=>"CA", "from"=>"3647", "to"=>"3649", "descr"=>"1F42"}}
  • {"CB_MSG"=>{"time"=>"1349696911000", "area_id"=>"G1", "msg_type"=>"CB", "from"=>"G669", "descr"=>"2J01"}}
  • {"CC_MSG"=>{"time"=>"1349696911000", "area_id"=>"G1", "msg_type"=>"CC", "descr"=>"2J01", "to"=>"G669"}}
  • {"CT_MSG"=>{"time"=>"1349696911000", "area_id"=>"SA", "msg_type"=>"CT", "report_time"=>"1249"}}