Train Movements: Difference between revisions
m Clarification that timestamps are only wrong during BST |
PeterHicks (talk | contribs) m Make clear the TRUST messages are available on a single topic |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 7: | Line 7: | ||
TRUST data may also be updated/amended 'after the fact' so a delay which is input manually from TRUST DA may overwrite a previous automatic report and that could happen several days later. TRUST should always be historically correct. | TRUST data may also be updated/amended 'after the fact' so a delay which is input manually from TRUST DA may overwrite a previous automatic report and that could happen several days later. TRUST should always be historically correct. | ||
TRUST does not provide predictions, it only reports on events that have happened. TRUST reports in 30 second intervals, and rounds to whole | TRUST does not provide predictions, it only reports on events that have happened. TRUST reports in 30 second intervals, and rounds to whole minutes. - A train reporting 1 minute early or late may only be 31 seconds early or late in reality. | ||
= Message Topics = | = Message Topics = | ||
Train movement messages are available through | Train movement messages are available through a single topic, TRAIN_MVT_ALL_TOC. Historically, they were available on a per-operator feed, a freight operator feed, and a 'general' feed including Change of Identity messages. These topics are listed here for historical reasons: | ||
{| class="wikitable" | {| class="wikitable" | ||
! | !Historical topic name | ||
!Description | !Description | ||
|- | |- | ||
|TRAIN_MVT_''XX''_TOC | |TRAIN_MVT_''XX''_TOC | ||
|Train movement messages for ''XX'' TOC. | |Train movement messages for ''XX'' TOC. These codes are business codes on the [[TOC Codes]] page | ||
|- | |- | ||
|TRAIN_MVT_ALL_TOC | |TRAIN_MVT_ALL_TOC | ||
Line 35: | Line 34: | ||
The feed contains eight message types, all in JSON format: | The feed contains eight message types, all in JSON format: | ||
{| class="wikitable" | |||
!Type | |||
!Description | |||
|- | |||
|0001 | |||
|[[Train Activation]] | |||
|- | |||
|0002 | |||
|[[Train Cancellation]] | |||
|- | |||
|0003 | |||
|[[Train Movement]] | |||
|- | |||
|0004 | |||
|Unidentified Train (not used in production) | |||
|- | |||
|0005 | |||
|[[Train Reinstatement]] | |||
|- | |||
|0006 | |||
|[[Change of Origin]] | |||
|- | |||
|0007 | |||
|[[Change of Identity]] | |||
|- | |||
|0008 | |||
|[[Change of Location]] | |||
|} | |||
== Format == | == Format == | ||
Line 52: | Line 67: | ||
Each message is represented as a JSON hash with two keys - 'header' and 'body'. Zero or more of these messages is sent out in a JSON list, either every five seconds or when there are 32 messages to be sent. It is perfectly legitimate to receive an empty array. | Each message is represented as a JSON hash with two keys - 'header' and 'body'. Zero or more of these messages is sent out in a JSON list, either every five seconds or when there are 32 messages to be sent. It is perfectly legitimate to receive an empty array. | ||
All timestamp values are in milliseconds since the UNIX epoch. But it appears that in certain fields this is incorrect during British Summer Time (UK DST) and is <i>actually one hour in the future.</i> You will need to subtract one hour in order for the times to be valid. This is known to affect the following fields | All timestamp values are in milliseconds since the UNIX epoch. But it appears that in certain fields this is incorrect during British Summer Time (UK DST) and is <i>actually one hour in the future.</i> You will need to subtract one hour in order for the times to be valid. This is known to affect the following fields: | ||
* gbtt_timestamp | * gbtt_timestamp | ||
* planned_timestamp | * planned_timestamp | ||
Line 59: | Line 75: | ||
* dep_timestamp | * dep_timestamp | ||
* orig_loc_timestamp | * orig_loc_timestamp | ||
== Weekly Planned Outage == | |||
Each week there is a short planned outage in the TRUST feeds, which normally takes place in the early hours of Sunday morning (when very few trains are running). Usually the outage occurs at some point between 0200 and 0215 and lasts for approximately 5 minutes. Any missed messages during the outage period are sent by the feed once it resumes. | |||
== Examples and source code == | |||
* [https://github.com/openraildata/network-rail-json-schema JSON schema for TRUST messages] | |||
{{Navtable-DataFeeds}} | {{Navtable-DataFeeds}} | ||
[[Category:Train Movement Data]] | [[Category:Train Movement Data]] |
Latest revision as of 10:37, 6 December 2023
The Train Movements feed contains data from Network Rail's TRUST system. This reports on the progress of trains along their journey.
There's a fuller description of the process available.
Because of the way TRUST works not every location will generate a report. If you want fine grain reporting then you would need to look at processing data from the TD feed and reporting based on that, or look at the Darwin Push Port data. Darwin will generally capture more, better quality, and ad-hoc data as its part of the bigger customer information system - TRUST is an internal reporting tool and can be updated in 'slow time' meaning data can change or be late being input. A good example is cancelled services - they may be input to Darwin via another source (Darwin Workstation, Tyrell, CIS) leading to a cancellation, the actual TRUST cancellation may not come through till much later.
TRUST data may also be updated/amended 'after the fact' so a delay which is input manually from TRUST DA may overwrite a previous automatic report and that could happen several days later. TRUST should always be historically correct.
TRUST does not provide predictions, it only reports on events that have happened. TRUST reports in 30 second intervals, and rounds to whole minutes. - A train reporting 1 minute early or late may only be 31 seconds early or late in reality.
Message Topics
Train movement messages are available through a single topic, TRAIN_MVT_ALL_TOC. Historically, they were available on a per-operator feed, a freight operator feed, and a 'general' feed including Change of Identity messages. These topics are listed here for historical reasons:
Historical topic name | Description |
---|---|
TRAIN_MVT_XX_TOC | Train movement messages for XX TOC. These codes are business codes on the TOC Codes page |
TRAIN_MVT_ALL_TOC | All train operating companies |
TRAIN_MVT_FREIGHT | All non-passenger train operating company movements |
TRAIN_MVT_GENERAL | Change of Identity messages for freight trains |
Message types
The feed contains eight message types, all in JSON format:
Type | Description |
---|---|
0001 | Train Activation |
0002 | Train Cancellation |
0003 | Train Movement |
0004 | Unidentified Train (not used in production) |
0005 | Train Reinstatement |
0006 | Change of Origin |
0007 | Change of Identity |
0008 | Change of Location |
Format
Each message is represented as a JSON hash with two keys - 'header' and 'body'. Zero or more of these messages is sent out in a JSON list, either every five seconds or when there are 32 messages to be sent. It is perfectly legitimate to receive an empty array.
All timestamp values are in milliseconds since the UNIX epoch. But it appears that in certain fields this is incorrect during British Summer Time (UK DST) and is actually one hour in the future. You will need to subtract one hour in order for the times to be valid. This is known to affect the following fields:
- gbtt_timestamp
- planned_timestamp
- actual_timestamp
- canx_timestamp
- dep_timestamp
- orig_loc_timestamp
Weekly Planned Outage
Each week there is a short planned outage in the TRUST feeds, which normally takes place in the early hours of Sunday morning (when very few trains are running). Usually the outage occurs at some point between 0200 and 0215 and lasts for approximately 5 minutes. Any missed messages during the outage period are sent by the feed once it resumes.
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 Uses • FAQ • 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 • TIPLOC Records • 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 (BPLAN) |