00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <interfaces/SkillerDebugInterface.h>
00025
00026 #include <core/exceptions/software.h>
00027
00028 #include <cstring>
00029 #include <cstdlib>
00030
00031 namespace fawkes {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 SkillerDebugInterface::SkillerDebugInterface() : Interface()
00048 {
00049 data_size = sizeof(SkillerDebugInterface_data_t);
00050 data_ptr = malloc(data_size);
00051 data = (SkillerDebugInterface_data_t *)data_ptr;
00052 data_ts = (interface_data_ts_t *)data_ptr;
00053 memset(data_ptr, 0, data_size);
00054 add_fieldinfo(IFT_STRING, "graph_fsm", 32, data->graph_fsm);
00055 add_fieldinfo(IFT_STRING, "graph", 8192, data->graph);
00056 add_fieldinfo(IFT_ENUM, "graph_dir", 1, &data->graph_dir, "GraphDirectionEnum");
00057 add_fieldinfo(IFT_BOOL, "graph_colored", 1, &data->graph_colored);
00058 add_messageinfo("SetGraphMessage");
00059 add_messageinfo("SetGraphDirectionMessage");
00060 add_messageinfo("SetGraphColoredMessage");
00061 unsigned char tmp_hash[] = {0xcf, 0x3d, 0x2f, 0xf8, 0x80, 0x6e, 0x8f, 0xf4, 0x81, 0xa6, 0x7f, 0xd9, 0xb0, 0x29, 0xfc, 0x62};
00062 set_hash(tmp_hash);
00063 }
00064
00065
00066 SkillerDebugInterface::~SkillerDebugInterface()
00067 {
00068 free(data_ptr);
00069 }
00070
00071
00072
00073
00074 const char *
00075 SkillerDebugInterface::tostring_GraphDirectionEnum(GraphDirectionEnum value) const
00076 {
00077 switch (value) {
00078 case GD_TOP_BOTTOM: return "GD_TOP_BOTTOM";
00079 case GD_BOTTOM_TOP: return "GD_BOTTOM_TOP";
00080 case GD_LEFT_RIGHT: return "GD_LEFT_RIGHT";
00081 case GD_RIGHT_LEFT: return "GD_RIGHT_LEFT";
00082 default: return "UNKNOWN";
00083 }
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 char *
00093 SkillerDebugInterface::graph_fsm() const
00094 {
00095 return data->graph_fsm;
00096 }
00097
00098
00099
00100
00101
00102 size_t
00103 SkillerDebugInterface::maxlenof_graph_fsm() const
00104 {
00105 return 32;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114 void
00115 SkillerDebugInterface::set_graph_fsm(const char * new_graph_fsm)
00116 {
00117 strncpy(data->graph_fsm, new_graph_fsm, sizeof(data->graph_fsm));
00118 data_changed = true;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127 char *
00128 SkillerDebugInterface::graph() const
00129 {
00130 return data->graph;
00131 }
00132
00133
00134
00135
00136
00137 size_t
00138 SkillerDebugInterface::maxlenof_graph() const
00139 {
00140 return 8192;
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 void
00150 SkillerDebugInterface::set_graph(const char * new_graph)
00151 {
00152 strncpy(data->graph, new_graph, sizeof(data->graph));
00153 data_changed = true;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162 SkillerDebugInterface::GraphDirectionEnum
00163 SkillerDebugInterface::graph_dir() const
00164 {
00165 return data->graph_dir;
00166 }
00167
00168
00169
00170
00171
00172 size_t
00173 SkillerDebugInterface::maxlenof_graph_dir() const
00174 {
00175 return 1;
00176 }
00177
00178
00179
00180
00181
00182
00183
00184 void
00185 SkillerDebugInterface::set_graph_dir(const GraphDirectionEnum new_graph_dir)
00186 {
00187 data->graph_dir = new_graph_dir;
00188 data_changed = true;
00189 }
00190
00191
00192
00193
00194
00195
00196
00197 bool
00198 SkillerDebugInterface::is_graph_colored() const
00199 {
00200 return data->graph_colored;
00201 }
00202
00203
00204
00205
00206
00207 size_t
00208 SkillerDebugInterface::maxlenof_graph_colored() const
00209 {
00210 return 1;
00211 }
00212
00213
00214
00215
00216
00217
00218
00219 void
00220 SkillerDebugInterface::set_graph_colored(const bool new_graph_colored)
00221 {
00222 data->graph_colored = new_graph_colored;
00223 data_changed = true;
00224 }
00225
00226
00227 Message *
00228 SkillerDebugInterface::create_message(const char *type) const
00229 {
00230 if ( strncmp("SetGraphMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00231 return new SetGraphMessage();
00232 } else if ( strncmp("SetGraphDirectionMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00233 return new SetGraphDirectionMessage();
00234 } else if ( strncmp("SetGraphColoredMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00235 return new SetGraphColoredMessage();
00236 } else {
00237 throw UnknownTypeException("The given type '%s' does not match any known "
00238 "message type for this interface type.", type);
00239 }
00240 }
00241
00242
00243
00244
00245
00246 void
00247 SkillerDebugInterface::copy_values(const Interface *other)
00248 {
00249 const SkillerDebugInterface *oi = dynamic_cast<const SkillerDebugInterface *>(other);
00250 if (oi == NULL) {
00251 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00252 type(), other->type());
00253 }
00254 memcpy(data, oi->data, sizeof(SkillerDebugInterface_data_t));
00255 }
00256
00257 const char *
00258 SkillerDebugInterface::enum_tostring(const char *enumtype, int val) const
00259 {
00260 if (strcmp(enumtype, "GraphDirectionEnum") == 0) {
00261 return tostring_GraphDirectionEnum((GraphDirectionEnum)val);
00262 }
00263 throw UnknownTypeException("Unknown enum type %s", enumtype);
00264 }
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 SkillerDebugInterface::SetGraphMessage::SetGraphMessage(const char * ini_graph_fsm) : Message("SetGraphMessage")
00278 {
00279 data_size = sizeof(SetGraphMessage_data_t);
00280 data_ptr = malloc(data_size);
00281 memset(data_ptr, 0, data_size);
00282 data = (SetGraphMessage_data_t *)data_ptr;
00283 data_ts = (message_data_ts_t *)data_ptr;
00284 strncpy(data->graph_fsm, ini_graph_fsm, 32);
00285 add_fieldinfo(IFT_STRING, "graph_fsm", 32, data->graph_fsm);
00286 }
00287
00288 SkillerDebugInterface::SetGraphMessage::SetGraphMessage() : Message("SetGraphMessage")
00289 {
00290 data_size = sizeof(SetGraphMessage_data_t);
00291 data_ptr = malloc(data_size);
00292 memset(data_ptr, 0, data_size);
00293 data = (SetGraphMessage_data_t *)data_ptr;
00294 data_ts = (message_data_ts_t *)data_ptr;
00295 add_fieldinfo(IFT_STRING, "graph_fsm", 32, data->graph_fsm);
00296 }
00297
00298
00299 SkillerDebugInterface::SetGraphMessage::~SetGraphMessage()
00300 {
00301 free(data_ptr);
00302 }
00303
00304
00305
00306
00307 SkillerDebugInterface::SetGraphMessage::SetGraphMessage(const SetGraphMessage *m) : Message("SetGraphMessage")
00308 {
00309 data_size = m->data_size;
00310 data_ptr = malloc(data_size);
00311 memcpy(data_ptr, m->data_ptr, data_size);
00312 data = (SetGraphMessage_data_t *)data_ptr;
00313 data_ts = (message_data_ts_t *)data_ptr;
00314 }
00315
00316
00317
00318
00319
00320
00321
00322
00323 char *
00324 SkillerDebugInterface::SetGraphMessage::graph_fsm() const
00325 {
00326 return data->graph_fsm;
00327 }
00328
00329
00330
00331
00332
00333 size_t
00334 SkillerDebugInterface::SetGraphMessage::maxlenof_graph_fsm() const
00335 {
00336 return 32;
00337 }
00338
00339
00340
00341
00342
00343
00344
00345 void
00346 SkillerDebugInterface::SetGraphMessage::set_graph_fsm(const char * new_graph_fsm)
00347 {
00348 strncpy(data->graph_fsm, new_graph_fsm, sizeof(data->graph_fsm));
00349 }
00350
00351
00352
00353
00354
00355
00356 Message *
00357 SkillerDebugInterface::SetGraphMessage::clone() const
00358 {
00359 return new SkillerDebugInterface::SetGraphMessage(this);
00360 }
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 SkillerDebugInterface::SetGraphDirectionMessage::SetGraphDirectionMessage(const GraphDirectionEnum ini_graph_dir) : Message("SetGraphDirectionMessage")
00372 {
00373 data_size = sizeof(SetGraphDirectionMessage_data_t);
00374 data_ptr = malloc(data_size);
00375 memset(data_ptr, 0, data_size);
00376 data = (SetGraphDirectionMessage_data_t *)data_ptr;
00377 data_ts = (message_data_ts_t *)data_ptr;
00378 data->graph_dir = ini_graph_dir;
00379 add_fieldinfo(IFT_ENUM, "graph_dir", 1, &data->graph_dir, "GraphDirectionEnum");
00380 }
00381
00382 SkillerDebugInterface::SetGraphDirectionMessage::SetGraphDirectionMessage() : Message("SetGraphDirectionMessage")
00383 {
00384 data_size = sizeof(SetGraphDirectionMessage_data_t);
00385 data_ptr = malloc(data_size);
00386 memset(data_ptr, 0, data_size);
00387 data = (SetGraphDirectionMessage_data_t *)data_ptr;
00388 data_ts = (message_data_ts_t *)data_ptr;
00389 add_fieldinfo(IFT_ENUM, "graph_dir", 1, &data->graph_dir, "GraphDirectionEnum");
00390 }
00391
00392
00393 SkillerDebugInterface::SetGraphDirectionMessage::~SetGraphDirectionMessage()
00394 {
00395 free(data_ptr);
00396 }
00397
00398
00399
00400
00401 SkillerDebugInterface::SetGraphDirectionMessage::SetGraphDirectionMessage(const SetGraphDirectionMessage *m) : Message("SetGraphDirectionMessage")
00402 {
00403 data_size = m->data_size;
00404 data_ptr = malloc(data_size);
00405 memcpy(data_ptr, m->data_ptr, data_size);
00406 data = (SetGraphDirectionMessage_data_t *)data_ptr;
00407 data_ts = (message_data_ts_t *)data_ptr;
00408 }
00409
00410
00411
00412
00413
00414
00415
00416
00417 SkillerDebugInterface::GraphDirectionEnum
00418 SkillerDebugInterface::SetGraphDirectionMessage::graph_dir() const
00419 {
00420 return data->graph_dir;
00421 }
00422
00423
00424
00425
00426
00427 size_t
00428 SkillerDebugInterface::SetGraphDirectionMessage::maxlenof_graph_dir() const
00429 {
00430 return 1;
00431 }
00432
00433
00434
00435
00436
00437
00438
00439 void
00440 SkillerDebugInterface::SetGraphDirectionMessage::set_graph_dir(const GraphDirectionEnum new_graph_dir)
00441 {
00442 data->graph_dir = new_graph_dir;
00443 }
00444
00445
00446
00447
00448
00449
00450 Message *
00451 SkillerDebugInterface::SetGraphDirectionMessage::clone() const
00452 {
00453 return new SkillerDebugInterface::SetGraphDirectionMessage(this);
00454 }
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465 SkillerDebugInterface::SetGraphColoredMessage::SetGraphColoredMessage(const bool ini_graph_colored) : Message("SetGraphColoredMessage")
00466 {
00467 data_size = sizeof(SetGraphColoredMessage_data_t);
00468 data_ptr = malloc(data_size);
00469 memset(data_ptr, 0, data_size);
00470 data = (SetGraphColoredMessage_data_t *)data_ptr;
00471 data_ts = (message_data_ts_t *)data_ptr;
00472 data->graph_colored = ini_graph_colored;
00473 add_fieldinfo(IFT_BOOL, "graph_colored", 1, &data->graph_colored);
00474 }
00475
00476 SkillerDebugInterface::SetGraphColoredMessage::SetGraphColoredMessage() : Message("SetGraphColoredMessage")
00477 {
00478 data_size = sizeof(SetGraphColoredMessage_data_t);
00479 data_ptr = malloc(data_size);
00480 memset(data_ptr, 0, data_size);
00481 data = (SetGraphColoredMessage_data_t *)data_ptr;
00482 data_ts = (message_data_ts_t *)data_ptr;
00483 add_fieldinfo(IFT_BOOL, "graph_colored", 1, &data->graph_colored);
00484 }
00485
00486
00487 SkillerDebugInterface::SetGraphColoredMessage::~SetGraphColoredMessage()
00488 {
00489 free(data_ptr);
00490 }
00491
00492
00493
00494
00495 SkillerDebugInterface::SetGraphColoredMessage::SetGraphColoredMessage(const SetGraphColoredMessage *m) : Message("SetGraphColoredMessage")
00496 {
00497 data_size = m->data_size;
00498 data_ptr = malloc(data_size);
00499 memcpy(data_ptr, m->data_ptr, data_size);
00500 data = (SetGraphColoredMessage_data_t *)data_ptr;
00501 data_ts = (message_data_ts_t *)data_ptr;
00502 }
00503
00504
00505
00506
00507
00508
00509
00510
00511 bool
00512 SkillerDebugInterface::SetGraphColoredMessage::is_graph_colored() const
00513 {
00514 return data->graph_colored;
00515 }
00516
00517
00518
00519
00520
00521 size_t
00522 SkillerDebugInterface::SetGraphColoredMessage::maxlenof_graph_colored() const
00523 {
00524 return 1;
00525 }
00526
00527
00528
00529
00530
00531
00532
00533 void
00534 SkillerDebugInterface::SetGraphColoredMessage::set_graph_colored(const bool new_graph_colored)
00535 {
00536 data->graph_colored = new_graph_colored;
00537 }
00538
00539
00540
00541
00542
00543
00544 Message *
00545 SkillerDebugInterface::SetGraphColoredMessage::clone() const
00546 {
00547 return new SkillerDebugInterface::SetGraphColoredMessage(this);
00548 }
00549
00550
00551
00552
00553 bool
00554 SkillerDebugInterface::message_valid(const Message *message) const
00555 {
00556 const SetGraphMessage *m0 = dynamic_cast<const SetGraphMessage *>(message);
00557 if ( m0 != NULL ) {
00558 return true;
00559 }
00560 const SetGraphDirectionMessage *m1 = dynamic_cast<const SetGraphDirectionMessage *>(message);
00561 if ( m1 != NULL ) {
00562 return true;
00563 }
00564 const SetGraphColoredMessage *m2 = dynamic_cast<const SetGraphColoredMessage *>(message);
00565 if ( m2 != NULL ) {
00566 return true;
00567 }
00568 return false;
00569 }
00570
00571
00572 EXPORT_INTERFACE(SkillerDebugInterface)
00573
00574
00575
00576 }