Fawkes API
Fawkes Development Version
|
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()
107 return data->voltage;
137 return data->temperature;
167 return data->absolute_soc;
197 return data->relative_soc;
224 if ( strncmp(
"PushButtonMessage",
type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
226 }
else if ( strncmp(
"SleepMessage",
type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
230 "message type for this interface type.",
type);
246 memcpy(data, oi->data,
sizeof(BatteryInterface_data_t));
266 data_size =
sizeof(PushButtonMessage_data_t);
269 data = (PushButtonMessage_data_t *)
data_ptr;
287 data = (PushButtonMessage_data_t *)
data_ptr;
315 data = (SleepMessage_data_t *)
data_ptr;
333 data = (SleepMessage_data_t *)
data_ptr;
void * data_ptr
Pointer to local memory storage.
SleepMessage Fawkes BlackBoard Interface Message.
float absolute_soc() const
Get absolute_soc value.
size_t maxlenof_temperature() const
Get maximum length of temperature value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
SleepMessage()
Constructor.
virtual Message * clone() const
Clone this message.
~SleepMessage()
Destructor.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
size_t maxlenof_current() const
Get maximum length of current value.
void * data_ptr
Pointer to memory that contains local data.
message_data_ts_t * data_ts
data timestamp aliasing pointer
@ IFT_UINT32
32 bit unsigned integer field
float relative_soc() const
Get relative_soc value.
const char * type() const
Get type of interface.
void set_temperature(const uint32_t new_temperature)
Set temperature value.
Timestamp data, must be present and first entries for each interface data structs!...
void set_absolute_soc(const float new_absolute_soc)
Set absolute_soc value.
bool data_changed
Indicator if data has changed.
size_t maxlenof_relative_soc() const
Get maximum length of relative_soc value.
Fawkes library namespace.
unsigned int data_size
Size of memory needed to hold all data.
size_t maxlenof_absolute_soc() const
Get maximum length of absolute_soc value.
void set_relative_soc(const float new_relative_soc)
Set relative_soc value.
void set_voltage(const uint32_t new_voltage)
Set voltage value.
uint32_t current() const
Get current value.
BatteryInterface Fawkes BlackBoard Interface.
Base class for all Fawkes BlackBoard interfaces.
void set_current(const uint32_t new_current)
Set current value.
uint32_t voltage() const
Get voltage value.
virtual Message * create_message(const char *type) const
Create message based on type name.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
virtual void copy_values(const Interface *other)
Copy values from other interface.
uint32_t temperature() const
Get temperature value.
bool change_field(FieldT &field, const DataT &value)
Set a field and return whether it changed.
size_t maxlenof_voltage() const
Get maximum length of voltage value.