API for linking to the Huxley National Rail REST proxy for the retrieval of live National Rail data. Still needs work (sadly), but works well for the time being!
Dependencies: EthernetInterface
National Rail Huxley Integration Interface
This API provides a clear link between the National Rail Huxley Integration JSON interface (available at https://huxley.unop.uk/), and mbed devices, over an Ethernet connection. This project is still very much a work-in-progress, but hopefully I will be able to provide a comprehensive method of retrieving live National Rail departures data in a simple and effective way.
departure.cpp@7:d713a0e47ffe, 2016-04-26 (annotated)
- Committer:
- Leigh_LbR
- Date:
- Tue Apr 26 13:03:09 2016 +0000
- Revision:
- 7:d713a0e47ffe
- Parent:
- 0:bf04f62339a4
Added functions to get statuses of arrivals/departures (is it delayed, cancelled, on time) and to get the ETA/ETD of said arrival/departure
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Leigh_LbR | 0:bf04f62339a4 | 1 | #include "departure.h" |
Leigh_LbR | 0:bf04f62339a4 | 2 | #include <string> |
Leigh_LbR | 0:bf04f62339a4 | 3 | |
Leigh_LbR | 0:bf04f62339a4 | 4 | Departure::Departure(const std::string& _crs, const std::string& _locationName, const std::string& _std, const std::string& _etd, const std::string& _platform, const std::string& _operatorName, const std::string& _operatorCode) |
Leigh_LbR | 0:bf04f62339a4 | 5 | { |
Leigh_LbR | 0:bf04f62339a4 | 6 | crs = std::string(_crs); |
Leigh_LbR | 0:bf04f62339a4 | 7 | locationName = std::string(_locationName); |
Leigh_LbR | 0:bf04f62339a4 | 8 | std = std::string(_std); |
Leigh_LbR | 0:bf04f62339a4 | 9 | etd = std::string(_etd); |
Leigh_LbR | 0:bf04f62339a4 | 10 | platform = std::string(_platform); |
Leigh_LbR | 0:bf04f62339a4 | 11 | operatorName = std::string(_operatorName); |
Leigh_LbR | 0:bf04f62339a4 | 12 | operatorCode = std::string(_operatorCode); |
Leigh_LbR | 7:d713a0e47ffe | 13 | }; |
Leigh_LbR | 7:d713a0e47ffe | 14 | |
Leigh_LbR | 7:d713a0e47ffe | 15 | bool Departure::IsDelayed() |
Leigh_LbR | 7:d713a0e47ffe | 16 | { |
Leigh_LbR | 7:d713a0e47ffe | 17 | if(etd == "On time") return false; |
Leigh_LbR | 7:d713a0e47ffe | 18 | else if(etd == "Cancelled") return false; |
Leigh_LbR | 7:d713a0e47ffe | 19 | else return true; |
Leigh_LbR | 7:d713a0e47ffe | 20 | } |
Leigh_LbR | 7:d713a0e47ffe | 21 | |
Leigh_LbR | 7:d713a0e47ffe | 22 | std::string Departure::GetETDFormatted() |
Leigh_LbR | 7:d713a0e47ffe | 23 | { |
Leigh_LbR | 7:d713a0e47ffe | 24 | if(etd == "Delayed") return "Unknown"; |
Leigh_LbR | 7:d713a0e47ffe | 25 | else if(etd == "On time") return std; |
Leigh_LbR | 7:d713a0e47ffe | 26 | else return etd; |
Leigh_LbR | 7:d713a0e47ffe | 27 | } |
Leigh_LbR | 7:d713a0e47ffe | 28 | |
Leigh_LbR | 7:d713a0e47ffe | 29 | bool Departure::IsCancelled() |
Leigh_LbR | 7:d713a0e47ffe | 30 | { |
Leigh_LbR | 7:d713a0e47ffe | 31 | if(etd == "Cancelled") return true; |
Leigh_LbR | 7:d713a0e47ffe | 32 | else return false; |
Leigh_LbR | 7:d713a0e47ffe | 33 | } |
Leigh_LbR | 7:d713a0e47ffe | 34 | |
Leigh_LbR | 7:d713a0e47ffe | 35 | bool Departure::IsOnTime() |
Leigh_LbR | 7:d713a0e47ffe | 36 | { |
Leigh_LbR | 7:d713a0e47ffe | 37 | if(etd == "On time") return true; |
Leigh_LbR | 7:d713a0e47ffe | 38 | else return false; |
Leigh_LbR | 7:d713a0e47ffe | 39 | } |