|
Open Model Railroad Network (OpenMRN)
|
Static constants and helper functions for Broadcast Time Protocol. More...
#include <BroadcastTimeDefs.hxx>
Static Public Member Functions | |
| static EventType | get_event_type (uint16_t suffix) |
| Get the EventTuype from the event suffix number. | |
| static bool | valid_time (uint16_t suffix) |
| Validate that this is a supported time event. | |
| static bool | valid_date (uint16_t suffix) |
| Validate that this is a supported date event. | |
| static int | event_to_min (uint64_t event) |
| Get the minutes from the event. | |
| static int | event_to_hour (uint64_t event) |
| Get the hour from the event. | |
| static int | event_to_day (uint64_t event) |
| Get the day from the event. | |
| static int | event_to_month (uint64_t event) |
| Get the month from the event. | |
| static int | event_to_year (uint64_t event) |
| Get the year from the event. | |
| static int16_t | event_to_rate (uint64_t event) |
| Get the rate from the event. | |
| static uint64_t | time_to_event (uint64_t event_base, int hours, int minutes) |
| Build an event from hours and minutes. | |
| static uint64_t | date_to_event (uint64_t event_base, int month, int day) |
| Build an event from month and day. | |
| static uint64_t | year_to_event (uint64_t event_base, int year) |
| Build an event from year. | |
| static uint64_t | rate_to_event (uint64_t event_base, int16_t rate) |
| Build an event from rate. | |
| static std::string | time_to_string (int hour, int min) |
| Convert time in integer hours/minutes to a string ("hh:mm"). | |
| static std::string | rate_quarters_to_string (int16_t rate) |
| Convert rate in integer rate quarters to a string (float). | |
| static std::string | date_to_string (int year, int month, int day) |
| Converts a date to a string "Mmm dd, yyyy". | |
| static bool | string_to_time (const std::string &stime, int *hour, int *min) |
| Convert a string (hh:mm) to hour and minute component integers. | |
| static int16_t | string_to_rate_quarters (const std::string &srate) |
| Convert a string (float) to rate quarters. | |
| static bool | string_to_date (const std::string &sdate, int *year, int *month, int *day) |
| Converts a (user-provided) string "Mmm dd, yyyy" to date. | |
| static bool | canonicalize_time_string (std::string *stime) |
| Verifies that a user-provided string parses as time, and canonicalizes the string format. | |
| static bool | canonicalize_rate_string (std::string *srate) |
| Verifies that a user-provided string parses as rate quarters, and canonicalizes the string format. | |
| static bool | canonicalize_date_string (std::string *sdate) |
| Verifies that a user-provided string parses as date, and canonicalizes the string format. | |
Static Public Attributes | |
| static constexpr NodeID | DEFAULT_FAST_CLOCK_ID = 0x010100000100ULL |
| Unique identifier for the Default Fast Clock. | |
| static constexpr NodeID | DEFAULT_REALTIME_CLOCK_ID = 0x010100000101ULL |
| Unique identifier for the Default Real-Time Clock. | |
| static constexpr NodeID | ALTERNATE_CLOCK_1_ID = 0x010100000102ULL |
| Unique identifier for Alternate Clock 1. | |
| static constexpr NodeID | ALTERNATE_CLOCK_2_ID = 0x010100000103ULL |
| Unique identifier for Alternate Clock 2. | |
Static constants and helper functions for Broadcast Time Protocol.
Definition at line 47 of file BroadcastTimeDefs.hxx.
| anonymous enum |
Definition at line 79 of file BroadcastTimeDefs.hxx.
| anonymous enum |
Definition at line 110 of file BroadcastTimeDefs.hxx.
Type of event.
Definition at line 62 of file BroadcastTimeDefs.hxx.
|
static |
Verifies that a user-provided string parses as date, and canonicalizes the string format.
Parse errors get turned into "Jan 1, 1970".
| sdate | input-output argument. Input is user-provided date in "Mmm dd, yyyy" format, output is the canonicalized date. |
Definition at line 241 of file BroadcastTimeDefs.cxx.
|
static |
Verifies that a user-provided string parses as rate quarters, and canonicalizes the string format.
Parse errors get turned into "0.00".
| srate | input-output argument. Input is user-provided rate, output is the canonicalized rate. |
Definition at line 229 of file BroadcastTimeDefs.cxx.
|
static |
Verifies that a user-provided string parses as time, and canonicalizes the string format.
Parse errors get turned into "00:00".
| stime | input-output argument. Input is the user-provided time (hh:mm), output is the canonicalized time. |
Definition at line 254 of file BroadcastTimeDefs.cxx.
|
inlinestatic |
Build an event from month and day.
| event_base | base event ID of the event pool |
| month | month (1 to 12) |
| day | day of month (1 to 31) |
Definition at line 304 of file BroadcastTimeDefs.hxx.
|
static |
Converts a date to a string "Mmm dd, yyyy".
| year | 0 to 4095 |
| month | 1 to 12 (warning! struct tm has 0 to 11) |
| day | 1 to 31 |
Definition at line 117 of file BroadcastTimeDefs.cxx.
|
inlinestatic |
Get the day from the event.
To save logic, the event is assumed to be of type REPORT_DATE.
Definition at line 231 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Get the hour from the event.
To save logic, the event is assumed to be of type REPORT_TIME.
Definition at line 218 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Get the minutes from the event.
To save logic, the event is assumed to be of type REPORT_TIME.
Definition at line 205 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Get the month from the event.
To save logic, the event is assumed to be of type REPORT_DATE.
Definition at line 244 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Get the rate from the event.
To save logic, the event is assumed to be of type REPORT_RATE.
Definition at line 265 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Get the year from the event.
To save logic, the event is assumed to be of type REPORT_YEAR.
Definition at line 257 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Get the EventTuype from the event suffix number.
| suffix | 16-bit event suffix |
Definition at line 124 of file BroadcastTimeDefs.hxx.
|
static |
Convert rate in integer rate quarters to a string (float).
| rate | rate in the form of rate quarters |
Definition at line 82 of file BroadcastTimeDefs.cxx.
|
inlinestatic |
Build an event from rate.
| event_base | base event ID of the event pool |
| year | (0AD to 4095AD) |
Definition at line 328 of file BroadcastTimeDefs.hxx.
|
static |
Converts a (user-provided) string "Mmm dd, yyyy" to date.
Verifies that the values are in range for OpenLCB and for a real date.
| sdate | the input string in "Mmm dd, yyyy" format. |
| year | will be filled in with the year (0 to 4095) |
| month | will be filled in with the month (1 to 12) (warning! struct tm has 0 to 11) |
| day | will be filled in with the day (1 to 31) |
Definition at line 189 of file BroadcastTimeDefs.cxx.
|
static |
Convert a string (float) to rate quarters.
| srate | rate in the form of a string float |
Definition at line 160 of file BroadcastTimeDefs.cxx.
|
static |
Convert a string (hh:mm) to hour and minute component integers.
| stime | time in the form of a string |
| hour | resulting hour integer (0 to 23) |
| min | resulting minute integer (0 to 59) |
Definition at line 137 of file BroadcastTimeDefs.cxx.
|
inlinestatic |
Build an event from hours and minutes.
| event_base | base event ID of the event pool |
| hours | hours (0 to 23) |
| minutes | minutes (0 to 59) |
Definition at line 290 of file BroadcastTimeDefs.hxx.
|
static |
Convert time in integer hours/minutes to a string ("hh:mm").
| hour | hours in integer form (0 to 23) |
| min | minutes in integer form (0 to 59) |
Definition at line 54 of file BroadcastTimeDefs.cxx.
|
inlinestatic |
Validate that this is a supported date event.
Assume that the four most significant bits have been seperately validated.
Definition at line 194 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Validate that this is a supported time event.
Assume that the four most significant bits have been seperately validated.
Definition at line 185 of file BroadcastTimeDefs.hxx.
|
inlinestatic |
Build an event from year.
| event_base | base event ID of the event pool |
| year | (0AD to 4095AD) |
Definition at line 317 of file BroadcastTimeDefs.hxx.
|
staticconstexpr |
Unique identifier for Alternate Clock 1.
Definition at line 56 of file BroadcastTimeDefs.hxx.
|
staticconstexpr |
Unique identifier for Alternate Clock 2.
Definition at line 59 of file BroadcastTimeDefs.hxx.
|
staticconstexpr |
Unique identifier for the Default Fast Clock.
Definition at line 50 of file BroadcastTimeDefs.hxx.
|
staticconstexpr |
Unique identifier for the Default Real-Time Clock.
Definition at line 53 of file BroadcastTimeDefs.hxx.