24 #include <interfaces/SkillerDebugInterface.h>
26 #include <core/exceptions/software.h>
49 SkillerDebugInterface::SkillerDebugInterface() : Interface()
51 data_size =
sizeof(SkillerDebugInterface_data_t);
52 data_ptr = malloc(data_size);
53 data = (SkillerDebugInterface_data_t *)data_ptr;
54 data_ts = (interface_data_ts_t *)data_ptr;
55 memset(data_ptr, 0, data_size);
56 enum_map_GraphDirectionEnum[(int)GD_TOP_BOTTOM] =
"GD_TOP_BOTTOM";
57 enum_map_GraphDirectionEnum[(int)GD_BOTTOM_TOP] =
"GD_BOTTOM_TOP";
58 enum_map_GraphDirectionEnum[(int)GD_LEFT_RIGHT] =
"GD_LEFT_RIGHT";
59 enum_map_GraphDirectionEnum[(int)GD_RIGHT_LEFT] =
"GD_RIGHT_LEFT";
60 add_fieldinfo(IFT_STRING,
"graph_fsm", 32, data->graph_fsm);
61 add_fieldinfo(IFT_STRING,
"graph", 8192, data->graph);
62 add_fieldinfo(IFT_ENUM,
"graph_dir", 1, &data->graph_dir,
"GraphDirectionEnum", &enum_map_GraphDirectionEnum);
63 add_fieldinfo(IFT_BOOL,
"graph_colored", 1, &data->graph_colored);
64 add_messageinfo(
"SetGraphMessage");
65 add_messageinfo(
"SetGraphDirectionMessage");
66 add_messageinfo(
"SetGraphColoredMessage");
67 unsigned char tmp_hash[] = {0xcf, 0x3d, 0x2f, 0xf8, 0x80, 0x6e, 0x8f, 0xf4, 0x81, 0xa6, 0x7f, 0xd9, 0xb0, 0x29, 0xfc, 0x62};
72 SkillerDebugInterface::~SkillerDebugInterface()
81 SkillerDebugInterface::tostring_GraphDirectionEnum(GraphDirectionEnum value)
const
84 case GD_TOP_BOTTOM:
return "GD_TOP_BOTTOM";
85 case GD_BOTTOM_TOP:
return "GD_BOTTOM_TOP";
86 case GD_LEFT_RIGHT:
return "GD_LEFT_RIGHT";
87 case GD_RIGHT_LEFT:
return "GD_RIGHT_LEFT";
88 default:
return "UNKNOWN";
99 SkillerDebugInterface::graph_fsm()
const
101 return data->graph_fsm;
109 SkillerDebugInterface::maxlenof_graph_fsm()
const
121 SkillerDebugInterface::set_graph_fsm(
const char * new_graph_fsm)
123 strncpy(data->graph_fsm, new_graph_fsm,
sizeof(data->graph_fsm)-1);
124 data->graph_fsm[
sizeof(data->graph_fsm)-1] = 0;
135 SkillerDebugInterface::graph()
const
145 SkillerDebugInterface::maxlenof_graph()
const
157 SkillerDebugInterface::set_graph(
const char * new_graph)
159 strncpy(data->graph, new_graph,
sizeof(data->graph)-1);
160 data->graph[
sizeof(data->graph)-1] = 0;
171 SkillerDebugInterface::graph_dir()
const
181 SkillerDebugInterface::maxlenof_graph_dir()
const
195 data->graph_dir = new_graph_dir;
206 SkillerDebugInterface::is_graph_colored()
const
208 return data->graph_colored;
216 SkillerDebugInterface::maxlenof_graph_colored()
const
228 SkillerDebugInterface::set_graph_colored(
const bool new_graph_colored)
230 data->graph_colored = new_graph_colored;
236 SkillerDebugInterface::create_message(
const char *type)
const
238 if ( strncmp(
"SetGraphMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
240 }
else if ( strncmp(
"SetGraphDirectionMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
242 }
else if ( strncmp(
"SetGraphColoredMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
243 return new SetGraphColoredMessage();
245 throw UnknownTypeException(
"The given type '%s' does not match any known "
246 "message type for this interface type.", type);
255 SkillerDebugInterface::copy_values(
const Interface *other)
257 const SkillerDebugInterface *oi =
dynamic_cast<const SkillerDebugInterface *
>(other);
259 throw TypeMismatchException(
"Can only copy values from interface of same type (%s vs. %s)",
260 type(), other->type());
262 memcpy(data, oi->data,
sizeof(SkillerDebugInterface_data_t));
266 SkillerDebugInterface::enum_tostring(
const char *enumtype,
int val)
const
268 if (strcmp(enumtype,
"GraphDirectionEnum") == 0) {
269 return tostring_GraphDirectionEnum((GraphDirectionEnum)val);
271 throw UnknownTypeException(
"Unknown enum type %s", enumtype);
285 SkillerDebugInterface::SetGraphMessage::SetGraphMessage(
const char * ini_graph_fsm) :
Message(
"SetGraphMessage")
287 data_size =
sizeof(SetGraphMessage_data_t);
290 data = (SetGraphMessage_data_t *)
data_ptr;
292 strncpy(data->graph_fsm, ini_graph_fsm, 32-1);
293 data->graph_fsm[32-1] = 0;
294 enum_map_GraphDirectionEnum[(int)
GD_TOP_BOTTOM] =
"GD_TOP_BOTTOM";
295 enum_map_GraphDirectionEnum[(int)
GD_BOTTOM_TOP] =
"GD_BOTTOM_TOP";
296 enum_map_GraphDirectionEnum[(int)
GD_LEFT_RIGHT] =
"GD_LEFT_RIGHT";
297 enum_map_GraphDirectionEnum[(int)
GD_RIGHT_LEFT] =
"GD_RIGHT_LEFT";
303 data_size =
sizeof(SetGraphMessage_data_t);
306 data = (SetGraphMessage_data_t *)
data_ptr;
308 enum_map_GraphDirectionEnum[(int)
GD_TOP_BOTTOM] =
"GD_TOP_BOTTOM";
309 enum_map_GraphDirectionEnum[(int)
GD_BOTTOM_TOP] =
"GD_BOTTOM_TOP";
310 enum_map_GraphDirectionEnum[(int)
GD_LEFT_RIGHT] =
"GD_LEFT_RIGHT";
311 enum_map_GraphDirectionEnum[(int)
GD_RIGHT_LEFT] =
"GD_RIGHT_LEFT";
329 data = (SetGraphMessage_data_t *)
data_ptr;
343 return data->graph_fsm;
365 strncpy(data->graph_fsm, new_graph_fsm,
sizeof(data->graph_fsm)-1);
366 data->graph_fsm[
sizeof(data->graph_fsm)-1] = 0;
391 data_size =
sizeof(SetGraphDirectionMessage_data_t);
394 data = (SetGraphDirectionMessage_data_t *)
data_ptr;
396 data->graph_dir = ini_graph_dir;
397 enum_map_GraphDirectionEnum[(int)
GD_TOP_BOTTOM] =
"GD_TOP_BOTTOM";
398 enum_map_GraphDirectionEnum[(int)
GD_BOTTOM_TOP] =
"GD_BOTTOM_TOP";
399 enum_map_GraphDirectionEnum[(int)
GD_LEFT_RIGHT] =
"GD_LEFT_RIGHT";
400 enum_map_GraphDirectionEnum[(int)
GD_RIGHT_LEFT] =
"GD_RIGHT_LEFT";
401 add_fieldinfo(
IFT_ENUM,
"graph_dir", 1, &data->graph_dir,
"GraphDirectionEnum", &enum_map_GraphDirectionEnum);
406 data_size =
sizeof(SetGraphDirectionMessage_data_t);
409 data = (SetGraphDirectionMessage_data_t *)
data_ptr;
411 enum_map_GraphDirectionEnum[(int)
GD_TOP_BOTTOM] =
"GD_TOP_BOTTOM";
412 enum_map_GraphDirectionEnum[(int)
GD_BOTTOM_TOP] =
"GD_BOTTOM_TOP";
413 enum_map_GraphDirectionEnum[(int)
GD_LEFT_RIGHT] =
"GD_LEFT_RIGHT";
414 enum_map_GraphDirectionEnum[(int)
GD_RIGHT_LEFT] =
"GD_RIGHT_LEFT";
415 add_fieldinfo(
IFT_ENUM,
"graph_dir", 1, &data->graph_dir,
"GraphDirectionEnum", &enum_map_GraphDirectionEnum);
432 data = (SetGraphDirectionMessage_data_t *)
data_ptr;
468 data->graph_dir = new_graph_dir;
493 data_size =
sizeof(SetGraphColoredMessage_data_t);
496 data = (SetGraphColoredMessage_data_t *)
data_ptr;
498 data->graph_colored = ini_graph_colored;
499 enum_map_GraphDirectionEnum[(int)
GD_TOP_BOTTOM] =
"GD_TOP_BOTTOM";
500 enum_map_GraphDirectionEnum[(int)
GD_BOTTOM_TOP] =
"GD_BOTTOM_TOP";
501 enum_map_GraphDirectionEnum[(int)
GD_LEFT_RIGHT] =
"GD_LEFT_RIGHT";
502 enum_map_GraphDirectionEnum[(int)
GD_RIGHT_LEFT] =
"GD_RIGHT_LEFT";
508 data_size =
sizeof(SetGraphColoredMessage_data_t);
511 data = (SetGraphColoredMessage_data_t *)
data_ptr;
513 enum_map_GraphDirectionEnum[(int)
GD_TOP_BOTTOM] =
"GD_TOP_BOTTOM";
514 enum_map_GraphDirectionEnum[(int)
GD_BOTTOM_TOP] =
"GD_BOTTOM_TOP";
515 enum_map_GraphDirectionEnum[(int)
GD_LEFT_RIGHT] =
"GD_LEFT_RIGHT";
516 enum_map_GraphDirectionEnum[(int)
GD_RIGHT_LEFT] =
"GD_RIGHT_LEFT";
534 data = (SetGraphColoredMessage_data_t *)
data_ptr;
548 return data->graph_colored;
570 data->graph_colored = new_graph_colored;
598 const SetGraphColoredMessage *m2 =
dynamic_cast<const SetGraphColoredMessage *
>(message);
606 EXPORT_INTERFACE(SkillerDebugInterface)