29SCENARIO(
"Creating and configuring a stdMotionNode",
"[instGraph::stdMotionNode]" )
31 GIVEN(
"a valid XML file, a valid config file")
33 WHEN(
"node is in file, default config")
35 ingr::instGraphXML parentGraph;
37 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim"},
40 mx::app::appConfigurator config;
41 config.readConfig(
"/tmp/stdMotionNode_test.conf");
45 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
57 catch(
const std::exception & e)
59 std::cerr << e.what() <<
"\n";
62 REQUIRE(pass ==
true);
63 REQUIRE(tsn !=
nullptr);
65 REQUIRE( tsn->
name() ==
"fwtelsim");
66 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
74 catch(
const std::exception & e)
76 std::cerr << e.what() <<
"\n";
79 REQUIRE(pass ==
true);
82 REQUIRE(tsn->
device() ==
"fwtelsim");
84 REQUIRE(tsn->
presetDir() == ingr::ioDir::output);
93 WHEN(
"node is in file, full config")
95 ingr::instGraphXML parentGraph;
97 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim",
"fwtelsim",
"fwtelsim",
"fwtelsim",
"fwtelsim",
"fwtelsim",
"fwtelsim",
"fwtelsim",},
98 {
"type",
"device",
"presetPrefix",
"presetDir",
"presetPutName",
"trackingReqKey",
"trackingReqElement",
"trackerKey",
"trackerElement"},
99 {
"stdMotion",
"devtelsim",
"filter",
"input",
"filt1,filt2",
"labrules.info",
"trackreq",
"adc.track",
"toggle"} );
100 mx::app::appConfigurator config;
101 config.readConfig(
"/tmp/stdMotionNode_test.conf");
105 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
117 catch(
const std::exception & e)
119 std::cerr << e.what() <<
"\n";
122 REQUIRE(pass ==
true);
123 REQUIRE(tsn !=
nullptr);
125 REQUIRE( tsn->
name() ==
"fwtelsim");
126 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
134 catch(
const std::exception & e)
136 std::cerr << e.what() <<
"\n";
139 REQUIRE(pass ==
true);
140 REQUIRE(tsn->
device() ==
"devtelsim");
142 REQUIRE(tsn->
presetDir() == ingr::ioDir::input);
150 GIVEN(
"an invalid parent graph")
152 WHEN(
"parent graph is null on construction")
154 ingr::instGraphXML * parentGraph =
nullptr;
163 catch(
const std::exception & e)
165 std::cerr << e.what() <<
"\n";
169 REQUIRE(pass ==
false);
170 REQUIRE(tsn ==
nullptr);
173 WHEN(
"valid xml, parent graph becomes null somehow")
175 ingr::instGraphXML parentGraph;
177 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim"},
180 mx::app::appConfigurator config;
181 config.readConfig(
"/tmp/stdMotionNode_test.conf");
185 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
197 catch(
const std::exception & e)
199 std::cerr << e.what() <<
"\n";
202 REQUIRE(pass ==
true);
203 REQUIRE(tsn !=
nullptr);
205 REQUIRE( tsn->
name() ==
"fwtelsim");
206 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
209 tsn->setParentGraphNull();
217 catch(
const std::exception & e)
219 std::cerr << e.what() <<
"\n";
222 REQUIRE(pass ==
false);
226 GIVEN(
"an invalid config file")
228 WHEN(
"node is in xml file, does not have type set in config")
230 ingr::instGraphXML parentGraph;
232 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim"},
235 mx::app::appConfigurator config;
236 config.readConfig(
"/tmp/stdMotionNode_test.conf");
240 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
253 catch(
const std::exception & e)
255 std::cerr << e.what() <<
"\n";
258 REQUIRE(pass ==
true);
259 REQUIRE(tsn !=
nullptr);
261 REQUIRE( tsn->
name() ==
"fwtelsim");
262 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
271 catch(
const std::exception & e)
273 std::cerr << e.what() <<
"\n";
276 REQUIRE(pass ==
false);
280 WHEN(
"node is in xml file, has wrong type in config")
282 ingr::instGraphXML parentGraph;
284 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim"},
287 mx::app::appConfigurator config;
288 config.readConfig(
"/tmp/stdMotionNode_test.conf");
292 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
305 catch(
const std::exception & e)
307 std::cerr << e.what() <<
"\n";
310 REQUIRE(pass ==
true);
311 REQUIRE(tsn !=
nullptr);
313 REQUIRE( tsn->
name() ==
"fwtelsim");
314 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
323 catch(
const std::exception & e)
325 std::cerr << e.what() <<
"\n";
328 REQUIRE(pass ==
false);
332 WHEN(
"node is in xml file, is not in config")
334 ingr::instGraphXML parentGraph;
336 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"nonode"},
339 mx::app::appConfigurator config;
340 config.readConfig(
"/tmp/stdMotionNode_test.conf");
344 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
357 catch(
const std::exception & e)
359 std::cerr << e.what() <<
"\n";
362 REQUIRE(pass ==
true);
363 REQUIRE(tsn !=
nullptr);
365 REQUIRE( tsn->
name() ==
"fwtelsim");
366 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
375 catch(
const std::exception & e)
377 std::cerr << e.what() <<
"\n";
380 REQUIRE(pass ==
false);
384 WHEN(
"config invalid: changing device")
386 ingr::instGraphXML parentGraph;
388 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
390 {
"stdMotion",
"device2"} );
391 mx::app::appConfigurator config;
392 config.readConfig(
"/tmp/stdMotionNode_test.conf");
396 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
409 catch(
const std::exception & e)
411 std::cerr << e.what() <<
"\n";
414 REQUIRE(pass ==
true);
415 REQUIRE(tsn !=
nullptr);
417 REQUIRE( tsn->
name() ==
"fwtelsim");
418 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
429 catch(
const std::exception & e)
431 std::cerr << e.what() <<
"\n";
434 REQUIRE(pass ==
false);
438 WHEN(
"config invalid: changing presetName")
440 ingr::instGraphXML parentGraph;
442 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
443 {
"type",
"presetPrefix"},
444 {
"stdMotion",
"preset2"} );
445 mx::app::appConfigurator config;
446 config.readConfig(
"/tmp/stdMotionNode_test.conf");
450 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
463 catch(
const std::exception & e)
465 std::cerr << e.what() <<
"\n";
468 REQUIRE(pass ==
true);
469 REQUIRE(tsn !=
nullptr);
471 REQUIRE( tsn->
name() ==
"fwtelsim");
472 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
483 catch(
const std::exception & e)
485 std::cerr << e.what() <<
"\n";
488 REQUIRE(pass ==
false);
492 WHEN(
"config invalid: invalid presetDir")
494 ingr::instGraphXML parentGraph;
496 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
497 {
"type",
"presetDir"},
498 {
"stdMotion",
"wrongput"} );
499 mx::app::appConfigurator config;
500 config.readConfig(
"/tmp/stdMotionNode_test.conf");
504 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
517 catch(
const std::exception & e)
519 std::cerr << e.what() <<
"\n";
522 REQUIRE(pass ==
true);
523 REQUIRE(tsn !=
nullptr);
525 REQUIRE( tsn->
name() ==
"fwtelsim");
526 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
535 catch(
const std::exception & e)
537 std::cerr << e.what() <<
"\n";
540 REQUIRE(pass ==
false);
544 WHEN(
"config invalid: presetPutName empty")
546 ingr::instGraphXML parentGraph;
548 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
549 {
"type",
"presetPutName"},
551 mx::app::appConfigurator config;
552 config.readConfig(
"/tmp/stdMotionNode_test.conf");
556 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
569 catch(
const std::exception & e)
571 std::cerr << e.what() <<
"\n";
574 REQUIRE(pass ==
true);
575 REQUIRE(tsn !=
nullptr);
577 REQUIRE( tsn->
name() ==
"fwtelsim");
578 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
587 catch(
const std::exception & e)
589 std::cerr << e.what() <<
"\n";
592 REQUIRE(pass ==
false);
596 WHEN(
"config invalid: only trackingReqKey provided")
598 ingr::instGraphXML parentGraph;
600 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
601 {
"type",
"trackingReqKey"},
602 {
"stdMotion",
"labrules.info"} );
603 mx::app::appConfigurator config;
604 config.readConfig(
"/tmp/stdMotionNode_test.conf");
608 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
621 catch(
const std::exception & e)
623 std::cerr << e.what() <<
"\n";
626 REQUIRE(pass ==
true);
627 REQUIRE(tsn !=
nullptr);
629 REQUIRE( tsn->
name() ==
"fwtelsim");
630 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
639 catch(
const std::exception & e)
641 std::cerr << e.what() <<
"\n";
644 REQUIRE(pass ==
false);
648 WHEN(
"config invalid: only trackingReqElement provided")
650 ingr::instGraphXML parentGraph;
652 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
653 {
"type",
"trackingReqElement"},
654 {
"stdMotion",
"toggle"} );
655 mx::app::appConfigurator config;
656 config.readConfig(
"/tmp/stdMotionNode_test.conf");
660 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
673 catch(
const std::exception & e)
675 std::cerr << e.what() <<
"\n";
678 REQUIRE(pass ==
true);
679 REQUIRE(tsn !=
nullptr);
681 REQUIRE( tsn->
name() ==
"fwtelsim");
682 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
691 catch(
const std::exception & e)
693 std::cerr << e.what() <<
"\n";
696 REQUIRE(pass ==
false);
700 WHEN(
"config invalid: only trackerKey provided")
702 ingr::instGraphXML parentGraph;
704 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
705 {
"type",
"trackerKey"},
706 {
"stdMotion",
"adctrack.tracking"} );
707 mx::app::appConfigurator config;
708 config.readConfig(
"/tmp/stdMotionNode_test.conf");
712 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
725 catch(
const std::exception & e)
727 std::cerr << e.what() <<
"\n";
730 REQUIRE(pass ==
true);
731 REQUIRE(tsn !=
nullptr);
733 REQUIRE( tsn->
name() ==
"fwtelsim");
734 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
743 catch(
const std::exception & e)
745 std::cerr << e.what() <<
"\n";
748 REQUIRE(pass ==
false);
752 WHEN(
"config invalid: only trackerElement provided")
754 ingr::instGraphXML parentGraph;
756 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim"},
757 {
"type",
"trackerElement"},
758 {
"stdMotion",
"toggle"} );
759 mx::app::appConfigurator config;
760 config.readConfig(
"/tmp/stdMotionNode_test.conf");
764 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
777 catch(
const std::exception & e)
779 std::cerr << e.what() <<
"\n";
782 REQUIRE(pass ==
true);
783 REQUIRE(tsn !=
nullptr);
785 REQUIRE( tsn->
name() ==
"fwtelsim");
786 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
795 catch(
const std::exception & e)
797 std::cerr << e.what() <<
"\n";
800 REQUIRE(pass ==
false);
804 WHEN(
"config invalid: only trackingReqKey and trackingReqElement provided")
806 ingr::instGraphXML parentGraph;
808 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim",
"fwtelsim"},
809 {
"type",
"trackingReqKey",
"trackingReqElement"},
810 {
"stdMotion",
"labrules.info",
"adcTrackingReq"} );
811 mx::app::appConfigurator config;
812 config.readConfig(
"/tmp/stdMotionNode_test.conf");
816 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
829 catch(
const std::exception & e)
831 std::cerr << e.what() <<
"\n";
834 REQUIRE(pass ==
true);
835 REQUIRE(tsn !=
nullptr);
837 REQUIRE( tsn->
name() ==
"fwtelsim");
838 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
847 catch(
const std::exception & e)
849 std::cerr << e.what() <<
"\n";
852 REQUIRE(pass ==
false);
856 WHEN(
"config invalid: only trackerKey and trackerElement provided")
858 ingr::instGraphXML parentGraph;
860 mx::app::writeConfigFile(
"/tmp/stdMotionNode_test.conf", {
"fwtelsim",
"fwtelsim",
"fwtelsim"},
861 {
"type",
"trackerKey",
"trackerElement"},
862 {
"stdMotion",
"adctrack.tracking",
"toggle"} );
863 mx::app::appConfigurator config;
864 config.readConfig(
"/tmp/stdMotionNode_test.conf");
868 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
881 catch(
const std::exception & e)
883 std::cerr << e.what() <<
"\n";
886 REQUIRE(pass ==
true);
887 REQUIRE(tsn !=
nullptr);
889 REQUIRE( tsn->
name() ==
"fwtelsim");
890 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
899 catch(
const std::exception & e)
901 std::cerr << e.what() <<
"\n";
904 REQUIRE(pass ==
false);
910SCENARIO(
"Sending Properties to a stdMotionNode",
"[instGraph::stdMotionNode]" )
912 GIVEN(
"a configured stdMotionNode with tracking")
915 ingr::instGraphXML parentGraph;
919 int rv = parentGraph.loadXMLFile(emsg,
"/tmp/xigNode_test.xml");
931 catch(
const std::exception & e)
933 std::cerr << e.what() <<
"\n";
936 REQUIRE(pass ==
true);
937 REQUIRE(tsn !=
nullptr);
939 REQUIRE( tsn->
name() ==
"fwtelsim");
940 REQUIRE( tsn->
node()->name() ==
"fwtelsim");
949 WHEN(
"tracking off, tracking not rquired")
951 pcf::IndiProperty ipSend;
952 ipSend.setDevice(
"adctrack");
953 ipSend.setName(
"tracking");
954 ipSend.add(pcf::IndiElement(
"toggle"));
955 ipSend[
"toggle"].setSwitchState(pcf::IndiElement::Off);
959 pcf::IndiProperty ipSend2;
960 ipSend2.setDevice(
"labrules");
961 ipSend2.setName(
"info");
962 ipSend2.add(pcf::IndiElement(
"adcTrackReq"));
963 ipSend2[
"adcTrackReq"].setSwitchState(pcf::IndiElement::Off);
967 pcf::IndiProperty ipSend3;
968 ipSend3.setDevice(
"fwtelsim");
969 ipSend3.setName(
"filterName");
970 ipSend3.add(pcf::IndiElement(
"filt1"));
971 ipSend3[
"filt1"].setSwitchState(pcf::IndiElement::On);
972 ipSend3.add(pcf::IndiElement(
"none"));
973 ipSend3[
"none"].setSwitchState(pcf::IndiElement::Off);
979 pcf::IndiProperty ipSend4;
980 ipSend4.setDevice(
"fwtelsim");
981 ipSend4.setName(
"fsm");
982 ipSend4.add(pcf::IndiElement(
"state"));
983 ipSend4[
"state"].set(
"READY");
987 REQUIRE(tsn->
curLabel() ==
"filt1");
989 ipSend2[
"adcTrackReq"].setSwitchState(pcf::IndiElement::On);
992 REQUIRE(tsn->
curLabel() ==
"not tracking");
994 ipSend[
"toggle"].setSwitchState(pcf::IndiElement::On);
997 REQUIRE(tsn->
curLabel() ==
"tracking");
999 ipSend4[
"state"].set(
"OPERATING");
1002 REQUIRE(tsn->
curLabel() ==
"tracking");
1004 ipSend2[
"adcTrackReq"].setSwitchState(pcf::IndiElement::Off);
1008 REQUIRE(tsn->
curLabel() ==
"tracking");
1010 ipSend[
"toggle"].setSwitchState(pcf::IndiElement::Off);
1016 ipSend3[
"filt1"].setSwitchState(pcf::IndiElement::Off);
1019 ipSend4[
"state"].set(
"READY");
1025 ipSend3[
"filt1"].setSwitchState(pcf::IndiElement::On);
1029 REQUIRE(tsn->
curLabel() ==
"filt1");
1031 ipSend3[
"filt1"].setSwitchState(pcf::IndiElement::Off);
1032 ipSend3[
"none"].setSwitchState(pcf::IndiElement::On);
1039 ipSend3[
"filt1"].setSwitchState(pcf::IndiElement::On);
1040 ipSend3[
"none"].setSwitchState(pcf::IndiElement::Off);
1045 REQUIRE(tsn->
curLabel() ==
"filt1");