50SCENARIO(
"Creating and configuring a stdMotionNode",
"[instGraph::stdMotionNode]" )
53 #ifdef XINSTGRAPH_TEST_DOXYGEN_REF
59 GIVEN(
"a valid XML file, a valid config file" )
61 WHEN(
"node is in file, default config" )
63 ingr::instGraphXML parentGraph;
65 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim" }, {
"type" }, {
"stdMotion" } );
66 mx::app::appConfigurator config;
67 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
71 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
74 REQUIRE( emsg ==
"" );
83 catch(
const std::exception &e )
85 std::cerr << e.what() <<
"\n";
88 REQUIRE( pass ==
true );
89 REQUIRE( tsn !=
nullptr );
91 REQUIRE( tsn->
name() ==
"fwtelsim" );
92 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
100 catch(
const std::exception &e )
102 std::cerr << e.what() <<
"\n";
105 REQUIRE( pass ==
true );
108 REQUIRE( tsn->
device() ==
"fwtelsim" );
110 REQUIRE( tsn->
presetDir() == ingr::ioDir::output );
119 WHEN(
"node is in file, full config" )
121 ingr::instGraphXML parentGraph;
123 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
141 "trackingReqElement",
153 mx::app::appConfigurator config;
154 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
158 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
161 REQUIRE( emsg ==
"" );
170 catch(
const std::exception &e )
172 std::cerr << e.what() <<
"\n";
175 REQUIRE( pass ==
true );
176 REQUIRE( tsn !=
nullptr );
178 REQUIRE( tsn->
name() ==
"fwtelsim" );
179 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
187 catch(
const std::exception &e )
189 std::cerr << e.what() <<
"\n";
192 REQUIRE( pass ==
true );
193 REQUIRE( tsn->
device() ==
"devtelsim" );
195 REQUIRE( tsn->
presetDir() == ingr::ioDir::input );
203 GIVEN(
"an invalid parent graph" )
205 WHEN(
"parent graph is null on construction" )
207 ingr::instGraphXML *parentGraph =
nullptr;
216 catch(
const std::exception &e )
218 std::cerr << e.what() <<
"\n";
222 REQUIRE( pass ==
false );
223 REQUIRE( tsn ==
nullptr );
226 WHEN(
"valid xml, parent graph becomes null somehow" )
228 ingr::instGraphXML parentGraph;
230 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim" }, {
"type" }, {
"stdMotion" } );
231 mx::app::appConfigurator config;
232 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
236 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
239 REQUIRE( emsg ==
"" );
248 catch(
const std::exception &e )
250 std::cerr << e.what() <<
"\n";
253 REQUIRE( pass ==
true );
254 REQUIRE( tsn !=
nullptr );
256 REQUIRE( tsn->
name() ==
"fwtelsim" );
257 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
260 tsn->setParentGraphNull();
268 catch(
const std::exception &e )
270 std::cerr << e.what() <<
"\n";
273 REQUIRE( pass ==
false );
277 GIVEN(
"an invalid config file" )
279 WHEN(
"node is in xml file, does not have type set in config" )
281 ingr::instGraphXML parentGraph;
283 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim" }, {
"" }, {
"" } );
284 mx::app::appConfigurator config;
285 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
289 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
292 REQUIRE( emsg ==
"" );
302 catch(
const std::exception &e )
304 std::cerr << e.what() <<
"\n";
307 REQUIRE( pass ==
true );
308 REQUIRE( tsn !=
nullptr );
310 REQUIRE( tsn->
name() ==
"fwtelsim" );
311 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
320 catch(
const std::exception &e )
322 std::cerr << e.what() <<
"\n";
325 REQUIRE( pass ==
false );
328 WHEN(
"node is in xml file, has wrong type in config" )
330 ingr::instGraphXML parentGraph;
332 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim" }, {
"type" }, {
"xigNode" } );
333 mx::app::appConfigurator config;
334 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
338 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
341 REQUIRE( emsg ==
"" );
351 catch(
const std::exception &e )
353 std::cerr << e.what() <<
"\n";
356 REQUIRE( pass ==
true );
357 REQUIRE( tsn !=
nullptr );
359 REQUIRE( tsn->
name() ==
"fwtelsim" );
360 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
369 catch(
const std::exception &e )
371 std::cerr << e.what() <<
"\n";
374 REQUIRE( pass ==
false );
377 WHEN(
"node is in xml file, is not in config" )
379 ingr::instGraphXML parentGraph;
381 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"nonode" }, {
"type" }, {
"stdMotion" } );
382 mx::app::appConfigurator config;
383 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
387 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
390 REQUIRE( emsg ==
"" );
400 catch(
const std::exception &e )
402 std::cerr << e.what() <<
"\n";
405 REQUIRE( pass ==
true );
406 REQUIRE( tsn !=
nullptr );
408 REQUIRE( tsn->
name() ==
"fwtelsim" );
409 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
418 catch(
const std::exception &e )
420 std::cerr << e.what() <<
"\n";
423 REQUIRE( pass ==
false );
426 WHEN(
"config invalid: changing device" )
428 ingr::instGraphXML parentGraph;
430 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
431 {
"fwtelsim",
"fwtelsim" },
432 {
"type",
"device" },
433 {
"stdMotion",
"device2" } );
434 mx::app::appConfigurator config;
435 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
439 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
442 REQUIRE( emsg ==
"" );
452 catch(
const std::exception &e )
454 std::cerr << e.what() <<
"\n";
457 REQUIRE( pass ==
true );
458 REQUIRE( tsn !=
nullptr );
460 REQUIRE( tsn->
name() ==
"fwtelsim" );
461 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
472 catch(
const std::exception &e )
474 std::cerr << e.what() <<
"\n";
477 REQUIRE( pass ==
false );
480 WHEN(
"config invalid: changing presetName" )
482 ingr::instGraphXML parentGraph;
484 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
485 {
"fwtelsim",
"fwtelsim" },
486 {
"type",
"presetPrefix" },
487 {
"stdMotion",
"preset2" } );
488 mx::app::appConfigurator config;
489 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
493 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
496 REQUIRE( emsg ==
"" );
506 catch(
const std::exception &e )
508 std::cerr << e.what() <<
"\n";
511 REQUIRE( pass ==
true );
512 REQUIRE( tsn !=
nullptr );
514 REQUIRE( tsn->
name() ==
"fwtelsim" );
515 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
526 catch(
const std::exception &e )
528 std::cerr << e.what() <<
"\n";
531 REQUIRE( pass ==
false );
534 WHEN(
"config invalid: invalid presetDir" )
536 ingr::instGraphXML parentGraph;
538 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
539 {
"fwtelsim",
"fwtelsim" },
540 {
"type",
"presetDir" },
541 {
"stdMotion",
"wrongput" } );
542 mx::app::appConfigurator config;
543 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
547 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
550 REQUIRE( emsg ==
"" );
560 catch(
const std::exception &e )
562 std::cerr << e.what() <<
"\n";
565 REQUIRE( pass ==
true );
566 REQUIRE( tsn !=
nullptr );
568 REQUIRE( tsn->
name() ==
"fwtelsim" );
569 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
579 catch(
const std::exception &e )
581 std::cerr << e.what() <<
"\n";
584 REQUIRE( pass ==
false );
587 WHEN(
"config invalid: presetPutName empty" )
589 ingr::instGraphXML parentGraph;
591 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
592 {
"fwtelsim",
"fwtelsim" },
593 {
"type",
"presetPutName" },
594 {
"stdMotion",
"" } );
595 mx::app::appConfigurator config;
596 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
600 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
603 REQUIRE( emsg ==
"" );
613 catch(
const std::exception &e )
615 std::cerr << e.what() <<
"\n";
618 REQUIRE( pass ==
true );
619 REQUIRE( tsn !=
nullptr );
621 REQUIRE( tsn->
name() ==
"fwtelsim" );
622 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
631 catch(
const std::exception &e )
633 std::cerr << e.what() <<
"\n";
636 REQUIRE( pass ==
false );
639 WHEN(
"config invalid: only trackingReqKey provided" )
641 ingr::instGraphXML parentGraph;
643 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
644 {
"fwtelsim",
"fwtelsim" },
645 {
"type",
"trackingReqKey" },
646 {
"stdMotion",
"labrules.info" } );
647 mx::app::appConfigurator config;
648 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
652 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
655 REQUIRE( emsg ==
"" );
665 catch(
const std::exception &e )
667 std::cerr << e.what() <<
"\n";
670 REQUIRE( pass ==
true );
671 REQUIRE( tsn !=
nullptr );
673 REQUIRE( tsn->
name() ==
"fwtelsim" );
674 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
683 catch(
const std::exception &e )
685 std::cerr << e.what() <<
"\n";
688 REQUIRE( pass ==
false );
691 WHEN(
"config invalid: only trackingReqElement provided" )
693 ingr::instGraphXML parentGraph;
695 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
696 {
"fwtelsim",
"fwtelsim" },
697 {
"type",
"trackingReqElement" },
698 {
"stdMotion",
"toggle" } );
699 mx::app::appConfigurator config;
700 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
704 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
707 REQUIRE( emsg ==
"" );
717 catch(
const std::exception &e )
719 std::cerr << e.what() <<
"\n";
722 REQUIRE( pass ==
true );
723 REQUIRE( tsn !=
nullptr );
725 REQUIRE( tsn->
name() ==
"fwtelsim" );
726 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
735 catch(
const std::exception &e )
737 std::cerr << e.what() <<
"\n";
740 REQUIRE( pass ==
false );
743 WHEN(
"config invalid: only trackerKey provided" )
745 ingr::instGraphXML parentGraph;
747 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
748 {
"fwtelsim",
"fwtelsim" },
749 {
"type",
"trackerKey" },
750 {
"stdMotion",
"adctrack.tracking" } );
751 mx::app::appConfigurator config;
752 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
756 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
759 REQUIRE( emsg ==
"" );
769 catch(
const std::exception &e )
771 std::cerr << e.what() <<
"\n";
774 REQUIRE( pass ==
true );
775 REQUIRE( tsn !=
nullptr );
777 REQUIRE( tsn->
name() ==
"fwtelsim" );
778 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
787 catch(
const std::exception &e )
789 std::cerr << e.what() <<
"\n";
792 REQUIRE( pass ==
false );
795 WHEN(
"config invalid: only trackerElement provided" )
797 ingr::instGraphXML parentGraph;
799 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
800 {
"fwtelsim",
"fwtelsim" },
801 {
"type",
"trackerElement" },
802 {
"stdMotion",
"toggle" } );
803 mx::app::appConfigurator config;
804 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
808 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
811 REQUIRE( emsg ==
"" );
821 catch(
const std::exception &e )
823 std::cerr << e.what() <<
"\n";
826 REQUIRE( pass ==
true );
827 REQUIRE( tsn !=
nullptr );
829 REQUIRE( tsn->
name() ==
"fwtelsim" );
830 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
839 catch(
const std::exception &e )
841 std::cerr << e.what() <<
"\n";
844 REQUIRE( pass ==
false );
847 WHEN(
"config invalid: only trackingReqKey and trackingReqElement provided" )
849 ingr::instGraphXML parentGraph;
851 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
852 {
"fwtelsim",
"fwtelsim",
"fwtelsim" },
853 {
"type",
"trackingReqKey",
"trackingReqElement" },
854 {
"stdMotion",
"labrules.info",
"adcTrackingReq" } );
855 mx::app::appConfigurator config;
856 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
860 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
863 REQUIRE( emsg ==
"" );
873 catch(
const std::exception &e )
875 std::cerr << e.what() <<
"\n";
878 REQUIRE( pass ==
true );
879 REQUIRE( tsn !=
nullptr );
881 REQUIRE( tsn->
name() ==
"fwtelsim" );
882 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
891 catch(
const std::exception &e )
893 std::cerr << e.what() <<
"\n";
896 REQUIRE( pass ==
false );
899 WHEN(
"config invalid: only trackerKey and trackerElement provided" )
901 ingr::instGraphXML parentGraph;
903 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf",
904 {
"fwtelsim",
"fwtelsim",
"fwtelsim" },
905 {
"type",
"trackerKey",
"trackerElement" },
906 {
"stdMotion",
"adctrack.tracking",
"toggle" } );
907 mx::app::appConfigurator config;
908 config.readConfig(
"/tmp/stdMotionNode_test.conf" );
912 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
915 REQUIRE( emsg ==
"" );
925 catch(
const std::exception &e )
927 std::cerr << e.what() <<
"\n";
930 REQUIRE( pass ==
true );
931 REQUIRE( tsn !=
nullptr );
933 REQUIRE( tsn->
name() ==
"fwtelsim" );
934 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
943 catch(
const std::exception &e )
945 std::cerr << e.what() <<
"\n";
948 REQUIRE( pass ==
false );
957SCENARIO(
"Sending Properties to a stdMotionNode",
"[instGraph::stdMotionNode]" )
959 GIVEN(
"a configured stdMotionNode with tracking" )
962 ingr::instGraphXML parentGraph;
966 int rv = parentGraph.loadXMLFile( emsg,
"/tmp/xigNode_test.xml" );
969 REQUIRE( emsg ==
"" );
978 catch(
const std::exception &e )
980 std::cerr << e.what() <<
"\n";
983 REQUIRE( pass ==
true );
984 REQUIRE( tsn !=
nullptr );
986 REQUIRE( tsn->
name() ==
"fwtelsim" );
987 REQUIRE( tsn->
node()->name() ==
"fwtelsim" );
989 tsn->
device(
"fwtelsim" );
996 WHEN(
"tracking off, tracking not rquired" )
998 pcf::IndiProperty ipSend;
999 ipSend.setDevice(
"adctrack" );
1000 ipSend.setName(
"tracking" );
1001 ipSend.add( pcf::IndiElement(
"toggle" ) );
1002 ipSend[
"toggle"].setSwitchState( pcf::IndiElement::Off );
1006 pcf::IndiProperty ipSend2;
1007 ipSend2.setDevice(
"labrules" );
1008 ipSend2.setName(
"info" );
1009 ipSend2.add( pcf::IndiElement(
"adcTrackReq" ) );
1010 ipSend2[
"adcTrackReq"].setSwitchState( pcf::IndiElement::Off );
1014 pcf::IndiProperty ipSend3;
1015 ipSend3.setDevice(
"fwtelsim" );
1016 ipSend3.setName(
"filterName" );
1017 ipSend3.add( pcf::IndiElement(
"filt1" ) );
1018 ipSend3[
"filt1"].setSwitchState( pcf::IndiElement::On );
1019 ipSend3.add( pcf::IndiElement(
"none" ) );
1020 ipSend3[
"none"].setSwitchState( pcf::IndiElement::Off );
1024 REQUIRE( tsn->
curLabel() ==
"off" );
1026 pcf::IndiProperty ipSend4;
1027 ipSend4.setDevice(
"fwtelsim" );
1028 ipSend4.setName(
"fsm" );
1029 ipSend4.add( pcf::IndiElement(
"state" ) );
1030 ipSend4[
"state"].set(
"READY" );
1034 REQUIRE( tsn->
curLabel() ==
"filt1" );
1036 ipSend2[
"adcTrackReq"].setSwitchState( pcf::IndiElement::On );
1039 REQUIRE( tsn->
curLabel() ==
"not tracking" );
1041 ipSend[
"toggle"].setSwitchState( pcf::IndiElement::On );
1044 REQUIRE( tsn->
curLabel() ==
"tracking" );
1046 ipSend4[
"state"].set(
"OPERATING" );
1049 REQUIRE( tsn->
curLabel() ==
"tracking" );
1051 ipSend2[
"adcTrackReq"].setSwitchState( pcf::IndiElement::Off );
1055 REQUIRE( tsn->
curLabel() ==
"tracking" );
1057 ipSend[
"toggle"].setSwitchState( pcf::IndiElement::Off );
1061 REQUIRE( tsn->
curLabel() ==
"off" );
1063 ipSend3[
"filt1"].setSwitchState( pcf::IndiElement::Off );
1066 ipSend4[
"state"].set(
"READY" );
1070 REQUIRE( tsn->
curLabel() ==
"off" );
1072 ipSend3[
"filt1"].setSwitchState( pcf::IndiElement::On );
1076 REQUIRE( tsn->
curLabel() ==
"filt1" );
1078 ipSend3[
"filt1"].setSwitchState( pcf::IndiElement::Off );
1079 ipSend3[
"none"].setSwitchState( pcf::IndiElement::On );
1084 REQUIRE( tsn->
curLabel() ==
"off" );
1086 ipSend3[
"filt1"].setSwitchState( pcf::IndiElement::On );
1087 ipSend3[
"none"].setSwitchState( pcf::IndiElement::Off );
1092 REQUIRE( tsn->
curLabel() ==
"filt1" );