24 #include <interfaces/TestInterface.h> 26 #include <core/exceptions/software.h> 49 TestInterface::TestInterface() : Interface()
53 data = (TestInterface_data_t *)
data_ptr;
56 enum_map_TestEnum[(int)TEST_ENUM_1] =
"TEST_ENUM_1";
57 enum_map_TestEnum[(int)TEST_ENUM_2] =
"TEST_ENUM_2";
67 unsigned char tmp_hash[] = {0xe4, 0xe2, 0x1, 0xa9, 0xc8, 0x87, 0x8d, 0x3d, 0xa3, 0xab, 0xc9, 0xcd, 0xf3, 0xf, 0x5a, 0x33};
72 TestInterface::~TestInterface()
84 case TEST_ENUM_1:
return "TEST_ENUM_1";
85 case TEST_ENUM_2:
return "TEST_ENUM_2";
86 default:
return "UNKNOWN";
97 return data->test_bool;
117 data->test_bool = new_test_bool;
128 return data->test_int;
148 data->test_int = new_test_int;
179 data->flags = new_flags;
190 return data->test_string;
210 strncpy(data->test_string, new_test_string,
sizeof(data->test_string));
241 data->result = new_result;
252 return data->test_uint;
272 data->test_uint = new_test_uint;
280 if ( strncmp(
"SetTestIntMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
282 }
else if ( strncmp(
"SetTestStringMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
284 }
else if ( strncmp(
"CalculateMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
288 "message type for this interface type.", type);
304 memcpy(data, oi->data,
sizeof(TestInterface_data_t));
310 if (strcmp(enumtype,
"TestEnum") == 0) {
311 return tostring_TestEnum((
TestEnum)val);
329 data_size =
sizeof(SetTestIntMessage_data_t);
332 data = (SetTestIntMessage_data_t *)
data_ptr;
334 data->test_int = ini_test_int;
335 enum_map_TestEnum[(int)
TEST_ENUM_1] =
"TEST_ENUM_1";
336 enum_map_TestEnum[(int)
TEST_ENUM_2] =
"TEST_ENUM_2";
342 data_size =
sizeof(SetTestIntMessage_data_t);
345 data = (SetTestIntMessage_data_t *)
data_ptr;
347 enum_map_TestEnum[(int)
TEST_ENUM_1] =
"TEST_ENUM_1";
348 enum_map_TestEnum[(int)
TEST_ENUM_2] =
"TEST_ENUM_2";
366 data = (SetTestIntMessage_data_t *)
data_ptr;
378 return data->test_int;
398 data->test_int = new_test_int;
423 data_size =
sizeof(SetTestStringMessage_data_t);
426 data = (SetTestStringMessage_data_t *)
data_ptr;
428 strncpy(data->test_string, ini_test_string, 30);
429 enum_map_TestEnum[(int)
TEST_ENUM_1] =
"TEST_ENUM_1";
430 enum_map_TestEnum[(int)
TEST_ENUM_2] =
"TEST_ENUM_2";
436 data_size =
sizeof(SetTestStringMessage_data_t);
439 data = (SetTestStringMessage_data_t *)
data_ptr;
441 enum_map_TestEnum[(int)
TEST_ENUM_1] =
"TEST_ENUM_1";
442 enum_map_TestEnum[(int)
TEST_ENUM_2] =
"TEST_ENUM_2";
460 data = (SetTestStringMessage_data_t *)
data_ptr;
472 return data->test_string;
492 strncpy(data->test_string, new_test_string,
sizeof(data->test_string));
518 data_size =
sizeof(CalculateMessage_data_t);
521 data = (CalculateMessage_data_t *)
data_ptr;
523 data->summand = ini_summand;
524 data->addend = ini_addend;
525 enum_map_TestEnum[(int)
TEST_ENUM_1] =
"TEST_ENUM_1";
526 enum_map_TestEnum[(int)
TEST_ENUM_2] =
"TEST_ENUM_2";
533 data_size =
sizeof(CalculateMessage_data_t);
536 data = (CalculateMessage_data_t *)
data_ptr;
538 enum_map_TestEnum[(int)
TEST_ENUM_1] =
"TEST_ENUM_1";
539 enum_map_TestEnum[(int)
TEST_ENUM_2] =
"TEST_ENUM_2";
558 data = (CalculateMessage_data_t *)
data_ptr;
570 return data->summand;
590 data->summand = new_summand;
620 data->addend = new_addend;
void set_test_string(const char *new_test_string)
Set test_string value.
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.
size_t maxlenof_test_bool() const
Get maximum length of test_bool value.
TestEnum
Demonstrating enums.
void set_hash(unsigned char *ihash)
Set hash.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Fawkes library namespace.
size_t maxlenof_flags() const
Get maximum length of flags value.
Timestamp data, must be present and first entries for each interface data structs! This leans on time...
virtual Message * create_message(const char *type) const
Create message based on type name.
int32_t test_int() const
Get test_int value.
virtual void copy_values(const Interface *other)
Copy values from other interface.
~CalculateMessage()
Destructor.
byte field, alias for uint8
Base class for all Fawkes BlackBoard interfaces.
int32_t addend() const
Get addend value.
void set_summand(const int32_t new_summand)
Set summand value.
char * test_string() const
Get test_string value.
~SetTestStringMessage()
Destructor.
message_data_ts_t * data_ts
data timestamp aliasing pointer
unsigned int data_size
Size of memory needed to hold all data.
void set_test_int(const int32_t new_test_int)
Set test_int value.
void add_messageinfo(const char *name)
Add an entry to the message info list.
bool data_changed
Indicator if data has changed.
size_t maxlenof_summand() const
Get maximum length of summand value.
static const int32_t TEST_CONSTANT
TEST_CONSTANT constant.
const char * type() const
Get type of interface.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
virtual Message * clone() const
Clone this message.
char * test_string() const
Get test_string value.
void set_addend(const int32_t new_addend)
Set addend value.
size_t maxlenof_test_uint() const
Get maximum length of test_uint value.
size_t maxlenof_test_int() const
Get maximum length of test_int value.
uint32_t test_uint() const
Get test_uint value.
void set_test_bool(const bool new_test_bool)
Set test_bool value.
size_t maxlenof_addend() const
Get maximum length of addend value.
CalculateMessage Fawkes BlackBoard Interface Message.
int32_t result() const
Get result value.
void set_flags(const uint8_t new_flags)
Set flags value.
SetTestIntMessage Fawkes BlackBoard Interface Message.
uint8_t flags() const
Get flags value.
void set_test_uint(const uint32_t new_test_uint)
Set test_uint value.
size_t maxlenof_result() const
Get maximum length of result value.
void set_test_string(const char *new_test_string)
Set test_string value.
SetTestIntMessage()
Constructor.
size_t maxlenof_test_int() const
Get maximum length of test_int value.
int32_t summand() const
Get summand value.
bool is_test_bool() const
Get test_bool value.
int32_t test_int() const
Get test_int value.
~SetTestIntMessage()
Destructor.
const char * tostring_TestEnum(TestEnum value) const
Convert TestEnum constant to string.
SetTestStringMessage()
Constructor.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
static const float TEST_FLOAT_CONSTANT
TEST_FLOAT_CONSTANT constant.
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.
SetTestStringMessage Fawkes BlackBoard Interface Message.
void set_result(const int32_t new_result)
Set result value.
void set_test_int(const int32_t new_test_int)
Set test_int value.
const char * type() const
Get message type.
size_t maxlenof_test_string() const
Get maximum length of test_string value.
32 bit unsigned integer field
size_t maxlenof_test_string() const
Get maximum length of test_string value.
CalculateMessage()
Constructor.
TestInterface Fawkes BlackBoard Interface.