35#ifndef _OPENLCB_BROADCASTTIME_HXX_
36#define _OPENLCB_BROADCASTTIME_HXX_
142 for (
size_t i = 0; i <
callbacks_.size(); ++i)
See OSMutexLock in os/OS.hxx.
Use this timer class to deliver the timeout notification to a stateflow.
Base class for state machines.
Helper class for implementing fast clocks.
struct tm * gmtime_r(struct tm *result)
Get the time as a standard struct tm.
time_t time()
Get the time as a value of seconds relative to the system epoch.
Implementation of Broadcast Time Protocol.
StateFlowTimer timer_
timer helper
virtual bool is_server_detected()=0
Has a time server been detected?
const struct tm * gmtime_get()
Get the last calculated reprentation of time.
void clear_timezone()
Reset our process local timezone environment to GMT0.
int16_t rateRequested_
pending clock rate
void set_year(int year)
Set the time in seconds since the system Epoch.
std::function< void(time_t old, time_t current)> TimeUpdateCallback
Callback type used for time update subscribers.
void update_subscribe_remove(UpdateSubscribeHandle handle)
Unregister a callback for when the time synchronization is updated.
void set_date_year_str(const char *date_year)
Set the date and year from a C string.
virtual bool is_server_self()=0
Test if this is a server.
virtual ~BroadcastTime()
Destructor.
std::vector< TimeUpdateCallback > callbacks_
update subscribers
void service_callbacks(time_t old, time_t current)
Service all of the attached update subscribers.
Node * node()
Accessor method to get the Node reference.
BroadcastTime(Node *node, NodeID clock_id)
Constructor.
NodeID clock_id()
Accessor method to get the (48-bit) Clock ID.
EventId event_base()
Access method to get the (64-bit) Event ID base.
size_t UpdateSubscribeHandle
An opaque data element that is returned from update subscriber registration, and allows unregistering...
struct tm tm_
the time we are last set to as a struct tm
void query()
Query the current time.
void set_date(int month, int day)
Set the time in seconds since the system Epoch.
void set_time(int hours, int minutes)
Set the time in seconds since the system Epoch.
virtual void set_shortcut(uint64_t event)
Try the possible set event shortcut.
UpdateSubscribeHandle update_subscribe_add(TimeUpdateCallback callback)
Register a callback for when the time synchronization is updated.
WriteHelper writer_
helper for sending event messages
const struct tm * gmtime_recalculate()
Recalculate the struct tm representation of time.
void set_rate_quarters(int16_t rate)
Set Rate.
EventId eventBase_
48-bit unique identifier for the clock instance
Node * node_
OpenLCB node to export the consumer on.
Base class for NMRAnet nodes conforming to the asynchronous interface.
SimpleEventHandler ignores all non-essential callbacks.
A statically allocated buffer for sending one message to the OpenLCB bus.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
uint64_t NodeID
48-bit NMRAnet Node ID type
void send_event(Node *src_node, uint64_t event_id)
Helper function to send an event report to the bus.
static uint64_t time_to_event(uint64_t event_base, int hours, int minutes)
Build an event from hours and minutes.
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 uint64_t date_to_event(uint64_t event_base, int month, int day)
Build an event from month and day.
@ EVENT_SET_SUFFIX_MASK
suffix max for setting a property
@ START_EVENT_SUFFIX
start clock event suffix value
@ STOP_EVENT_SUFFIX
stop clock event suffix value
@ QUERY_EVENT_SUFFIX
query event suffix value