powermanagerApi.h
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <boost/function.hpp>
8 #include <boost/system/error_code.hpp>
9 #include <boost/shared_ptr.hpp>
10 #include <vector>
11 
12 #include "iPower.h"
13 
14 class PowerClient;
15 
21 class Power
22 {
23 
24 private:
25  boost::shared_ptr <PowerClient> mClient;
26 public:
27  explicit Power(std::string ip = "127.0.0.1");
28  virtual ~Power();
29 
31 #ifndef TESTING
32  bool isAlive();
33  void monitorServiceAvailability_S(dpyPowermanager::service_availability_handler handler);
34  void monitorServiceAvailability_U();
35  void asyncGetCurrentEvent(dpyPowermanager::event_handler_function handler);
36  void getPowerEvent_S(dpyPowermanager::event_handler_function handler, dpyPowermanager::ConfigType configuration);
37  void getPowerEvent_U();
38  void asyncShutdownRequest(dpyPowermanager::answer_pm_handler_function handler);
39  void asyncRebootRequest(dpyPowermanager::answer_pm_handler_function handler);
40  void asyncStandbyRequest(dpyPowermanager::answer_pm_handler_function handler);
41  void asyncAbortRequest(dpyPowermanager::answer_pm_handler_function handler);
42  void asyncCheckPowerRailsStatus(dpyPowermanager::power_rails_handler_function);
43  void asyncCriticalBatteryRequest(dpyPowermanager::answer_pm_handler_function handler);
44  void asyncSetDebugMode(dpyPowermanager::answer_pm_handler_function handler, bool debug);
45  void asyncGetDebugMode(dpyPowermanager::debug_pm_handler_function handler);
46  void asyncSetTimers(dpyPowermanager::answer_pm_handler_function handler, std::uint32_t standbyTimer, std::uint32_t haltTimer);
47  void asyncGetTimers(dpyPowermanager::timers_pm_handler_function handler);
48  void asyncSetStateWakeupTimers(dpyPowermanager::answer_pm_handler_function handler, bool standbyEnabled, bool haltEnabled);
49  void asyncGetStateWakeupTimers(dpyPowermanager::timers_state_pm_handler_function handler);
50  void asyncSetTransitionIntervals(dpyPowermanager::answer_pm_handler_function handler, std::uint32_t cancelTime, std::uint32_t guardTime);
51  void asyncGetTransitionIntervals(dpyPowermanager::transition_intervals_pm_handler_function handler);
52  void asyncSetWakeupTime(dpyPowermanager::answer_pm_handler_function handler, struct tm &wakeupTime, bool localTime);
53  void asyncGetWakeupTime(dpyPowermanager::wakeup_time_pm_handler_function handler);
54  void asyncSetIgnitionOffTimeout(dpyPowermanager::answer_pm_handler_function handler, int minutes);
55  void asyncGetIgnitionOffTimeout(dpyPowermanager::ignition_off_timeout_pm_handler_function handler);
56  void asyncCancelIgnitionOffTimeout(dpyPowermanager::answer_pm_handler_function handler);
57 
58 #else
59  virtual bool isAlive();
60  virtual void monitorServiceAvailability_S(dpyPowermanager::service_availability_handler handler);
61  virtual void monitorServiceAvailability_U();
62  virtual void asyncGetCurrentEvent(dpyPowermanager::event_handler_function handler);
63  virtual void getPowerEvent_S(dpyPowermanager::event_handler_function handler, dpyPowermanager::ConfigType configuration);
64  virtual void getPowerEvent_U();
65  virtual void asyncShutdownRequest(dpyPowermanager::answer_pm_handler_function handler);
66  virtual void asyncRebootRequest(dpyPowermanager::answer_pm_handler_function handler);
67  virtual void asyncStandbyRequest(dpyPowermanager::answer_pm_handler_function handler);
68  virtual void asyncAbortRequest(dpyPowermanager::answer_pm_handler_function handler);
69  virtual void asyncCheckPowerRailsStatus(dpyPowermanager::power_rails_handler_function);
70  virtual void asyncCriticalBatteryRequest(dpyPowermanager::answer_pm_handler_function handler);
71  virtual void asyncSetDebugMode(dpyPowermanager::answer_pm_handler_function handler, bool debug);
72  virtual void asyncGetDebugMode(dpyPowermanager::debug_pm_handler_function handler);
73  virtual void asyncSetTimers(dpyPowermanager::answer_pm_handler_function handler, std::uint32_t standbyTimer, std::uint32_t haltTimer);
74  virtual void asyncGetTimers(dpyPowermanager::timers_pm_handler_function handler);
75  virtual void asyncSetTransitionIntervals(dpyPowermanager::answer_pm_handler_function handler, std::uint32_t cancelTime, std::uint32_t guardTime);
76  virtual void asyncGetTransitionIntervals(dpyPowermanager::transition_intervals_pm_handler_function handler);
77 #endif
78 };
ConfigType
An enum definition which represents the different types of messages that it is wanted to be subscribe...
Definition: iPower.h:72
boost::function< void(boost::system::error_code &ec, dpyPowermanager::TransitionIntervals)> transition_intervals_pm_handler_function
Transition Intervals handler function.
Definition: iPower.h:148
Class which interfaces with the API logic.
Definition: powermanagerApi.h:21
bool isAlive()
This class allows to interact with the Power Manager Service.
Definition: powermanagerClient.h:15
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: iPower.h:23
boost::function< void(boost::system::error_code &ec)> answer_pm_handler_function
Answer handler function.
Definition: iPower.h:144
boost::function< void(boost::system::error_code &ec, dpyPowermanager::PowerEvent event)> event_handler_function
Handlers to the functions the client has to implement.
Definition: iPower.h:142
boost::function< void(boost::system::error_code &ec, dpyPowermanager::Timers)> timers_pm_handler_function
Timers handler function.
Definition: iPower.h:145
boost::function< void(boost::system::error_code &ec, bool standbyEnabled, bool haltEnabled)> timers_state_pm_handler_function
Timers State handler function.
Definition: iPower.h:147
boost::function< void(boost::system::error_code &ec, bool rightConfiguration)> power_rails_handler_function
Power Rails handler function.
Definition: iPower.h:146
boost::function< void(boost::system::error_code &ec, struct tm dateTime)> wakeup_time_pm_handler_function
Wakeup Time handler function.
Definition: iPower.h:149
boost::function< void(boost::system::error_code ec, bool active)> debug_pm_handler_function
Debug handler to check if the debug is active or not.
Definition: iPower.h:143
boost::function< void(boost::system::error_code &ec, int minutes)> ignition_off_timeout_pm_handler_function
Ignition Off Timeout handler function.
Definition: iPower.h:150