rtcApi.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <boost/function.hpp>
9 #include <boost/system/error_code.hpp>
10 #include <boost/shared_ptr.hpp>
11 #include <map>
12 
13 #include "dateSourceTypes.h"
14 
15 class RtcClient;
21 namespace dpyRtc {
22 
25 {
26  std::uint32_t sync_time_seconds;
27  std::uint32_t max_diff_time_seconds;
28 };
29 
34 typedef boost::function<void(const bool &available)> service_availability_handler;
35 
40 typedef boost::function<void(boost::system::error_code& ec)> result_handler;
41 
47 typedef boost::function<void(boost::system::error_code& ec, dpyRtc::ParamConfig &)> params_handler;
48 
55 typedef boost::function<void(boost::system::error_code& ec, struct tm date_and_time)> time_and_date_handler;
56 
63 typedef boost::function<void(boost::system::error_code& ec, struct tm date_and_time,struct tm last_set_date_and_time)> time_date_set_handler;
64 
65 
75 typedef boost::function<void(boost::system::error_code& ec, struct tm date_and_time,struct tm last_set_date_and_time, struct tm sunrise_date_and_time, struct tm sunset_date_and_time, bool is_day)> time_date_set_daylight_handler;
81 typedef boost::function<void(boost::system::error_code& ec, std::map<std::string, dpyRtc::DateSources> sourceList)> sources_list_handler;
82 }
83 
89 class Rtc
90 {
91 private:
92  boost::shared_ptr<RtcClient> mClient;
93 public:
94 
99  explicit Rtc(std::string ip = "127.0.0.1");
100 
104  ~Rtc();
105  bool isAlive();
106  void monitorServiceAvailability_S(dpyRtc::service_availability_handler handler);
107  void monitorServiceAvailability_U();
113  void asyncSetSyncTime(std::uint32_t time_s, dpyRtc::result_handler handler);
114 
120  void asyncSetDiffTime(std::uint32_t time_s, dpyRtc::result_handler handler);
121 
127 
134 
140 
146 
152 
164  boost::system::error_code getDateTime(struct tm & date_and_time);
165 
177  boost::system::error_code getDateTime(struct tm & date_and_time,struct tm &last_set_date_and_time);
178 
193  boost::system::error_code getDateTime(struct tm & date_and_time,struct tm &last_set_date_and_time, struct tm &sunrise_date_and_time, struct tm &sunset_date_and_time, bool &is_day);
194 
201  void asyncAddNewSourceDate(const std::string& source_name, const dpyRtc::DateSources& source, dpyRtc::result_handler handler);
202 
208  void asyncDeleteSourceDate(const std::string& source_name, dpyRtc::result_handler handler);
209 
216  boost::system::error_code addNewSourceDate(const std::string& source_name, const dpyRtc::DateSources& source);
217 
223  boost::system::error_code deleteSourceDate(const std::string& source_name);
224 };
void asyncDeleteSourceDate(const std::string &source_name, dpyRtc::result_handler handler)
Delete a particular date source.
~Rtc()
Destructor of the class.
void asyncAddNewSourceDate(const std::string &source_name, const dpyRtc::DateSources &source, dpyRtc::result_handler handler)
Method used to add a date source.
boost::system::error_code getDateTime(struct tm &date_and_time)
Synchronous method to get date and time coming from RTC service.
Definition: dateSourceTypes.h:28
Parameters struct which contains the response received from the service.
Definition: rtcApi.h:24
void asyncGetDateTime(dpyRtc::time_and_date_handler handler)
Method to get date and time coming from RTC service.
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: rtcApi.h:34
boost::function< void(boost::system::error_code &ec, struct tm date_and_time, struct tm last_set_date_and_time, struct tm sunrise_date_and_time, struct tm sunset_date_and_time, bool is_day)> time_date_set_daylight_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:75
boost::function< void(boost::system::error_code &ec, struct tm date_and_time, struct tm last_set_date_and_time)> time_date_set_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:63
boost::function< void(boost::system::error_code &ec, struct tm date_and_time)> time_and_date_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:55
boost::function< void(boost::system::error_code &ec, dpyRtc::ParamConfig &)> params_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:47
void asyncSetSyncTime(std::uint32_t time_s, dpyRtc::result_handler handler)
Method to set synchronism time period in seconds.
void asyncSetDiffTime(std::uint32_t time_s, dpyRtc::result_handler handler)
Method to set maximum time in seconds allowed to RTC to be drifted from UTC valid time.
void asyncGetConfigValues(dpyRtc::params_handler handler)
Method to get configuration parameters coming from RTC service.
boost::function< void(boost::system::error_code &ec)> result_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:40
std::uint32_t sync_time_seconds
Synchronism time period in seconds.
Definition: rtcApi.h:26
boost::system::error_code addNewSourceDate(const std::string &source_name, const dpyRtc::DateSources &source)
Method used to add a date source.
boost::system::error_code deleteSourceDate(const std::string &source_name)
Delete a particular date source.
Deepsy Rtc namespace that includes the different enums, structs or method signatures that should be u...
Definition: rtcApi.h:15
boost::function< void(boost::system::error_code &ec, std::map< std::string, dpyRtc::DateSources > sourceList)> sources_list_handler
Prototype of the handler function for getting sources list.
Definition: rtcApi.h:81
void asyncGetSources(dpyRtc::sources_list_handler handler)
Method used to get a sources list.
Rtc(std::string ip="127.0.0.1")
Constructor of the class.
std::uint32_t max_diff_time_seconds
Maximum time in seconds allowed to RTC to be drifted from UTC valid time.
Definition: rtcApi.h:27
Interacts with RTC service.
Definition: rtcClient.h:16
Allows to interact with a RTC Service.
Definition: rtcApi.h:89