24 #include <interfaces/SwitchInterface.h> 26 #include <core/exceptions/software.h> 49 SwitchInterface::SwitchInterface() : Interface()
51 data_size =
sizeof(SwitchInterface_data_t);
53 data = (SwitchInterface_data_t *)
data_ptr;
66 unsigned char tmp_hash[] = {0xa7, 0xa4, 0xc, 0x19, 0x66, 0xa4, 0x87, 0x6b, 0xa9, 0x32, 0x95, 0x40, 0xc7, 0x82, 0x75, 0x6d};
71 SwitchInterface::~SwitchInterface()
107 data->enabled = new_enabled;
146 data->value = new_value;
164 return data->history;
191 data->history = new_history;
205 return data->short_activations;
228 data->short_activations = new_short_activations;
242 return data->long_activations;
265 data->long_activations = new_long_activations;
279 return data->activation_count;
302 data->activation_count = new_activation_count;
310 if ( strncmp(
"SetMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
312 }
else if ( strncmp(
"EnableSwitchMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
314 }
else if ( strncmp(
"DisableSwitchMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
316 }
else if ( strncmp(
"EnableDurationMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
320 "message type for this interface type.", type);
336 memcpy(data, oi->data,
sizeof(SwitchInterface_data_t));
362 data = (SetMessage_data_t *)
data_ptr;
364 data->enabled = ini_enabled;
365 data->value = ini_value;
375 data = (SetMessage_data_t *)
data_ptr;
395 data = (SetMessage_data_t *)
data_ptr;
409 return data->enabled;
431 data->enabled = new_enabled;
469 data->value = new_value;
492 data_size =
sizeof(EnableSwitchMessage_data_t);
495 data = (EnableSwitchMessage_data_t *)
data_ptr;
513 data = (EnableSwitchMessage_data_t *)
data_ptr;
538 data_size =
sizeof(DisableSwitchMessage_data_t);
541 data = (DisableSwitchMessage_data_t *)
data_ptr;
559 data = (DisableSwitchMessage_data_t *)
data_ptr;
587 data_size =
sizeof(EnableDurationMessage_data_t);
590 data = (EnableDurationMessage_data_t *)
data_ptr;
592 data->duration = ini_duration;
593 data->value = ini_value;
600 data_size =
sizeof(EnableDurationMessage_data_t);
603 data = (EnableDurationMessage_data_t *)
data_ptr;
623 data = (EnableDurationMessage_data_t *)
data_ptr;
636 return data->duration;
657 data->duration = new_duration;
695 data->value = new_value;
~EnableDurationMessage()
Destructor.
void * data_ptr
Pointer to memory that contains local data.
float value() const
Get value value.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
SetMessage Fawkes BlackBoard Interface Message.
void set_value(const float new_value)
Set value value.
size_t maxlenof_long_activations() const
Get maximum length of long_activations value.
void set_hash(unsigned char *ihash)
Set hash.
void set_enabled(const bool new_enabled)
Set enabled value.
Fawkes library namespace.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
size_t maxlenof_history() const
Get maximum length of history value.
uint32_t short_activations() const
Get short_activations value.
uint32_t activation_count() const
Get activation_count value.
DisableSwitchMessage()
Constructor.
float value() const
Get value value.
void set_value(const float new_value)
Set value value.
void set_history(const float new_history)
Set history value.
uint32_t long_activations() const
Get long_activations value.
Base class for all Fawkes BlackBoard interfaces.
bool is_enabled() const
Get enabled value.
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.
float value() const
Get value value.
void add_messageinfo(const char *name)
Add an entry to the message info list.
virtual Message * create_message(const char *type) const
Create message based on type name.
bool data_changed
Indicator if data has changed.
SwitchInterface Fawkes BlackBoard Interface.
const char * type() const
Get type of interface.
void set_activation_count(const uint32_t new_activation_count)
Set activation_count value.
void set_enabled(const bool new_enabled)
Set enabled value.
size_t maxlenof_value() const
Get maximum length of value value.
DisableSwitchMessage Fawkes BlackBoard Interface Message.
float history() const
Get history value.
virtual Message * clone() const
Clone this message.
EnableSwitchMessage()
Constructor.
bool is_enabled() const
Get enabled value.
size_t maxlenof_value() const
Get maximum length of value value.
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.
float duration() const
Get duration value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
EnableSwitchMessage Fawkes BlackBoard Interface Message.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
EnableDurationMessage()
Constructor.
virtual Message * clone() const
Clone this message.
void set_value(const float new_value)
Set value value.
virtual Message * clone() const
Clone this message.
~EnableSwitchMessage()
Destructor.
EnableDurationMessage Fawkes BlackBoard Interface Message.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
size_t maxlenof_short_activations() const
Get maximum length of short_activations value.
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
void set_duration(const float new_duration)
Set duration value.
size_t maxlenof_enabled() const
Get maximum length of enabled value.
virtual Message * clone() const
Clone this message.
~DisableSwitchMessage()
Destructor.
size_t maxlenof_duration() const
Get maximum length of duration value.
const char * type() const
Get message type.
size_t maxlenof_value() const
Get maximum length of value value.
32 bit unsigned integer field