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.h@7:d713a0e47ffe, 2016-04-26 (annotated)
- Committer:
- Leigh_LbR
- Date:
- Tue Apr 26 13:03:09 2016 +0000
- Revision:
- 7:d713a0e47ffe
- Parent:
- 3:a287e75a2121
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 | #ifndef DEPARTURE_H |
Leigh_LbR | 0:bf04f62339a4 | 2 | #define DEPARTURE_H |
Leigh_LbR | 0:bf04f62339a4 | 3 | |
Leigh_LbR | 0:bf04f62339a4 | 4 | #include <string> |
Leigh_LbR | 0:bf04f62339a4 | 5 | |
Leigh_LbR | 3:a287e75a2121 | 6 | /** Departure |
Leigh_LbR | 3:a287e75a2121 | 7 | * Stores a single departure |
Leigh_LbR | 3:a287e75a2121 | 8 | */ |
Leigh_LbR | 0:bf04f62339a4 | 9 | class Departure { |
Leigh_LbR | 0:bf04f62339a4 | 10 | public: |
Leigh_LbR | 0:bf04f62339a4 | 11 | std::string crs; |
Leigh_LbR | 0:bf04f62339a4 | 12 | std::string locationName; |
Leigh_LbR | 0:bf04f62339a4 | 13 | std::string std; |
Leigh_LbR | 0:bf04f62339a4 | 14 | std::string etd; |
Leigh_LbR | 0:bf04f62339a4 | 15 | std::string platform; |
Leigh_LbR | 0:bf04f62339a4 | 16 | std::string operatorName; |
Leigh_LbR | 0:bf04f62339a4 | 17 | std::string operatorCode; |
Leigh_LbR | 0:bf04f62339a4 | 18 | |
Leigh_LbR | 3:a287e75a2121 | 19 | /** Empty Departure constructor |
Leigh_LbR | 3:a287e75a2121 | 20 | */ |
Leigh_LbR | 0:bf04f62339a4 | 21 | Departure() {}; |
Leigh_LbR | 3:a287e75a2121 | 22 | /** Departure constructor |
Leigh_LbR | 3:a287e75a2121 | 23 | * @param _crs Station code (in NR style) |
Leigh_LbR | 3:a287e75a2121 | 24 | * @param _locationName Location of departure (i.e. where the train is going) |
Leigh_LbR | 3:a287e75a2121 | 25 | * @param _std Scheduled time of departure (in 24-hour format, i.e. "14:03") |
Leigh_LbR | 3:a287e75a2121 | 26 | * @param _etd Estimated time of departure (in 24-hour format, "On time", "Delayed" or "Cancelled") |
Leigh_LbR | 3:a287e75a2121 | 27 | * @param _platform Intended platform |
Leigh_LbR | 3:a287e75a2121 | 28 | * @param _operatorName The train operating company operating the service |
Leigh_LbR | 3:a287e75a2121 | 29 | * @param _operatorCode The train operating companies' NR code |
Leigh_LbR | 3:a287e75a2121 | 30 | */ |
Leigh_LbR | 0:bf04f62339a4 | 31 | 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 | 7:d713a0e47ffe | 32 | |
Leigh_LbR | 7:d713a0e47ffe | 33 | /** Determine if the departure is delayed |
Leigh_LbR | 7:d713a0e47ffe | 34 | * @return a boolean stating if the departure is delayed |
Leigh_LbR | 7:d713a0e47ffe | 35 | */ |
Leigh_LbR | 7:d713a0e47ffe | 36 | bool IsDelayed(); |
Leigh_LbR | 7:d713a0e47ffe | 37 | /** Determine if a departure is cancelled |
Leigh_LbR | 7:d713a0e47ffe | 38 | * @return a boolean stating if the departure is cancelled |
Leigh_LbR | 7:d713a0e47ffe | 39 | */ |
Leigh_LbR | 7:d713a0e47ffe | 40 | bool IsCancelled(); |
Leigh_LbR | 7:d713a0e47ffe | 41 | /** Determine if a departure is on time |
Leigh_LbR | 7:d713a0e47ffe | 42 | * @return a boolean stating if the departure is on time |
Leigh_LbR | 7:d713a0e47ffe | 43 | */ |
Leigh_LbR | 7:d713a0e47ffe | 44 | bool IsOnTime(); |
Leigh_LbR | 7:d713a0e47ffe | 45 | /** Get the estimated time of departure |
Leigh_LbR | 7:d713a0e47ffe | 46 | * @return a time string with the estimated time of departure (in format "HH:MM"), the phrase "Unknown" if it is not known, or the phrase "Cancelled" if it is cancelled |
Leigh_LbR | 7:d713a0e47ffe | 47 | */ |
Leigh_LbR | 7:d713a0e47ffe | 48 | std::string GetETDFormatted(); |
Leigh_LbR | 0:bf04f62339a4 | 49 | }; |
Leigh_LbR | 0:bf04f62339a4 | 50 | #endif |