24 #include <interfaces/LaserClusterInterface.h>
26 #include <core/exceptions/software.h>
44 LaserClusterInterface::LaserClusterInterface() : Interface()
46 data_size =
sizeof(LaserClusterInterface_data_t);
47 data_ptr = malloc(data_size);
48 data = (LaserClusterInterface_data_t *)data_ptr;
49 data_ts = (interface_data_ts_t *)data_ptr;
50 memset(data_ptr, 0, data_size);
51 enum_map_SelectionMode[(int)SELMODE_MIN_ANGLE] =
"SELMODE_MIN_ANGLE";
52 enum_map_SelectionMode[(int)SELMODE_MIN_DIST] =
"SELMODE_MIN_DIST";
53 add_fieldinfo(IFT_FLOAT,
"max_x", 1, &data->max_x);
54 add_fieldinfo(IFT_ENUM,
"selection_mode", 1, &data->selection_mode,
"SelectionMode", &enum_map_SelectionMode);
55 add_messageinfo(
"SetMaxXMessage");
56 add_messageinfo(
"SetSelectionModeMessage");
57 unsigned char tmp_hash[] = {0xad, 0xf8, 0x6e, 0xe7, 0x17, 0x56, 0x8a, 0xfb, 0xf9, 0xad, 0x3e, 0xba, 0xd, 0x15, 0xce, 0xde};
62 LaserClusterInterface::~LaserClusterInterface()
71 LaserClusterInterface::tostring_SelectionMode(SelectionMode value)
const
74 case SELMODE_MIN_ANGLE:
return "SELMODE_MIN_ANGLE";
75 case SELMODE_MIN_DIST:
return "SELMODE_MIN_DIST";
76 default:
return "UNKNOWN";
86 LaserClusterInterface::max_x()
const
96 LaserClusterInterface::maxlenof_max_x()
const
107 LaserClusterInterface::set_max_x(
const float new_max_x)
109 data->max_x = new_max_x;
120 LaserClusterInterface::selection_mode()
const
130 LaserClusterInterface::maxlenof_selection_mode()
const
142 LaserClusterInterface::set_selection_mode(
const SelectionMode new_selection_mode)
144 data->selection_mode = new_selection_mode;
150 LaserClusterInterface::create_message(
const char *type)
const
152 if ( strncmp(
"SetMaxXMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
153 return new SetMaxXMessage();
154 }
else if ( strncmp(
"SetSelectionModeMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
155 return new SetSelectionModeMessage();
157 throw UnknownTypeException(
"The given type '%s' does not match any known "
158 "message type for this interface type.", type);
167 LaserClusterInterface::copy_values(
const Interface *other)
169 const LaserClusterInterface *oi = dynamic_cast<const LaserClusterInterface *>(other);
172 type(), other->type());
174 memcpy(data, oi->data,
sizeof(LaserClusterInterface_data_t));
178 LaserClusterInterface::enum_tostring(
const char *enumtype,
int val)
const
180 if (strcmp(enumtype,
"SelectionMode") == 0) {
181 return tostring_SelectionMode((SelectionMode)val);
197 LaserClusterInterface::SetMaxXMessage::SetMaxXMessage(
const float ini_max_x) : Message(
"SetMaxXMessage")
199 data_size =
sizeof(SetMaxXMessage_data_t);
202 data = (SetMaxXMessage_data_t *)
data_ptr;
204 data->max_x = ini_max_x;
212 data_size =
sizeof(SetMaxXMessage_data_t);
215 data = (SetMaxXMessage_data_t *)
data_ptr;
236 data = (SetMaxXMessage_data_t *)
data_ptr;
270 data->max_x = new_max_x;
295 data_size =
sizeof(SetSelectionModeMessage_data_t);
298 data = (SetSelectionModeMessage_data_t *)
data_ptr;
300 data->selection_mode = ini_selection_mode;
303 add_fieldinfo(
IFT_ENUM,
"selection_mode", 1, &data->selection_mode,
"SelectionMode", &enum_map_SelectionMode);
308 data_size =
sizeof(SetSelectionModeMessage_data_t);
311 data = (SetSelectionModeMessage_data_t *)
data_ptr;
315 add_fieldinfo(
IFT_ENUM,
"selection_mode", 1, &data->selection_mode,
"SelectionMode", &enum_map_SelectionMode);
332 data = (SetSelectionModeMessage_data_t *)
data_ptr;
368 data->selection_mode = new_selection_mode;
388 const SetMaxXMessage *m0 = dynamic_cast<const SetMaxXMessage *>(message);
392 const SetSelectionModeMessage *m1 = dynamic_cast<const SetSelectionModeMessage *>(message);
400 EXPORT_INTERFACE(LaserClusterInterface)