36#ifndef _OPENLCB_BROADCASTTIMEDEFS_HXX_
37#define _OPENLCB_BROADCASTTIMEDEFS_HXX_
163 switch (suffix & 0xFFF)
234 if (day >= 1 && day <= 31)
247 if (month >= 1 && month <= 12)
276 if (rate.rate_ & 0x0800)
279 rate.rate_ |= 0xF000;
292 HASSERT(minutes >= 0 && minutes <= 59);
293 HASSERT(hours >= 0 && hours <= 23);
306 HASSERT(month >= 1 && month <= 12);
307 HASSERT(day >= 1 && day <= 31);
319 HASSERT(year >= 0 && year <= 4095);
330 HASSERT(rate >= -2048 && rate < 2048);
367 static bool string_to_time(
const std::string &stime,
int *hour,
int *min);
387 const std::string &sdate,
int *year,
int *month,
int *day);
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
uint64_t NodeID
48-bit NMRAnet Node ID type
Static constants and helper functions for Broadcast Time Protocol.
static uint64_t time_to_event(uint64_t event_base, int hours, int minutes)
Build an event from hours and minutes.
static std::string time_to_string(int hour, int min)
Convert time in integer hours/minutes to a string ("hh:mm").
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 uint64_t year_to_event(uint64_t event_base, int year)
Build an event from year.
static int event_to_min(uint64_t event)
Get the minutes from the event.
static std::string rate_quarters_to_string(int16_t rate)
Convert rate in integer rate quarters to a string (float).
static constexpr NodeID ALTERNATE_CLOCK_1_ID
Unique identifier for Alternate Clock 1.
static constexpr NodeID ALTERNATE_CLOCK_2_ID
Unique identifier for Alternate Clock 2.
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 EventType get_event_type(uint16_t suffix)
Get the EventTuype from the event suffix number.
static int16_t string_to_rate_quarters(const std::string &srate)
Convert a string (float) to rate quarters.
static uint64_t rate_to_event(uint64_t event_base, int16_t rate)
Build an event from rate.
static constexpr NodeID DEFAULT_REALTIME_CLOCK_ID
Unique identifier for the Default Real-Time Clock.
@ TUESDAY
Day of the week value Tuesday.
@ SUNDAY
Day of the week value Sunday.
@ THURSDAY
Day of the week value Thursday.
@ MONDAY
Day of the week value Monday.
@ WEDNESDAY
Day of the week value Wednesday.
@ FRIDAY
Day of the week value Friday.
@ SATURDAY
Day of the week value Saturday.
static bool canonicalize_time_string(std::string *stime)
Verifies that a user-provided string parses as time, and canonicalizes the string format.
static int16_t event_to_rate(uint64_t event)
Get the rate from the event.
static constexpr NodeID DEFAULT_FAST_CLOCK_ID
Unique identifier for the Default Fast Clock.
static uint64_t date_to_event(uint64_t event_base, int month, int day)
Build an event from month and day.
static int event_to_year(uint64_t event)
Get the year from the event.
static std::string date_to_string(int year, int month, int day)
Converts a date to a string "Mmm dd, yyyy".
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 valid_date(uint16_t suffix)
Validate that this is a supported date event.
static bool valid_time(uint16_t suffix)
Validate that this is a supported time event.
@ REPORT_TIME
report time event
@ REPORT_YEAR
report year event
@ DATE_ROLLOVER
date rollover event
@ REPORT_RATE
report rate event
@ UNDEFINED
undefined event
@ REPORT_DATE
report date event
static bool canonicalize_date_string(std::string *sdate)
Verifies that a user-provided string parses as date, and canonicalizes the string format.
static int event_to_hour(uint64_t event)
Get the hour from the event.
@ EVENT_RATE_SHIFT
rate mask
@ EVENT_SET_SUFFIX_MASK
suffix max for setting a property
@ EVENT_YEAR_MASK
rate mask
@ EVENT_MINUTES_SHIFT
minutes mask
@ EVENT_HOURS_MASK
hours mask
@ EVENT_MINUTES_MASK
minutes mask
@ EVENT_MONTH_MASK
month mask
@ EVENT_SUFFIX_MASK
suffix mask
@ START_EVENT_SUFFIX
start clock event suffix value
@ EVENT_TYPE_MASK
type mask
@ DATE_ROLLOVER_EVENT_SUFFIX
rollover the date suffix value
@ EVENT_HOURS_SHIFT
hours mask
@ STOP_EVENT_SUFFIX
stop clock event suffix value
@ DATE_EVENT_BASE_SUFFIX
date event base suffix
@ EVENT_DAY_SHIFT
day mask
@ EVENT_ID_MASK
Unique ID mask.
@ YEAR_EVENT_BASE_SUFFIX
year event base suffix
@ RATE_EVENT_BASE_SUFFIX
rate event base suffix
@ EVENT_MONTH_SHIFT
month mask
@ EVENT_RATE_MASK
rate mask
@ EVENT_YEAR_SHIFT
year mask
@ TIME_EVENT_BASE_SUFFIX
time event base suffix
@ QUERY_EVENT_SUFFIX
query event suffix value
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.