24 #include <interfaces/BatteryInterface.h>
26 #include <core/exceptions/software.h>
46 BatteryInterface::BatteryInterface() : Interface()
48 data_size =
sizeof(BatteryInterface_data_t);
49 data_ptr = malloc(data_size);
50 data = (BatteryInterface_data_t *)data_ptr;
51 data_ts = (interface_data_ts_t *)data_ptr;
52 memset(data_ptr, 0, data_size);
53 add_fieldinfo(
IFT_UINT32,
"current", 1, &data->current);
54 add_fieldinfo(
IFT_UINT32,
"voltage", 1, &data->voltage);
55 add_fieldinfo(
IFT_UINT32,
"temperature", 1, &data->temperature);
56 add_fieldinfo(
IFT_FLOAT,
"absolute_soc", 1, &data->absolute_soc);
57 add_fieldinfo(
IFT_FLOAT,
"relative_soc", 1, &data->relative_soc);
58 add_messageinfo(
"PushButtonMessage");
59 add_messageinfo(
"SleepMessage");
60 unsigned char tmp_hash[] = {0x28, 0xb6, 0xbe, 0xe7, 0xf1, 0x47, 0x2, 0x12, 0x1d, 0xe3, 0x7c, 0x14, 0xe9, 0x1f, 0x24, 0x4d};
65 BatteryInterface::~BatteryInterface()
97 data->current = new_current;
108 return data->voltage;
128 data->voltage = new_voltage;
139 return data->temperature;
159 data->temperature = new_temperature;
170 return data->absolute_soc;
190 data->absolute_soc = new_absolute_soc;
201 return data->relative_soc;
221 data->relative_soc = new_relative_soc;
229 if ( strncmp(
"PushButtonMessage",
type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
231 }
else if ( strncmp(
"SleepMessage",
type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
235 "message type for this interface type.",
type);
246 const BatteryInterface *oi =
dynamic_cast<const BatteryInterface *
>(other);
248 throw TypeMismatchException(
"Can only copy values from interface of same type (%s vs. %s)",
249 type(), other->type());
251 memcpy(data, oi->data,
sizeof(BatteryInterface_data_t));
257 throw UnknownTypeException(
"Unknown enum type %s", enumtype);
271 data_size =
sizeof(PushButtonMessage_data_t);
274 data = (PushButtonMessage_data_t *)
data_ptr;
292 data = (PushButtonMessage_data_t *)
data_ptr;
320 data = (SleepMessage_data_t *)
data_ptr;
338 data = (SleepMessage_data_t *)
data_ptr;
372 EXPORT_INTERFACE(BatteryInterface)