diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index f65ccf1b8..d09090812 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1527,7 +1527,7 @@ std::string CmdProxy::ROI(int action) { t.xmin = StringTo(args[0]); t.xmax = StringTo(args[1]); det->setROI(t, det_id); - os << '[' << t.xmin << ", " << t.xmax << "] \n"; + os << '[' << t.xmin << ", " << t.xmax << "]\n"; } else { throw sls::RuntimeError("Unknown action"); } diff --git a/slsDetectorSoftware/tests/test-CmdProxy-gotthard.cpp b/slsDetectorSoftware/tests/test-CmdProxy-gotthard.cpp index 8528cecf2..189ad6741 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-gotthard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-gotthard.cpp @@ -94,3 +94,62 @@ TEST_CASE("Setting and reading back GOTTHARD dacs", "[.cmd][.dacs][.new]") { REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET)); } } + +/* Gotthard Specific */ + +TEST_CASE("roi", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD) { + auto prev_val = det.getROI(); + { + std::ostringstream oss; + proxy.Call("roi", {"0", "255"}, -1, PUT, oss); + REQUIRE(oss.str() == "roi [0, 255]\n"); + } + { + std::ostringstream oss; + proxy.Call("roi", {"256", "511"}, -1, PUT, oss); + REQUIRE(oss.str() == "roi [256, 511]\n"); + } + REQUIRE_THROWS(proxy.Call("roi", {"0", "256"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setROI(prev_val[i], i); + } + } else { + REQUIRE_THROWS(proxy.Call("roi", {}, -1, GET)); + } +} + +TEST_CASE("clearroi", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD) { + auto prev_val = det.getROI(); + { + std::ostringstream oss; + proxy.Call("clearroi", {}, -1, PUT, oss); + REQUIRE(oss.str() == "clearroi [-1, -1]\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setROI(prev_val[i], i); + } + } else { + REQUIRE_THROWS(proxy.Call("clearroi", {}, -1, PUT)); + } +} + +TEST_CASE("exptimel", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::GOTTHARD) { + REQUIRE_NOTHROW(proxy.Call("exptimel", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("exptimel", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp b/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp index ab7c19649..052f4a97e 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp @@ -15,82 +15,6 @@ using sls::Detector; using test::GET; using test::PUT; -/* acquisition parameters */ - -TEST_CASE("bursts", "[.cmd][.new]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::GOTTHARD2) { - auto prev_burst = - det.getNumberOfBursts().tsquash("#bursts should be same to test"); - auto prev_trigger = - det.getNumberOfFrames().tsquash("#frames should be same to test"); - auto prev_frames = det.getNumberOfTriggers().tsquash( - "#triggers should be same to test"); - auto prev_timingMode = det.getTimingMode(); - auto prev_burstMode = det.getBurstMode(); - // changing continuous mode frames and bursts - det.setBurstMode(defs::BURST_INTERNAL); - det.setTimingMode(defs::AUTO_TIMING); - { - std::ostringstream oss; - proxy.Call("bursts", {"3"}, -1, PUT, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - REQUIRE_THROWS(proxy.Call("bursts", {"0"}, -1, PUT)); - // trigger mode: reg set to 1, but bursts must be same - det.setTimingMode(defs::TRIGGER_EXPOSURE); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - det.setTimingMode(defs::AUTO_TIMING); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - // continuous mode: reg set to #frames, - // but bursts should return same value - det.setBurstMode(defs::BURST_OFF); - det.setNumberOfFrames(2); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - det.setTimingMode(defs::TRIGGER_EXPOSURE); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - det.setBurstMode(defs::BURST_INTERNAL); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - // set to previous values - det.setNumberOfBursts(prev_burst); - det.setNumberOfFrames(prev_frames); - det.setNumberOfTriggers(prev_trigger); - for (int i = 0; i != det.size(); ++i) { - det.setTimingMode(prev_timingMode[i], {i}); - det.setBurstMode(prev_burstMode[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("bursts", {}, -1, GET)); - } -} - /* dacs */ TEST_CASE("Setting and reading back GOTTHARD2 dacs", "[.cmd][.dacs][.new]") { @@ -262,7 +186,164 @@ TEST_CASE("vchip_cs", "[.cmd][.onchipdacs][.new]") { } } -TEST_CASE("burstmode", "[.cmd]") { +/* Gotthard2 Specific */ + +TEST_CASE("bursts", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::GOTTHARD2) { + auto prev_burst = + det.getNumberOfBursts().tsquash("#bursts should be same to test"); + auto prev_trigger = + det.getNumberOfFrames().tsquash("#frames should be same to test"); + auto prev_frames = det.getNumberOfTriggers().tsquash( + "#triggers should be same to test"); + auto prev_timingMode = det.getTimingMode(); + auto prev_burstMode = det.getBurstMode(); + // changing continuous mode frames and bursts + det.setBurstMode(defs::BURST_INTERNAL); + det.setTimingMode(defs::AUTO_TIMING); + { + std::ostringstream oss; + proxy.Call("bursts", {"3"}, -1, PUT, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + REQUIRE_THROWS(proxy.Call("bursts", {"0"}, -1, PUT)); + // trigger mode: reg set to 1, but bursts must be same + det.setTimingMode(defs::TRIGGER_EXPOSURE); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + det.setTimingMode(defs::AUTO_TIMING); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + // continuous mode: reg set to #frames, + // but bursts should return same value + det.setBurstMode(defs::BURST_OFF); + det.setNumberOfFrames(2); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + det.setTimingMode(defs::TRIGGER_EXPOSURE); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + det.setBurstMode(defs::BURST_INTERNAL); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + // set to previous values + det.setNumberOfBursts(prev_burst); + det.setNumberOfFrames(prev_frames); + det.setNumberOfTriggers(prev_trigger); + for (int i = 0; i != det.size(); ++i) { + det.setTimingMode(prev_timingMode[i], {i}); + det.setBurstMode(prev_burstMode[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("bursts", {}, -1, GET)); + } +} + +TEST_CASE("burstperiod", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + auto previous = det.getBurstPeriod(); + + std::ostringstream oss_set, oss_get; + proxy.Call("burstperiod", {"30ms"}, -1, PUT, oss_set); + REQUIRE(oss_set.str() == "burstperiod 30ms\n"); + proxy.Call("burstperiod", {}, -1, GET, oss_get); + REQUIRE(oss_get.str() == "burstperiod 30ms\n"); + // Reset to previous value + for (int i = 0; i != det.size(); ++i) { + det.setBurstPeriod(previous[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("burstperiod", {}, -1, GET)); + } +} + +TEST_CASE("inj_ch", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + REQUIRE_THROWS( + proxy.Call("inj_ch", {"-1", "1"}, -1, PUT)); // invalid offset + REQUIRE_THROWS( + proxy.Call("inj_ch", {"0", "0"}, -1, PUT)); // invalid increment + { + std::ostringstream oss; + proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss); + REQUIRE(oss.str() == "inj_ch [0, 1]\n"); + } + { + std::ostringstream oss; + proxy.Call("inj_ch", {}, -1, GET, oss); + REQUIRE(oss.str() == "inj_ch [0, 1]\n"); + } + } else { + REQUIRE_THROWS(proxy.Call("inj_ch", {}, -1, GET)); + } +} + +TEST_CASE("vetophoton", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET)); + REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1, + PUT)); // invalid chip index + REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1, + PUT)); // invalid photon number + REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1, + PUT)); // invald file + } else { + REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET)); + } +} + +TEST_CASE("vetoref", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1, + PUT)); // invalid chip index + REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT)); + } +} + +TEST_CASE("burstmode", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -293,92 +374,7 @@ TEST_CASE("burstmode", "[.cmd]") { } } -TEST_CASE("vetoref", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1, - PUT)); // invalid chip index - REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT)); - } else { - REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT)); - } -} - -TEST_CASE("vetophoton", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET)); - REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET)); - REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1, - PUT)); // invalid chip index - REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1, - PUT)); // invalid photon number - REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1, - PUT)); // invald file - } else { - REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET)); - } -} - -TEST_CASE("inj_ch", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - auto inj = det.getInjectChannel(); - REQUIRE_THROWS( - proxy.Call("inj_ch", {"-1", "1"}, -1, PUT)); // invalid offset - REQUIRE_THROWS( - proxy.Call("inj_ch", {"0", "0"}, -1, PUT)); // invalid increment - { - std::ostringstream oss; - proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss); - REQUIRE(oss.str() == "inj_ch [0, 1]\n"); - } - { - std::ostringstream oss; - proxy.Call("inj_ch", {}, -1, GET, oss); - REQUIRE(oss.str() == "inj_ch [0, 1]\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setInjectChannel(inj[i][0], inj[i][1], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("inj_ch", {}, -1, GET)); - } -} - -TEST_CASE("burstperiod", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - auto previous = det.getBurstPeriod(); - - std::ostringstream oss_set, oss_get; - proxy.Call("burstperiod", {"30ms"}, -1, PUT, oss_set); - REQUIRE(oss_set.str() == "burstperiod 30ms\n"); - proxy.Call("burstperiod", {}, -1, GET, oss_get); - REQUIRE(oss_get.str() == "burstperiod 30ms\n"); - // Reset to previous value - for (int i = 0; i != det.size(); ++i) { - det.setBurstPeriod(previous[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("burstperiod", {}, -1, GET)); - } -} - -TEST_CASE("currentsource", "[.cmd]") { +TEST_CASE("currentsource", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -408,7 +404,7 @@ TEST_CASE("currentsource", "[.cmd]") { } } -TEST_CASE("timingsource", "[.cmd]") { +TEST_CASE("timingsource", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -437,3 +433,33 @@ TEST_CASE("timingsource", "[.cmd]") { REQUIRE_THROWS(proxy.Call("timingsource", {}, -1, GET)); } } + +TEST_CASE("veto", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + auto prev_val = det.getVeto(); + { + std::ostringstream oss; + proxy.Call("veto", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "veto 1\n"); + } + { + std::ostringstream oss; + proxy.Call("veto", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "veto 0\n"); + } + { + std::ostringstream oss; + proxy.Call("veto", {}, -1, GET, oss); + REQUIRE(oss.str() == "veto 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setVeto(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("veto", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp b/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp index fff13a553..798683c7a 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp @@ -89,7 +89,9 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs][.new]") { } } -TEST_CASE("counters", "[.cmd]") { +/* Mythen3 Specific */ + +TEST_CASE("counters", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -120,3 +122,243 @@ TEST_CASE("counters", "[.cmd]") { REQUIRE_THROWS(proxy.Call("counters", {}, -1, GET)); } } + +TEST_CASE("gates", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getNumberOfGates(); + { + std::ostringstream oss; + proxy.Call("gates", {"1000"}, -1, PUT, oss); + REQUIRE(oss.str() == "gates 1000\n"); + } + { + std::ostringstream oss; + proxy.Call("gates", {}, -1, GET, oss); + REQUIRE(oss.str() == "gates 1000\n"); + } + { + std::ostringstream oss; + proxy.Call("gates", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "gates 1\n"); + } + REQUIRE_THROWS(proxy.Call("gates", {"0"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setNumberOfGates(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gates", {}, -1, GET)); + } +} + +TEST_CASE("exptime1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptime(0); + { + std::ostringstream oss; + proxy.Call("exptime1", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime1", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime1", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime1 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setExptime(0, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("exptime1", {}, -1, GET)); + } +} + +TEST_CASE("exptime2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptime(1); + { + std::ostringstream oss; + proxy.Call("exptime2", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime2", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime2", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime2 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setExptime(1, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("exptime2", {}, -1, GET)); + } +} + +TEST_CASE("exptime3", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptime(2); + { + std::ostringstream oss; + proxy.Call("exptime3", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime3", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime3", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime3 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setExptime(2, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("exptime3", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptimeForAllGates().tsquash( + "inconsistent gatedelay to test"); + if (prev_val[0] != prev_val[1] || prev_val[1] != prev_val[2]) { + throw sls::RuntimeError("inconsistent gatedelay for all gates"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay", {"0.05"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay 0.05\n"); + } + if (det_type != defs::MYTHEN3) { + std::ostringstream oss; + proxy.Call("gatedelay", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay 50ms\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay", {"1s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay 1s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay 0\n"); + } + det.setGateDelay(-1, prev_val[0]); + } else { + REQUIRE_THROWS(proxy.Call("gatedelay", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getGateDelay(0); + { + std::ostringstream oss; + proxy.Call("gatedelay1", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay1", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay1", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay1 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setGateDelay(0, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gatedelay1", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getGateDelay(1); + { + std::ostringstream oss; + proxy.Call("gatedelay2", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay2", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay2", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay2 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setGateDelay(1, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gatedelay2", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay3", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getGateDelay(2); + { + std::ostringstream oss; + proxy.Call("gatedelay3", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay3", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay3", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay3 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setGateDelay(2, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gatedelay3", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index bb5ec6828..a64edd837 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -2579,30 +2579,6 @@ TEST_CASE("resetfpga", "[.cmd]") { // } // } -// TEST_CASE("roi", "[.cmd][.gotthard]") { -// if (test::type == defs::GOTTHARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("roi 0 255", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "roi [0, 255] \n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("roi 256 511", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "roi [256, 511] \n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clearroi", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "clearroi [-1, -1] \n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("roi 0 256", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("roi", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("clearroi", PUT)); -// } -// } - // TEST_CASE("adc", "[.cmd][.ctb]") { // if (test::type != defs::CHIPTESTBOARD) { // REQUIRE_THROWS(multiSlsDetectorClient("adc 8", GET));