24 #include <interfaces/SwitchInterface.h>
26 #include <core/exceptions/software.h>
47 SwitchInterface::SwitchInterface() : Interface()
49 data_size =
sizeof(SwitchInterface_data_t);
51 data = (SwitchInterface_data_t *)
data_ptr;
64 unsigned char tmp_hash[] = {0xa7, 0xa4, 0xc, 0x19, 0x66, 0xa4, 0x87, 0x6b, 0xa9, 0x32, 0x95, 0x40, 0xc7, 0x82, 0x75, 0x6d};
69 SwitchInterface::~SwitchInterface()
105 data->enabled = new_enabled;
144 data->value = new_value;
162 return data->history;
189 data->history = new_history;
203 return data->short_activations;
226 data->short_activations = new_short_activations;
240 return data->long_activations;
263 data->long_activations = new_long_activations;
277 return data->activation_count;
300 data->activation_count = new_activation_count;
308 if ( strncmp(
"SetMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
310 }
else if ( strncmp(
"EnableSwitchMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
312 }
else if ( strncmp(
"DisableSwitchMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
314 }
else if ( strncmp(
"EnableDurationMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
318 "message type for this interface type.", type);
334 memcpy(data, oi->data,
sizeof(SwitchInterface_data_t));
360 data = (SetMessage_data_t *)
data_ptr;
362 data->enabled = ini_enabled;
363 data->value = ini_value;
373 data = (SetMessage_data_t *)
data_ptr;
393 data = (SetMessage_data_t *)
data_ptr;
407 return data->enabled;
429 data->enabled = new_enabled;
467 data->value = new_value;
490 data_size =
sizeof(EnableSwitchMessage_data_t);
493 data = (EnableSwitchMessage_data_t *)
data_ptr;
511 data = (EnableSwitchMessage_data_t *)
data_ptr;
536 data_size =
sizeof(DisableSwitchMessage_data_t);
539 data = (DisableSwitchMessage_data_t *)
data_ptr;
557 data = (DisableSwitchMessage_data_t *)
data_ptr;
585 data_size =
sizeof(EnableDurationMessage_data_t);
588 data = (EnableDurationMessage_data_t *)
data_ptr;
590 data->duration = ini_duration;
591 data->value = ini_value;
598 data_size =
sizeof(EnableDurationMessage_data_t);
601 data = (EnableDurationMessage_data_t *)
data_ptr;
621 data = (EnableDurationMessage_data_t *)
data_ptr;
634 return data->duration;
655 data->duration = new_duration;
693 data->value = new_value;
size_t maxlenof_enabled() const
Get maximum length of enabled value.
bool is_enabled() const
Get enabled value.
~EnableDurationMessage()
Destructor.
void * data_ptr
Pointer to memory that contains local data.
size_t maxlenof_value() const
Get maximum length of value value.
virtual Message * clone() const
Clone this message.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
SetMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_duration() const
Get maximum length of duration value.
void set_value(const float new_value)
Set value value.
void set_hash(unsigned char *ihash)
Set hash.
size_t maxlenof_value() const
Get maximum length of value value.
void set_enabled(const bool new_enabled)
Set enabled value.
float value() const
Get value value.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
virtual Message * clone() const
Clone this message.
uint32_t long_activations() const
Get long_activations value.
float value() const
Get value value.
DisableSwitchMessage()
Constructor.
size_t maxlenof_value() const
Get maximum length of value value.
void set_value(const float new_value)
Set value value.
void set_history(const float new_history)
Set history value.
Base class for all Fawkes BlackBoard interfaces.
void set_short_activations(const uint32_t new_short_activations)
Set short_activations value.
message_data_ts_t * data_ts
data timestamp aliasing pointer
unsigned int data_size
Size of memory needed to hold all data.
void add_messageinfo(const char *name)
Add an entry to the message info list.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
bool data_changed
Indicator if data has changed.
SwitchInterface Fawkes BlackBoard Interface.
float history() const
Get history value.
uint32_t short_activations() const
Get short_activations value.
void * data_ptr
Pointer to local memory storage.
void set_activation_count(const uint32_t new_activation_count)
Set activation_count value.
void set_enabled(const bool new_enabled)
Set enabled value.
bool is_enabled() const
Get enabled value.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
DisableSwitchMessage Fawkes BlackBoard Interface Message.
uint32_t activation_count() const
Get activation_count value.
EnableSwitchMessage()
Constructor.
virtual Message * clone() const
Clone this message.
void set_long_activations(const uint32_t new_long_activations)
Set long_activations value.
size_t maxlenof_activation_count() const
Get maximum length of activation_count value.
size_t maxlenof_long_activations() const
Get maximum length of long_activations value.
float duration() const
Get duration value.
virtual Message * clone() const
Clone this message.
virtual void copy_values(const Interface *other)
Copy values from other interface.
EnableSwitchMessage Fawkes BlackBoard Interface Message.
EnableDurationMessage()
Constructor.
size_t maxlenof_history() const
Get maximum length of history value.
void set_value(const float new_value)
Set value value.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0)
Add an entry to the info list.
float value() const
Get value value.
~EnableSwitchMessage()
Destructor.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
size_t maxlenof_short_activations() const
Get maximum length of short_activations value.
EnableDurationMessage Fawkes BlackBoard Interface Message.
virtual Message * create_message(const char *type) const
Create message based on type name.
void set_duration(const float new_duration)
Set duration value.
const char * type() const
Get type of interface.
~DisableSwitchMessage()
Destructor.
32 bit unsigned integer field