24 #include <interfaces/KickerInterface.h>
26 #include <core/exceptions/software.h>
47 KickerInterface::KickerInterface() : Interface()
49 data_size =
sizeof(KickerInterface_data_t);
50 data_ptr = malloc(data_size);
51 data = (KickerInterface_data_t *)data_ptr;
52 data_ts = (interface_data_ts_t *)data_ptr;
53 memset(data_ptr, 0, data_size);
54 enum_map_GuideBallSideEnum[(int)GUIDE_BALL_LEFT] =
"GUIDE_BALL_LEFT";
55 enum_map_GuideBallSideEnum[(int)GUIDE_BALL_RIGHT] =
"GUIDE_BALL_RIGHT";
56 add_fieldinfo(IFT_INT32,
"num_kicks_left", 1, &data->num_kicks_left);
57 add_fieldinfo(IFT_INT32,
"num_kicks_center", 1, &data->num_kicks_center);
58 add_fieldinfo(IFT_INT32,
"num_kicks_right", 1, &data->num_kicks_right);
59 add_fieldinfo(IFT_ENUM,
"guide_ball_side", 1, &data->guide_ball_side,
"GuideBallSideEnum", &enum_map_GuideBallSideEnum);
60 add_fieldinfo(IFT_UINT32,
"current_intensity", 1, &data->current_intensity);
61 add_messageinfo(
"KickMessage");
62 add_messageinfo(
"ResetCounterMessage");
63 add_messageinfo(
"GuideBallMessage");
64 unsigned char tmp_hash[] = {0x96, 0x3d, 0x55, 0x60, 0xfd, 0x65, 0xf2, 0xfa, 0xa8, 0xfa, 0xfc, 0xaa, 0xb6, 0xfc, 0xc2, 0x81};
69 KickerInterface::~KickerInterface()
81 case GUIDE_BALL_LEFT:
return "GUIDE_BALL_LEFT";
82 case GUIDE_BALL_RIGHT:
return "GUIDE_BALL_RIGHT";
83 default:
return "UNKNOWN";
94 KickerInterface::num_kicks_left()
const
96 return data->num_kicks_left;
104 KickerInterface::maxlenof_num_kicks_left()
const
116 KickerInterface::set_num_kicks_left(
const int32_t new_num_kicks_left)
118 data_changed |=
change_field(data->num_kicks_left, new_num_kicks_left);
128 KickerInterface::num_kicks_center()
const
130 return data->num_kicks_center;
138 KickerInterface::maxlenof_num_kicks_center()
const
150 KickerInterface::set_num_kicks_center(
const int32_t new_num_kicks_center)
152 data_changed |=
change_field(data->num_kicks_center, new_num_kicks_center);
162 KickerInterface::num_kicks_right()
const
164 return data->num_kicks_right;
172 KickerInterface::maxlenof_num_kicks_right()
const
184 KickerInterface::set_num_kicks_right(
const int32_t new_num_kicks_right)
186 data_changed |=
change_field(data->num_kicks_right, new_num_kicks_right);
195 KickerInterface::guide_ball_side()
const
205 KickerInterface::maxlenof_guide_ball_side()
const
218 data_changed |=
change_field(data->guide_ball_side, new_guide_ball_side);
228 KickerInterface::current_intensity()
const
230 return data->current_intensity;
238 KickerInterface::maxlenof_current_intensity()
const
250 KickerInterface::set_current_intensity(
const uint32_t new_current_intensity)
252 data_changed |=
change_field(data->current_intensity, new_current_intensity);
257 KickerInterface::create_message(
const char *type)
const
259 if ( strncmp(
"KickMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
261 }
else if ( strncmp(
"ResetCounterMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
263 }
else if ( strncmp(
"GuideBallMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
267 "message type for this interface type.", type);
281 type(), other->
type());
283 memcpy(data, oi->data,
sizeof(KickerInterface_data_t));
287 KickerInterface::enum_tostring(
const char *enumtype,
int val)
const
289 if (strcmp(enumtype,
"GuideBallSideEnum") == 0) {
309 KickerInterface::KickMessage::KickMessage(
const bool ini_left,
const bool ini_center,
const bool ini_right,
const uint32_t ini_intensity) :
Message(
"KickMessage")
314 data = (KickMessage_data_t *)
data_ptr;
316 data->left = ini_left;
317 data->center = ini_center;
318 data->right = ini_right;
319 data->intensity = ini_intensity;
333 data = (KickMessage_data_t *)
data_ptr;
357 data = (KickMessage_data_t *)
data_ptr;
459 return data->intensity;
502 data_size =
sizeof(ResetCounterMessage_data_t);
505 data = (ResetCounterMessage_data_t *)
data_ptr;
525 data = (ResetCounterMessage_data_t *)
data_ptr;
552 data_size =
sizeof(GuideBallMessage_data_t);
555 data = (GuideBallMessage_data_t *)
data_ptr;
557 data->guide_ball_side = ini_guide_ball_side;
560 add_fieldinfo(
IFT_ENUM,
"guide_ball_side", 1, &data->guide_ball_side,
"GuideBallSideEnum", &enum_map_GuideBallSideEnum);
565 data_size =
sizeof(GuideBallMessage_data_t);
568 data = (GuideBallMessage_data_t *)
data_ptr;
572 add_fieldinfo(
IFT_ENUM,
"guide_ball_side", 1, &data->guide_ball_side,
"GuideBallSideEnum", &enum_map_GuideBallSideEnum);
589 data = (GuideBallMessage_data_t *)
data_ptr;
621 change_field(data->guide_ball_side, new_guide_ball_side);
Base class for all Fawkes BlackBoard interfaces.
const char * type() const
Get type of interface.
void * data_ptr
Pointer to local memory storage.
GuideBallMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_guide_ball_side() const
Get maximum length of guide_ball_side value.
~GuideBallMessage()
Destructor.
virtual Message * clone() const
Clone this message.
GuideBallSideEnum guide_ball_side() const
Get guide_ball_side value.
void set_guide_ball_side(const GuideBallSideEnum new_guide_ball_side)
Set guide_ball_side value.
GuideBallMessage()
Constructor.
KickMessage Fawkes BlackBoard Interface Message.
void set_left(const bool new_left)
Set left value.
bool is_left() const
Get left value.
size_t maxlenof_right() const
Get maximum length of right value.
void set_intensity(const uint32_t new_intensity)
Set intensity value.
void set_right(const bool new_right)
Set right value.
bool is_right() const
Get right value.
uint32_t intensity() const
Get intensity value.
~KickMessage()
Destructor.
void set_center(const bool new_center)
Set center value.
size_t maxlenof_intensity() const
Get maximum length of intensity value.
size_t maxlenof_left() const
Get maximum length of left value.
bool is_center() const
Get center value.
virtual Message * clone() const
Clone this message.
KickMessage()
Constructor.
size_t maxlenof_center() const
Get maximum length of center value.
ResetCounterMessage Fawkes BlackBoard Interface Message.
~ResetCounterMessage()
Destructor.
ResetCounterMessage()
Constructor.
virtual Message * clone() const
Clone this message.
KickerInterface Fawkes BlackBoard Interface.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
GuideBallSideEnum
Enumeration defining on which side of the robot the ball shall be guided (and thus on which side the ...
@ GUIDE_BALL_RIGHT
Constant defining that the kicker shall activate the ball guidance device in such a way that the righ...
@ GUIDE_BALL_LEFT
Constant defining that the kicker shall activate the ball guidance device in such a way that the left...
Base class for all messages passed through interfaces in Fawkes BlackBoard.
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.
void * data_ptr
Pointer to memory that contains local data.
message_data_ts_t * data_ts
data timestamp aliasing pointer
unsigned int data_size
Size of memory needed to hold all data.
Fawkes library namespace.
@ IFT_UINT32
32 bit unsigned integer field
@ IFT_ENUM
field with interface specific enum type
bool change_field(FieldT &field, const DataT &value)
Set a field and return whether it changed.
Timestamp data, must be present and first entries for each interface data structs!...