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