mcuApi.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 
12 #include "mcuTypes.h"
13 #include "firmware.h"
14 
15 class McuClient;
16 
22 namespace dpyMcu {
28 
32 {
33  RED = 1,
34  BLUE = 2,
35  GREEN = 3,
36  MAGENTA = 4,
37  YELLOW = 5,
38  CYAN = 6,
39  UNDEFINED = 7
40 };
41 
44 {
45  N_A = 1,
46  POWER_ON = 2,
47  REBOOT = 3,
48  STANDBY = 4,
49  HALT = 5,
50  ABORT = 6,
52 };
53 
55  GPI1 = 1,
56  GPI2 = 2,
57  GPI3 = 3,
58  GPI4 = 4,
59  GPI5 = 5,
60  GPI6 = 6,
61  GPI7 = 7,
62  GPI8 = 8,
63  BUTTON1 = 9,
64  BUTTON2 = 10,
65  BUTTON3 = 11,
66  BUTTON4 = 12,
67  BUTTON5 = 13,
68  BUTTON6 = 14,
69  BUTTON7 = 15,
70  BUTTON8 = 16,
71  POWER_BUTTON = 17,
72  ODO = 18,
73  ODO_REDU = 19,
74  GPO1 = 21,
75  GPO2 = 22,
76  GPO3 = 23,
77  GPO4 = 24,
78  GPO5 = 25,
79  GPO6 = 26,
80  GPO7 = 27,
81  GPO8 = 28
82 };
83 
85 enum Result {
86  OK = 0,
87  ERROR = 1
88 };
90 
96 struct LedsConfig
99 {
100  std::string timestamp;
102  std::uint32_t period;
103  std::uint32_t duty_cycle;
104 };
105 
108 {
109  std::string timestamp;
110  std::uint32_t gpio;
111  bool value;
112 };
113 
115 struct I2CValue
116 {
117  int bus;
118  int device;
119  std::list<int> address;
120  std::list<int> values;
121 };
122 
125 {
126  std::string timestamp;
127  std::string partition_written;
128 };
129 
132 {
133  std::string timestamp;
134  bool ignition;
138  std::int32_t temperature;
139  bool fault;
141 };
142 
145 {
146  std::string timestamp;
148  std::uint32_t event_flags;
150 };
151 
154 {
155  std::string timestamp;
156  std::uint32_t timer_standby_minutes;
157  std::uint32_t timer_halt_minutes;
158 };
159 
162 {
163  std::string timestamp;
164  std::string part_number;
165  std::string serial_number;
166  std::string cidl_number;
167 };
168 
171 {
172  std::list<struct GUIDConfig> guids;
173 };
174 
177 {
178  std::string timestamp;
179  std::uint32_t power_on_hours_working;
180  std::uint32_t standby_hours_working;
181  std::uint32_t halt_hours_working;
182 };
183 
185 struct MCUStatus
186 {
187  std::string timestamp;
188  std::uint32_t hardware_exceptions;
189  std::uint32_t software_exceptions;
190 };
191 
194 {
195  std::string timestamp;
196  float idle_voltage;
199  std::uint32_t grace_period_minutes;
200 };
201 
204 {
205  std::string timestamp;
206  std::uint32_t seconds;
207  std::uint32_t minutes;
208  std::uint32_t hours;
209  std::uint32_t day;
210  std::uint32_t month;
211  std::uint32_t year;
212 };
214 
219 typedef boost::function<void(const bool &available)> service_availability_handler;
220 
226 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::PowerInformationConfig &)> power_mng_handler_function;
232 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::LedsConfig &)> leds_handler_function;
238 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::PowerStateConfig &)> power_states_handler_function;
244 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::TimersConfig &)> timers_handler_function;
250 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::UpdateConfig &)> update_firmware_handler_function;
256 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::GUIDConfigList &)> guid_handler_function;
263 typedef boost::function<void(boost::system::error_code error_code, char &, char &)> eqvar_handler_function;
269 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::WorkingTimeConfig &)> working_time_handler_function;
275 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::MCUStatus &)> mcu_status_handler_function;
281 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::BatteryProtectionConfig &)> battery_protection_handler_function;
287 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::DateConfig &)> rtc_date_handler_function;
293 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::GpioConfig &)> gpio_handler_function;
299 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::GpiosAvailable &)> gpios_events_handler_function;
305 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::I2CValue &)> i2c_handler_function;
311 typedef boost::function<void(boost::system::error_code error_code, const dpyFirmware::FirmwareVersionInfo& fw_version)> version_handler_function;
317 typedef boost::function<void(boost::system::error_code error_code, dpyMcu::CanStatusEvent &)> can_status_handler_function;
318 
323 typedef boost::function<void(boost::system::error_code error_code)> test_misc_handler_function;
324 
329 typedef boost::function<void(boost::system::error_code error_code)> set_power_button_state_handler_function;
330 
336 typedef boost::function<void(boost::system::error_code error_code, bool enabled)> get_power_button_state_handler_function;
337 
342 typedef boost::function<void(boost::system::error_code error_code)> result_handler_function;
343 
344 }
345 
351 class Mcu
352 {
353 protected:
357  boost::shared_ptr<McuClient> mClient;
358 public:
363  explicit Mcu(std::string ip = "127.0.0.1");
364 
368  virtual ~Mcu();
369 
371 #ifndef TESTING
372 
376  bool isAlive();
377 
378  void monitorServiceAvailability_S(dpyMcu::service_availability_handler handler);
379  void monitorServiceAvailability_U();
380 
385  void asyncGetLedsConfig(dpyMcu::leds_handler_function handler);
386 
394  void asyncSetLedsConfig(dpyMcu::leds_handler_function handler, dpyMcu::LedsColor color, std::uint32_t period, std::uint32_t duty_cycle);
395 
407  void asyncSetBatteryProtectionConfig(dpyMcu::battery_protection_handler_function handler, float idle_voltage, float voltage_percentage_threshold,
408  float hysteresis_percentage, std::uint32_t grace_period_minutes);
409 
414  void asyncGetBatteryProtectionConfig(dpyMcu::battery_protection_handler_function handler);
415 
420  void asyncGetRtcDateConfig(dpyMcu::rtc_date_handler_function handler);
421 
427  boost::system::error_code getRtcDateConfig(dpyMcu::DateConfig & config);
428 
433  void asyncGetTimersConfig(dpyMcu::timers_handler_function handler);
434 
439  void asyncUpdateMCU(dpyMcu::update_firmware_handler_function handler);
440 
445  void asyncGetGUIDValues(dpyMcu::guid_handler_function handler);
446 
452  virtual boost::system::error_code getGUIDValues( dpyMcu::GUIDConfigList &guid_list);
453 
454 
459  void asyncGetEQVar(dpyMcu::eqvar_handler_function handler);
460 
467  virtual boost::system::error_code getEQVar(char &eq_id, char &var_id);
468 
473  void asyncGetWorkingTimeValues(dpyMcu::working_time_handler_function handler);
474 
479  void asyncGetMCUStatus(dpyMcu::mcu_status_handler_function handler);
480 
485  void getPowerInformation_S(dpyMcu::power_mng_handler_function handler);
486 
491  void asyncGetPowerInformation(dpyMcu::power_mng_handler_function handler);
492 
498  void asyncGetGpioValue(dpyMcu::gpio_handler_function handler, std::uint32_t gpio_number);
499 
506  void asyncSetGpioValue(dpyMcu::gpio_handler_function handler, std::uint32_t gpio_number, bool gpio_value);
507 
512  void asyncGetGpiosEvents(dpyMcu::gpios_events_handler_function handler);
513 
522  void asyncGetI2CValue(dpyMcu::i2c_handler_function handler, unsigned char busid, unsigned char deviceid, std::list<unsigned char> address, int lenght);
523 
533  void asyncSetI2CValue(dpyMcu::i2c_handler_function handler, unsigned char busid, unsigned char deviceid, std::list<unsigned char> address, std::list<unsigned char> values);
534 
540  void asyncGetVersion(dpyMcu::version_handler_function handler, dpyFirmware::Rfs rfs);
541 
545  void getPowerInformation_U();
546 
547 
558  boost::system::error_code setI2CValue(unsigned char busid, unsigned char deviceid, std::list<unsigned char> address, std::list<unsigned char> values,dpyMcu::I2CValue& result);
559 
570  boost::system::error_code getI2CValue(unsigned char busid, unsigned char deviceid, std::list<unsigned char> address, int length,dpyMcu::I2CValue& result);
571 
576  void asyncGetCanStatus(dpyMcu::can_status_handler_function handler);
577 
578 
579 #else
580  virtual bool isAlive();
581  virtual void asyncGetLedsConfig(dpyMcu::leds_handler_function handler);
582  virtual void asyncSetLedsConfig(dpyMcu::leds_handler_function handler, dpyMcu::LedsColor color, std::uint32_t period, std::uint32_t duty_cycle);
583  virtual void asyncSetBatteryProtectionConfig(dpyMcu::battery_protection_handler_function handler, float idle_voltage, float voltage_percentage_threshold, float hysteresis_percentage, std::uint32_t grace_period_minutes);
584  virtual void asyncGetBatteryProtectionConfig(dpyMcu::battery_protection_handler_function handler);
585  virtual void asyncGetRtcDateConfig(dpyMcu::rtc_date_handler_function handler);
586  virtual boost::system::error_code getRtcDateConfig(dpyMcu::DateConfig & config);
587  virtual void asyncGetTimersConfig(dpyMcu::timers_handler_function handler);
588  virtual void asyncUpdateMCU(dpyMcu::update_firmware_handler_function handler);
589  virtual void asyncGetGUIDValues(dpyMcu::guid_handler_function handler);
590  virtual boost::system::error_code getGUIDValues( dpyMcu::GUIDConfigList &guid_list);
591  virtual void asyncGetEQVar(dpyMcu::eqvar_handler_function handler);
592  virtual boost::system::error_code getEQVar(char &eq_id, char &var_id);
593  virtual void asyncGetWorkingTimeValues(dpyMcu::working_time_handler_function handler);
594  virtual void asyncGetMCUStatus(dpyMcu::mcu_status_handler_function handler);
595  virtual void getPowerInformation_S(dpyMcu::power_mng_handler_function handler);
596  virtual void asyncGetPowerInformation(dpyMcu::power_mng_handler_function handler);
597  virtual void asyncGetGpioValue(dpyMcu::gpio_handler_function handler, std::uint32_t gpio_number);
598  virtual void asyncSetGpioValue(dpyMcu::gpio_handler_function handler, std::uint32_t gpio_number, bool gpio_value);
599  virtual void asyncGetGpiosEvents(dpyMcu::gpios_events_handler_function handler);
600  virtual void asyncGetVersion(dpyMcu::version_handler_function handler, dpyFirmware::Rfs rfs);
601  virtual void getPowerInformation_U();
602  virtual boost::system::error_code setI2CValue(unsigned char busid, unsigned char deviceid, std::list<unsigned char> address, std::list<unsigned char> values,dpyMcu::I2CValue& value);
603  virtual boost::system::error_code getI2CValue(unsigned char busid, unsigned char deviceid, std::list<unsigned char> address, int lenght,dpyMcu::I2CValue& value);
604 
605 #endif
606 };
boost::function< void(boost::system::error_code error_code)> result_handler_function
Prototype of the handler function for obtaining the result of the operations status.
Definition: mcuApi.h:342
ODO.
Definition: mcuApi.h:72
GPO8.
Definition: mcuApi.h:81
BUTTON3.
Definition: mcuApi.h:65
std::string timestamp
timestamp
Definition: mcuApi.h:195
int bus
bus
Definition: mcuApi.h:117
I2C Struct which contains the response received from the service.
Definition: mcuApi.h:115
std::string serial_number
Serial Number of the equipment.
Definition: mcuApi.h:165
PowerInformation struct which contains the response received from the service.
Definition: mcuApi.h:144
std::string timestamp
timestamp
Definition: mcuApi.h:205
float battery_inner_percent
battery inner percent
Definition: mcuApi.h:136
std::uint32_t hardware_exceptions
Hardware exceptions.
Definition: mcuApi.h:188
std::string timestamp
timestamp
Definition: mcuApi.h:146
BUTTON8.
Definition: mcuApi.h:70
boost::function< void(boost::system::error_code error_code, dpyMcu::TimersConfig &)> timers_handler_function
Prototype of the handler function for obtaining the Timers Configuration.
Definition: mcuApi.h:244
UNDEFINED.
Definition: mcuApi.h:39
Power On.
Definition: mcuApi.h:46
std::uint32_t year
year
Definition: mcuApi.h:211
MAGENTA.
Definition: mcuApi.h:36
std::uint32_t period
Period in seconds (range: 0 - 10)
Definition: mcuApi.h:102
std::uint32_t software_exceptions
Software exceptions.
Definition: mcuApi.h:189
GUID struct which contains the response received from the service.
Definition: mcuApi.h:161
DateConfig struct which contains the response received from the service.
Definition: mcuApi.h:203
GPI2.
Definition: mcuApi.h:56
Class with the logic of the client.
Definition: mcuClient.h:26
Standby.
Definition: mcuApi.h:48
GpiosAvailable
Possible color to be set.
Definition: mcuApi.h:54
boost::function< void(boost::system::error_code error_code, dpyMcu::MCUStatus &)> mcu_status_handler_function
Prototype of the handler function for obtaining the MCU Status.
Definition: mcuApi.h:275
Working Time struct which contains the response received from the service.
Definition: mcuApi.h:176
int device
device
Definition: mcuApi.h:118
PowerStates power_state
power_state
Definition: mcuApi.h:147
boost::function< void(boost::system::error_code error_code, const dpyFirmware::FirmwareVersionInfo &fw_version)> version_handler_function
Prototype of the handler function for obtaining the fw version.
Definition: mcuApi.h:311
std::uint32_t timer_halt_minutes
Halt Timer.
Definition: mcuApi.h:157
std::string part_number
Part Number of the equipment.
Definition: mcuApi.h:164
std::uint32_t timer_standby_minutes
Standby Timer.
Definition: mcuApi.h:156
std::string timestamp
timestamp
Definition: mcuApi.h:155
std::string timestamp
timestamp
Definition: mcuApi.h:187
std::string timestamp
timestamp
Definition: mcuApi.h:163
boost::function< void(boost::system::error_code error_code, dpyMcu::GpioConfig &)> gpio_handler_function
Prototype of the handler function for obtaining the GPIO Configuration.
Definition: mcuApi.h:293
Halt.
Definition: mcuApi.h:49
Class which interfaces with the API logic.
Definition: mcuApi.h:351
std::string timestamp
timestamp
Definition: mcuApi.h:133
BUTTON7.
Definition: mcuApi.h:69
std::uint32_t grace_period_minutes
grace period in minutes used to enter in halt mode irrevocably
Definition: mcuApi.h:199
Battery Protection Config struct which contains the response received from the service.
Definition: mcuApi.h:193
BLUE.
Definition: mcuApi.h:34
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: mcuApi.h:219
BUTTON4.
Definition: mcuApi.h:66
GPI6.
Definition: mcuApi.h:60
std::string partition_written
partition_written
Definition: mcuApi.h:127
BUTTON5.
Definition: mcuApi.h:67
RED.
Definition: mcuApi.h:33
std::uint32_t duty_cycle
duty_cycle in percentage (range: 0% - 100%)
Definition: mcuApi.h:103
GPO6.
Definition: mcuApi.h:79
float voltage_percentage_over_idle_voltage_threshold
voltage percentage threshold calculated over idle voltage
Definition: mcuApi.h:197
GPI7.
Definition: mcuApi.h:61
BUTTON1.
Definition: mcuApi.h:63
Result result
result
Definition: mcuApi.h:149
Defines a class for checking firmware binaries available for upgrading.
Rfs
Defines the possible root file systems where binaries are located.
Definition: firmware.h:54
std::uint32_t day
day
Definition: mcuApi.h:209
GPI3.
Definition: mcuApi.h:57
boost::function< void(boost::system::error_code error_code, dpyMcu::CanStatusEvent &)> can_status_handler_function
Prototype of the handler function for obtaining the CAN Status Information.
Definition: mcuApi.h:317
std::uint32_t power_on_hours_working
Power-On hours working.
Definition: mcuApi.h:179
std::uint32_t seconds
seconds
Definition: mcuApi.h:206
MCU Status struct which contains the response received from the service.
Definition: mcuApi.h:185
boost::function< void(boost::system::error_code error_code, dpyMcu::WorkingTimeConfig &)> working_time_handler_function
Prototype of the handler function for obtaining the Working Time Values.
Definition: mcuApi.h:269
Deepsy Mcu namespace that includes the different enums, structs or method signatures that should be u...
Definition: mcuApi.h:15
bool fault
fault
Definition: mcuApi.h:139
GPO4.
Definition: mcuApi.h:77
OK.
Definition: mcuApi.h:86
boost::function< void(boost::system::error_code error_code, dpyMcu::GpiosAvailable &)> gpios_events_handler_function
Prototype of the handler function for obtaining the GPIO Events.
Definition: mcuApi.h:299
GPI5.
Definition: mcuApi.h:59
GPO1.
Definition: mcuApi.h:74
Abort.
Definition: mcuApi.h:50
boost::function< void(boost::system::error_code error_code, bool enabled)> get_power_button_state_handler_function
Prototype of the handler function for obtaining the result of power button.
Definition: mcuApi.h:336
GPO7.
Definition: mcuApi.h:80
boost::function< void(boost::system::error_code error_code, dpyMcu::I2CValue &)> i2c_handler_function
Prototype of the handler function for obtaining the I2C information.
Definition: mcuApi.h:305
std::uint32_t minutes
minutes
Definition: mcuApi.h:207
BUTTON6.
Definition: mcuApi.h:68
PowerInformation struct which contains the response received from the service.
Definition: mcuApi.h:131
std::string timestamp
timestamp
Definition: mcuApi.h:100
GPI4.
Definition: mcuApi.h:58
Update struct which contains the response received from the service.
Definition: mcuApi.h:124
Timers struct which contains the response received from the service.
Definition: mcuApi.h:153
std::string timestamp
timestamp
Definition: mcuApi.h:178
std::list< int > values
i2c values
Definition: mcuApi.h:120
boost::function< void(boost::system::error_code error_code, dpyMcu::GUIDConfigList &)> guid_handler_function
Prototype of the handler function for obtaining the GUIDs.
Definition: mcuApi.h:256
bool battery_protection_mode
battery protection mode
Definition: mcuApi.h:140
boost::function< void(boost::system::error_code error_code)> set_power_button_state_handler_function
Prototype of the handler function for obtaining the result of power button.
Definition: mcuApi.h:329
Not Available.
Definition: mcuApi.h:45
boost::function< void(boost::system::error_code error_code, dpyMcu::UpdateConfig &)> update_firmware_handler_function
Prototype of the handler function for obtaining the updated configuration.
Definition: mcuApi.h:250
std::string timestamp
timestamp
Definition: mcuApi.h:109
GPO3.
Definition: mcuApi.h:76
float hysteresis_percentage_over_idle_voltage
hysteresis percentage calculated over idle voltage
Definition: mcuApi.h:198
BUTTON2.
Definition: mcuApi.h:64
boost::function< void(boost::system::error_code error_code, dpyMcu::BatteryProtectionConfig &)> battery_protection_handler_function
Prototype of the handler function for obtaining the Battery Protection Configuration.
Definition: mcuApi.h:281
Result
Possible received result.
Definition: mcuApi.h:85
Definition: mcuApi.h:98
boost::function< void(boost::system::error_code error_code, dpyMcu::DateConfig &)> rtc_date_handler_function
Prototype of the handler function for obtaining the RTC Date Configuration.
Definition: mcuApi.h:287
YELLOW.
Definition: mcuApi.h:37
boost::function< void(boost::system::error_code error_code, dpyMcu::PowerStateConfig &)> power_states_handler_function
Prototype of the handler function for obtaining the Power State Configuration.
Definition: mcuApi.h:238
std::list< int > address
memory address
Definition: mcuApi.h:119
float battery_extern_voltage
battery extern voltage
Definition: mcuApi.h:135
float idle_voltage
idle voltage identified by ignition position off, engine off and stationary vehicle ...
Definition: mcuApi.h:196
bool value
GPIO value (values: 0 or 1)
Definition: mcuApi.h:111
Critical battery.
Definition: mcuApi.h:51
POWER_BUTTON.
Definition: mcuApi.h:71
bool battery_type
battery type: 1 –> 24V, 0 –> 12V
Definition: mcuApi.h:137
LedsColor color
state
Definition: mcuApi.h:101
GREEN.
Definition: mcuApi.h:35
GUID list struct which contains the response received from the service.
Definition: mcuApi.h:170
bool ignition
ignition
Definition: mcuApi.h:134
PowerStates
Possible power state to be set.
Definition: mcuApi.h:43
std::list< struct GUIDConfig > guids
GUIDs elements.
Definition: mcuApi.h:172
std::string cidl_number
CIDL Number of the equipment.
Definition: mcuApi.h:166
std::uint32_t standby_hours_working
Standby hours working.
Definition: mcuApi.h:180
ERROR.
Definition: mcuApi.h:87
std::int32_t temperature
temperature
Definition: mcuApi.h:138
GPO2.
Definition: mcuApi.h:75
GPO5.
Definition: mcuApi.h:78
std::uint32_t halt_hours_working
Halt hours working.
Definition: mcuApi.h:181
boost::function< void(boost::system::error_code error_code)> test_misc_handler_function
Prototype of the handler function for obtaining the current MISC status.
Definition: mcuApi.h:323
ODO_REDU.
Definition: mcuApi.h:73
std::uint32_t gpio
GPIOs values (values: 1 - 4)
Definition: mcuApi.h:110
std::uint32_t hours
hours
Definition: mcuApi.h:208
std::uint32_t event_flags
set flags to enter in power state
Definition: mcuApi.h:148
boost::function< void(boost::system::error_code error_code, char &, char &)> eqvar_handler_function
Prototype of the handler function for obtaining the GUIDs.
Definition: mcuApi.h:263
CYAN.
Definition: mcuApi.h:38
boost::function< void(boost::system::error_code error_code, dpyMcu::LedsConfig &)> leds_handler_function
Prototype of the handler function for obtaining the LEDs configuration.
Definition: mcuApi.h:232
GPI8.
Definition: mcuApi.h:62
Reboot.
Definition: mcuApi.h:47
std::uint32_t month
month
Definition: mcuApi.h:210
boost::shared_ptr< McuClient > mClient
Reference to an Client Object.
Definition: mcuApi.h:357
std::string timestamp
timestamp
Definition: mcuApi.h:126
GPIO Struct which contains the response received from the service.
Definition: mcuApi.h:107
boost::function< void(boost::system::error_code error_code, dpyMcu::PowerInformationConfig &)> power_mng_handler_function
Prototype of the handler function for obtaining the Power Information.
Definition: mcuApi.h:226
LedsColor
Possible color to be set.
Definition: mcuApi.h:31
GPI1.
Definition: mcuApi.h:55