Class which interfaces with the API logic.

#include <mcuApi.h>

Inheritance diagram for Mcu:

Public Member Functions

 Mcu (std::string ip="127.0.0.1")
 Constructor of the class. More...
 
virtual ~Mcu ()
 Destructor of the class.
 
bool isAlive ()
 Method to check if MCU Service is Alive. More...
 
void monitorServiceAvailability_S (dpyMcu::service_availability_handler handler)
 
void monitorServiceAvailability_U ()
 
void asyncGetLedsConfig (dpyMcu::leds_handler_function handler)
 Method which requests the LED color state. More...
 
void asyncSetLedsConfig (dpyMcu::leds_handler_function handler, dpyMcu::LedsColor color, std::uint32_t period, std::uint32_t duty_cycle)
 Method which requests to change the LED color state. More...
 
void asyncSetBatteryProtectionConfig (dpyMcu::battery_protection_handler_function handler, float idle_voltage, float voltage_percentage_threshold, float hysteresis_percentage, std::uint32_t grace_period_minutes)
 Method which requests to set battery protection configuration values. More...
 
void asyncGetBatteryProtectionConfig (dpyMcu::battery_protection_handler_function handler)
 Method which requests to get battery protection configuration values. More...
 
void asyncGetRtcDateConfig (dpyMcu::rtc_date_handler_function handler)
 Method which requests to get RTC date configuration values. More...
 
boost::system::error_code getRtcDateConfig (dpyMcu::DateConfig &config)
 Method which requests to get RTC date configuration values. More...
 
void asyncGetTimersConfig (dpyMcu::timers_handler_function handler)
 Method which requests one message with Standby and Halt Timers. More...
 
void asyncUpdateMCU (dpyMcu::update_firmware_handler_function handler)
 Method which updates the firmware of the MCU (the new image must be in the right PATH of the system) More...
 
void asyncGetGUIDValues (dpyMcu::guid_handler_function handler)
 Method which requests one message with Part Number, Serial Number and CIDL of the equipment. More...
 
virtual boost::system::error_code getGUIDValues (dpyMcu::GUIDConfigList &guid_list)
 Method which requests to get GUID values. More...
 
void asyncGetEQVar (dpyMcu::eqvar_handler_function handler)
 Method which requests to get EQ/Var values. More...
 
virtual boost::system::error_code getEQVar (char &eq_id, char &var_id)
 Method which requests to get EQ/Var values. More...
 
void asyncGetWorkingTimeValues (dpyMcu::working_time_handler_function handler)
 Method which requests one message with the Power-On, Standby and Halt States working hours. More...
 
void asyncGetMCUStatus (dpyMcu::mcu_status_handler_function handler)
 Method which gets one message indicating hardware and software exceptions coming from MCU. More...
 
void getPowerInformation_S (dpyMcu::power_mng_handler_function handler)
 Method which receives one message with Power information coming from the service periodically. More...
 
void asyncGetPowerInformation (dpyMcu::power_mng_handler_function handler)
 Method which requests one message with Power information coming from the service periodically. More...
 
void asyncGetGpioValue (dpyMcu::gpio_handler_function handler, std::uint32_t gpio_number)
 Method which requests one message with GPIO information. More...
 
void asyncSetGpioValue (dpyMcu::gpio_handler_function handler, std::uint32_t gpio_number, bool gpio_value)
 Method which requests to set a GPIO pin with a value. More...
 
void asyncGetGpiosEvents (dpyMcu::gpios_events_handler_function handler)
 Method which receives one message with Gpios events coming from the service. More...
 
void asyncGetI2CValue (dpyMcu::i2c_handler_function handler, unsigned char busid, unsigned char deviceid, std::list< unsigned char > address, int lenght)
 Method which requests one message with I2C information. More...
 
void asyncSetI2CValue (dpyMcu::i2c_handler_function handler, unsigned char busid, unsigned char deviceid, std::list< unsigned char > address, std::list< unsigned char > values)
 Method which requests to set a I2C address pin with a value. More...
 
void asyncGetVersion (dpyMcu::version_handler_function handler, dpyFirmware::Rfs rfs)
 Method which requests the firware version of the MCU. More...
 
void getPowerInformation_U ()
 Method to stop receiving Power information coming from the service periodically.
 
boost::system::error_code setI2CValue (unsigned char busid, unsigned char deviceid, std::list< unsigned char > address, std::list< unsigned char > values, dpyMcu::I2CValue &result)
 (Sync) Method which requests to set a I2C address pin with a value More...
 
boost::system::error_code getI2CValue (unsigned char busid, unsigned char deviceid, std::list< unsigned char > address, int length, dpyMcu::I2CValue &result)
 (Sync) Method which requests one message with I2C information More...
 
void asyncGetCanStatus (dpyMcu::can_status_handler_function handler)
 Method to get the current CAN Bus status. More...
 

Protected Attributes

boost::shared_ptr< McuClientmClient
 Reference to an Client Object.
 

Constructor & Destructor Documentation

Mcu ( std::string  ip = "127.0.0.1")
explicit
Parameters
ipIP address to be binded to the App

Member Function Documentation

void asyncGetBatteryProtectionConfig ( dpyMcu::battery_protection_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetCanStatus ( dpyMcu::can_status_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetEQVar ( dpyMcu::eqvar_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetGpiosEvents ( dpyMcu::gpios_events_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetGpioValue ( dpyMcu::gpio_handler_function  handler,
std::uint32_t  gpio_number 
)
Parameters
handlerHandler to be called when a response comes from the service
gpio_numberGPIO Number (Possible values are 1, 2, 3 or 4)
void asyncGetGUIDValues ( dpyMcu::guid_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetI2CValue ( dpyMcu::i2c_handler_function  handler,
unsigned char  busid,
unsigned char  deviceid,
std::list< unsigned char >  address,
int  lenght 
)
Parameters
handlerHandler to be called when a response comes from the service
busidbus address
deviceiddevice address
addressmemory address
lenghtnumber of bytes to read
void asyncGetLedsConfig ( dpyMcu::leds_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetMCUStatus ( dpyMcu::mcu_status_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetPowerInformation ( dpyMcu::power_mng_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetRtcDateConfig ( dpyMcu::rtc_date_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetTimersConfig ( dpyMcu::timers_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncGetVersion ( dpyMcu::version_handler_function  handler,
dpyFirmware::Rfs  rfs 
)
Parameters
handlerHandler to be called when a response comes from the service
rfschosen to obtain the fw version installed (Possible values are "current" or "alternative")
void asyncGetWorkingTimeValues ( dpyMcu::working_time_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
void asyncSetBatteryProtectionConfig ( dpyMcu::battery_protection_handler_function  handler,
float  idle_voltage,
float  voltage_percentage_threshold,
float  hysteresis_percentage,
std::uint32_t  grace_period_minutes 
)
Parameters
handlerHandler to be called when a response comes from the service
idle_voltageidle voltage identified by ignition position off, engine off and stationary vehicle range: 0 - 40). Setting this value to 0 disables battery protection mode
voltage_percentage_thresholdvoltage percentage calculated over idle voltage to set voltage battery protection mode threshold (range: 80 - 100)
hysteresis_percentagehysteresis percentage calculated over idle voltage to enter and exit in battery protection mode (range: 0 - 100)
grace_period_minutesgrace period in minutes used to enter in halt mode irrevocably (range: 1 - 10)
Remarks
NOTE: With these values a low and a high threshold will be used to detect battery protection according next formula: – low_voltage_threshold = (idle_voltage * voltage_percentage / 100) - (idle_voltage * hysteresis_percentage / 100) – high_voltage_threshold = (idle_voltage * voltage_percentage / 100) + (idle_voltage * hysteresis_percentage / 100)
void asyncSetGpioValue ( dpyMcu::gpio_handler_function  handler,
std::uint32_t  gpio_number,
bool  gpio_value 
)
Parameters
handlerHandler to be called when a response comes from the service
gpio_numberGPIO number (Possible values are 1, 2, 3 or 4)
gpio_valueGPIO value (Possible values are 1 or 0)
void asyncSetI2CValue ( dpyMcu::i2c_handler_function  handler,
unsigned char  busid,
unsigned char  deviceid,
std::list< unsigned char >  address,
std::list< unsigned char >  values 
)
Parameters
handlerHandler to be called when a response comes from the service
busidbus address
deviceiddevice address
addressmemory address. It's just ONE value. If you provide several values they will be concatenated to generate only ONE address. E.g. If you provide 0x10 0x20 0x30, it will produce a 0x102030 final address
valuesvalues to be set
void asyncSetLedsConfig ( dpyMcu::leds_handler_function  handler,
dpyMcu::LedsColor  color,
std::uint32_t  period,
std::uint32_t  duty_cycle 
)
Parameters
handlerHandler to be called when a response comes from the service
colorto be set
periodperiodic time to be set in seconds (range: 0 - 40)
duty_cycleduty cycle to be set in percentage (range: 1 - 100)
void asyncUpdateMCU ( dpyMcu::update_firmware_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
virtual boost::system::error_code getEQVar ( char &  eq_id,
char &  var_id 
)
virtual
Parameters
eq_idequipment identifier
var_idvarian identifier
Returns
error code
virtual boost::system::error_code getGUIDValues ( dpyMcu::GUIDConfigList guid_list)
virtual
Parameters
guid_liststruct containing Part Number, Serial Number and CIDL of the equipment
Returns
error code
boost::system::error_code getI2CValue ( unsigned char  busid,
unsigned char  deviceid,
std::list< unsigned char >  address,
int  length,
dpyMcu::I2CValue result 
)
Parameters
busidbus address
deviceiddevice address
addressmemory address
lengthnumber of bytes to read
resultI2C structure to be filled with the response
Returns
error code
void getPowerInformation_S ( dpyMcu::power_mng_handler_function  handler)
Parameters
handlerHandler to be called when a response comes from the service
boost::system::error_code getRtcDateConfig ( dpyMcu::DateConfig config)
Parameters
configRTC date config
Returns
error code
bool isAlive ( )

TESTING : define this flag to fake/mock DPY API methods to be able to unit test classes which use DPY APIs.

Returns
Boolean indicating if MCU is alive
boost::system::error_code setI2CValue ( unsigned char  busid,
unsigned char  deviceid,
std::list< unsigned char >  address,
std::list< unsigned char >  values,
dpyMcu::I2CValue result 
)
Parameters
busidbus address
deviceiddevice address
addressmemory address. It's just ONE value. If you provide several values they will be concatenated to generate only ONE address. E.g. If you provide 0x10 0x20 0x30, it will produce a 0x102030 final address
valuesvalues to be set
resultI2C structure to be filled with the response
Returns
error code