From 21d54ff7296ff33c11b9f7b788417a11e702f0d0 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 31 Jan 2018 04:39:16 +0100 Subject: Add TAI bulletin expiry to RC and to munin --- src/ClockTAI.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/ClockTAI.h') diff --git a/src/ClockTAI.h b/src/ClockTAI.h index 4ee4072..ac4978c 100644 --- a/src/ClockTAI.h +++ b/src/ClockTAI.h @@ -39,14 +39,18 @@ #include #include #include +#include +#include "RemoteControl.h" // EDI needs to know UTC-TAI, but doesn't need the CLOCK_TAI to be set. // We can keep this code, maybe for future use #define SUPPORT_SETTING_CLOCK_TAI 0 /* Loads, parses and represents TAI-UTC offset information from the IETF bulletin */ -class ClockTAI { +class ClockTAI : public RemoteControllable { public: + ClockTAI(); + // Fetch the bulletin from the IETF website and return the current // TAI-UTC offset. // Throws runtime_error on failure. @@ -70,11 +74,14 @@ class ClockTAI { // Download of new bulletin is done asynchronously std::future m_offset_future; + // Protect all data members, as RC functions are in another thread + mutable std::mutex m_data_mutex; + // The currently used TAI-UTC offset int m_offset; int m_offset_valid = false; - std::stringstream m_bulletin; + mutable std::stringstream m_bulletin; std::chrono::system_clock::time_point m_bulletin_download_time; // Load bulletin into m_bulletin from the cache file @@ -87,6 +94,10 @@ class ClockTAI { // true if the bulletin is valid. bool bulletin_is_valid(void); + // In how much time will the bulletin expire? + // returns a value in seconds, or -1 if it is expired or invalid + int64_t bulletin_expiry_delay(void) const; + // Load bulletin into m_bulletin from the URL void download_tai_utc_bulletin(const char* url); @@ -99,5 +110,12 @@ class ClockTAI { // static callback wrapper for cURL static size_t fill_bulletin_cb( char *ptr, size_t size, size_t nmemb, void *ctx); + + /* Remote control */ + virtual void set_parameter(const std::string& parameter, + const std::string& value); + + /* Getting a parameter always returns a string. */ + virtual const std::string get_parameter(const std::string& parameter) const; }; -- cgit v1.2.3