diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 026297a13..20506f542 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -1186,16 +1186,16 @@ class Detector { /** [CTB][Moench][Mythen3] */ void savePattern(const std::string &fname); - /** [CTB][Moench][Mythen3] */ + /** [CTB][Moench] */ Result getPatternIOControl(Positions pos = {}) const; - /** [CTB][Moench][Mythen3] */ + /** [CTB][Moench] */ void setPatternIOControl(uint64_t word, Positions pos = {}); - /** [CTB][Moench][Mythen3] */ + /** [CTB][Moench] */ Result getPatternClockControl(Positions pos = {}) const; - /** [CTB][Moench][Mythen3] */ + /** [CTB][Moench] */ void setPatternClockControl(uint64_t word, Positions pos = {}); /** [CTB][Moench][Mythen3] same as executing for ctb and moench */ diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index d09090812..5669a4655 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1961,7 +1961,7 @@ std::string CmdProxy::Pattern(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[fname]\n\t[Mythen3][Moench][Ctb][Moench] Loads binary pattern " + os << "[fname]\n\t[Mythen3][Moench][Ctb] Loads binary pattern " "file with only pattern " "words" << '\n'; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 1f53d552f..3e54303b7 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -2027,12 +2027,12 @@ class CmdProxy { INTEGER_COMMAND_HEX(patioctrl, getPatternIOControl, setPatternIOControl, StringTo, - "[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask " + "[64 bit mask]\n\t[Ctb][Moench] 64 bit mask " "defining input (0) and output (1) signals."); INTEGER_COMMAND_HEX(patclkctrl, getPatternClockControl, setPatternClockControl, StringTo, - "[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit mask " + "[64 bit mask]\n\t[Ctb][Moench] 64 bit mask " "defining output clock enable."); INTEGER_COMMAND_HEX( diff --git a/slsDetectorSoftware/tests/CMakeLists.txt b/slsDetectorSoftware/tests/CMakeLists.txt index 8fdd3e848..3d48b65a7 100755 --- a/slsDetectorSoftware/tests/CMakeLists.txt +++ b/slsDetectorSoftware/tests/CMakeLists.txt @@ -3,6 +3,7 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-slsDetector.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-rx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-pattern.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-eiger.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-jungfrau.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-mythen3.cpp diff --git a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp index 2a3a49b49..f489b8c6a 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp @@ -116,8 +116,8 @@ TEST_CASE("samples", "[.cmd][.new]") { } { std::ostringstream oss; - proxy.Call("samples", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "samples 1\n"); + proxy.Call("samples", {"25"}, -1, PUT, oss); + REQUIRE(oss.str() == "samples 25\n"); } { std::ostringstream oss; @@ -159,8 +159,8 @@ TEST_CASE("asamples", "[.cmd][.new]") { auto prev_val = det.getNumberOfAnalogSamples(); { std::ostringstream oss; - proxy.Call("asamples", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "asamples 1\n"); + proxy.Call("asamples", {"25"}, -1, PUT, oss); + REQUIRE(oss.str() == "asamples 25\n"); } { std::ostringstream oss; @@ -333,8 +333,8 @@ TEST_CASE("adcenable", "[.cmd][.new]") { auto prev_val = det.getADCEnableMask(); { std::ostringstream oss; - proxy.Call("adcenable", {"0x8d0a21d4"}, -1, PUT, oss); - REQUIRE(oss.str() == "adcenable 0x8d0a21d4\n"); + proxy.Call("adcenable", {"0x8d0aa0d8"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable 0x8d0aa0d8\n"); } { std::ostringstream oss; @@ -363,8 +363,8 @@ TEST_CASE("adcenable10g", "[.cmd][.new]") { auto prev_val = det.getTenGigaADCEnableMask(); { std::ostringstream oss; - proxy.Call("adcenable10g", {"0xff00f0f0"}, -1, PUT, oss); - REQUIRE(oss.str() == "adcenable10g 0xff00f0f0\n"); + proxy.Call("adcenable10g", {"0xff0000ff"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable10g 0xff0000ff\n"); } { std::ostringstream oss; diff --git a/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp b/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp new file mode 100644 index 000000000..09b36960a --- /dev/null +++ b/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp @@ -0,0 +1,543 @@ +#include "CmdProxy.h" +#include "Detector.h" +#include "catch.hpp" +#include "sls_detector_defs.h" +#include + +#include "Result.h" +#include "ToString.h" +#include "test-CmdProxy-global.h" +#include "tests/globals.h" +#include "versionAPI.h" + +using sls::CmdProxy; +using sls::Detector; +using test::GET; +using test::PUT; + +/* Pattern */ + +TEST_CASE("pattern", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + // no proper test for put + REQUIRE_THROWS(proxy.Call("pattern", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("pattern", {}, -1, GET)); + } +} + +TEST_CASE("savepattern", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + REQUIRE_THROWS( + proxy.Call("savepattern", {"/tmp/pattern.txt"}, -1, GET)); + REQUIRE_NOTHROW( + proxy.Call("savepattern", {"/tmp/pattern.txt"}, -1, PUT)); + } else { + REQUIRE_THROWS( + proxy.Call("savepattern", {"/tmp/pattern.txt"}, -1, PUT)); + } +} + +TEST_CASE("patioctrl", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) { + auto prev_val = det.getPatternIOControl(); + { + std::ostringstream oss; + proxy.Call("patioctrl", {"0xc15004808d0a21a4"}, -1, PUT, oss); + REQUIRE(oss.str() == "patioctrl 0xc15004808d0a21a4\n"); + } + { + std::ostringstream oss; + proxy.Call("patioctrl", {"0x0"}, -1, PUT, oss); + REQUIRE(oss.str() == "patioctrl 0x0\n"); + } + { + std::ostringstream oss; + proxy.Call("patioctrl", {}, -1, GET, oss); + REQUIRE(oss.str() == "patioctrl 0x0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternIOControl(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patioctrl", {}, -1, GET)); + } +} + +TEST_CASE("patclkctrl", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) { + auto prev_val = det.getPatternClockControl(); + { + std::ostringstream oss; + proxy.Call("patclkctrl", {"0xc15004808d0a21a4"}, -1, PUT, oss); + REQUIRE(oss.str() == "patclkctrl 0xc15004808d0a21a4\n"); + } + { + std::ostringstream oss; + proxy.Call("patclkctrl", {"0x0"}, -1, PUT, oss); + REQUIRE(oss.str() == "patclkctrl 0x0\n"); + } + { + std::ostringstream oss; + proxy.Call("patclkctrl", {}, -1, GET, oss); + REQUIRE(oss.str() == "patclkctrl 0x0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternClockControl(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patclkctrl", {}, -1, GET)); + } +} + +TEST_CASE("patword", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + int addr = 0x23; + std::string saddr = sls::ToStringHex(addr); + auto prev_val = det.getPatternWord(addr); + { + std::ostringstream oss; + proxy.Call("patword", {saddr, "0xc15004808d0a21a4"}, -1, PUT, oss); + REQUIRE(oss.str() == + "patword [" + saddr + ", 0xc15004808d0a21a4]\n"); + } + { + std::ostringstream oss; + proxy.Call("patword", {saddr, "0x0"}, -1, PUT, oss); + REQUIRE(oss.str() == "patword [" + saddr + ", 0x0]\n"); + } + { + std::ostringstream oss; + proxy.Call("patword", {saddr}, -1, GET, oss); + REQUIRE(oss.str() == "patword 0x0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternWord(addr, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patword", {"0x23"}, -1, GET)); + } +} + +TEST_CASE("patlimits", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternLoopAddresses(-1); + { + std::ostringstream oss; + proxy.Call("patlimits", {"0x20", "0x5c"}, -1, PUT, oss); + REQUIRE(oss.str() == "patlimits [0x20, 0x5c]\n"); + } + { + std::ostringstream oss; + proxy.Call("patlimits", {}, -1, GET, oss); + REQUIRE(oss.str() == "patlimits [0x20, 0x5c]\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternLoopAddresses(-1, prev_val[i][0], prev_val[i][1], + {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patlimits", {}, -1, GET)); + } +} + +TEST_CASE("patloop0", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternLoopAddresses(0); + { + std::ostringstream oss; + proxy.Call("patloop0", {"0x20", "0x5c"}, -1, PUT, oss); + REQUIRE(oss.str() == "patloop0 [0x20, 0x5c]\n"); + } + { + std::ostringstream oss; + proxy.Call("patloop0", {}, -1, GET, oss); + REQUIRE(oss.str() == "patloop0 [0x20, 0x5c]\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternLoopAddresses(0, prev_val[i][0], prev_val[i][1], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patloop0", {}, -1, GET)); + } +} + +TEST_CASE("patloop1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternLoopAddresses(1); + { + std::ostringstream oss; + proxy.Call("patloop1", {"0x20", "0x5c"}, -1, PUT, oss); + REQUIRE(oss.str() == "patloop1 [0x20, 0x5c]\n"); + } + { + std::ostringstream oss; + proxy.Call("patloop1", {}, -1, GET, oss); + REQUIRE(oss.str() == "patloop1 [0x20, 0x5c]\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternLoopAddresses(1, prev_val[i][0], prev_val[i][1], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patloop1", {}, -1, GET)); + } +} + +TEST_CASE("patloop2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternLoopAddresses(2); + { + std::ostringstream oss; + proxy.Call("patloop2", {"0x20", "0x5c"}, -1, PUT, oss); + REQUIRE(oss.str() == "patloop2 [0x20, 0x5c]\n"); + } + { + std::ostringstream oss; + proxy.Call("patloop2", {}, -1, GET, oss); + REQUIRE(oss.str() == "patloop2 [0x20, 0x5c]\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternLoopAddresses(2, prev_val[i][0], prev_val[i][1], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patloop2", {}, -1, GET)); + } +} + +TEST_CASE("patnloop0", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternLoopCycles(0); + { + std::ostringstream oss; + proxy.Call("patnloop0", {"5"}, -1, PUT, oss); + REQUIRE(oss.str() == "patnloop0 5\n"); + } + { + std::ostringstream oss; + proxy.Call("patnloop0", {}, -1, GET, oss); + REQUIRE(oss.str() == "patnloop0 5\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternLoopCycles(0, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patnloop0", {}, -1, GET)); + } +} + +TEST_CASE("patnloop1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternLoopCycles(1); + { + std::ostringstream oss; + proxy.Call("patnloop1", {"5"}, -1, PUT, oss); + REQUIRE(oss.str() == "patnloop1 5\n"); + } + { + std::ostringstream oss; + proxy.Call("patnloop1", {}, -1, GET, oss); + REQUIRE(oss.str() == "patnloop1 5\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternLoopCycles(1, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patnloop1", {}, -1, GET)); + } +} + +TEST_CASE("patnloop2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternLoopCycles(2); + { + std::ostringstream oss; + proxy.Call("patnloop2", {"5"}, -1, PUT, oss); + REQUIRE(oss.str() == "patnloop2 5\n"); + } + { + std::ostringstream oss; + proxy.Call("patnloop2", {}, -1, GET, oss); + REQUIRE(oss.str() == "patnloop2 5\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternLoopCycles(2, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patnloop2", {}, -1, GET)); + } +} + +TEST_CASE("patwait0", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternWaitAddr(0); + { + std::ostringstream oss; + proxy.Call("patwait0", {"0x5c"}, -1, PUT, oss); + REQUIRE(oss.str() == "patwait0 0x5c\n"); + } + { + std::ostringstream oss; + proxy.Call("patwait0", {}, -1, GET, oss); + REQUIRE(oss.str() == "patwait0 0x5c\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternWaitAddr(0, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patwait0", {}, -1, GET)); + } +} + +TEST_CASE("patwait1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternWaitAddr(1); + { + std::ostringstream oss; + proxy.Call("patwait1", {"0x5c"}, -1, PUT, oss); + REQUIRE(oss.str() == "patwait1 0x5c\n"); + } + { + std::ostringstream oss; + proxy.Call("patwait1", {}, -1, GET, oss); + REQUIRE(oss.str() == "patwait1 0x5c\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternWaitAddr(1, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patwait1", {}, -1, GET)); + } +} + +TEST_CASE("patwait2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternWaitAddr(2); + { + std::ostringstream oss; + proxy.Call("patwait2", {"0x5c"}, -1, PUT, oss); + REQUIRE(oss.str() == "patwait2 0x5c\n"); + } + { + std::ostringstream oss; + proxy.Call("patwait2", {}, -1, GET, oss); + REQUIRE(oss.str() == "patwait2 0x5c\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternWaitAddr(2, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patwait2", {}, -1, GET)); + } +} + +TEST_CASE("patwaittime0", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternWaitTime(0); + { + std::ostringstream oss; + proxy.Call("patwaittime0", {"8589936640"}, -1, PUT, oss); + REQUIRE(oss.str() == "patwaittime0 8589936640\n"); + } + { + std::ostringstream oss; + proxy.Call("patwaittime0", {}, -1, GET, oss); + REQUIRE(oss.str() == "patwaittime0 8589936640\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternWaitTime(0, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patwaittime0", {}, -1, GET)); + } +} + +TEST_CASE("patwaittime1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternWaitTime(1); + { + std::ostringstream oss; + proxy.Call("patwaittime1", {"8589936640"}, -1, PUT, oss); + REQUIRE(oss.str() == "patwaittime1 8589936640\n"); + } + { + std::ostringstream oss; + proxy.Call("patwaittime1", {}, -1, GET, oss); + REQUIRE(oss.str() == "patwaittime1 8589936640\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternWaitTime(1, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patwaittime1", {}, -1, GET)); + } +} + +TEST_CASE("patwaittime2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternWaitTime(2); + { + std::ostringstream oss; + proxy.Call("patwaittime2", {"8589936640"}, -1, PUT, oss); + REQUIRE(oss.str() == "patwaittime2 8589936640\n"); + } + { + std::ostringstream oss; + proxy.Call("patwaittime2", {}, -1, GET, oss); + REQUIRE(oss.str() == "patwaittime2 8589936640\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternWaitTime(2, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patwaittime2", {}, -1, GET)); + } +} + +TEST_CASE("patmask", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternMask(); + { + std::ostringstream oss; + proxy.Call("patmask", {"0x842f020204200dc0"}, -1, PUT, oss); + REQUIRE(oss.str() == "patmask 0x842f020204200dc0\n"); + } + { + std::ostringstream oss; + proxy.Call("patmask", {}, -1, GET, oss); + REQUIRE(oss.str() == "patmask 0x842f020204200dc0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternMask(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patmask", {}, -1, GET)); + } +} + +TEST_CASE("patsetbit", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH || + det_type == defs::MYTHEN3) { + auto prev_val = det.getPatternBitMask(); + { + std::ostringstream oss; + proxy.Call("patsetbit", {"0x842f020204200dc0"}, -1, PUT, oss); + REQUIRE(oss.str() == "patsetbit 0x842f020204200dc0\n"); + } + { + std::ostringstream oss; + proxy.Call("patsetbit", {}, -1, GET, oss); + REQUIRE(oss.str() == "patsetbit 0x842f020204200dc0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPatternBitMask(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("patsetbit", {}, -1, GET)); + } +} + +TEST_CASE("patternstart", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + REQUIRE_THROWS(proxy.Call("patternstart", {}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("patternstart", {}, -1, PUT)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 152fe379a..603a2c808 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1951,325 +1951,6 @@ TEST_CASE("resetfpga", "[.cmd]") { // REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT)); // } -// TEST_CASE("patsetbit", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// uint64_t val = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patsetbit", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("patsetbit -// ")); val = stoul(s, 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patsetbit -// 0x842f020204200dc0", PUT, nullptr, oss)); REQUIRE(oss.str() == -// "patsetbit 0x842f020204200dc0\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patsetbit " + -// sls::ToStringHex(val), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patsetbit", GET)); -// } -// } - -// TEST_CASE("patmask", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// uint64_t val = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patmask", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("patmask ")); -// val = stoul(s, 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patmask -// 0x842f020204200dc0", PUT, nullptr, oss)); REQUIRE(oss.str() == -// "patmask 0x842f020204200dc0\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patmask " + -// sls::ToStringHex(val), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patmask", GET)); -// } -// } - -// TEST_CASE("patwaittime", "[.cmd][.ctb]") { -// for (int loop = 0; loop < 3; ++loop) { -// if (test::type == defs::CHIPTESTBOARD) { -// uint64_t val = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patwaittime" + -// std::to_string(loop), GET, nullptr, oss)); std::string s = -// (oss.str()).erase (0, strlen("patwaittime") + 2); val = -// std::stoul(s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patwaittime" + -// std::to_string(loop) + " 8589936640", PUT, nullptr, oss)); -// REQUIRE(oss.str() == "patwaittime" + std::to_string(loop) + " -// 8589936640\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patwaittime" + -// std::to_string(loop) + ' ' + std::to_string(val), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patwaittime" + -// std::to_string(loop), GET)); -// } -// } -// } - -// TEST_CASE("patwait", "[.cmd][.ctb]") { -// for (int loop = 0; loop < 3; ++loop) { -// if (test::type == defs::CHIPTESTBOARD) { -// int val = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patwait" + -// std::to_string(loop), GET, nullptr, oss)); std::string s = -// (oss.str()).erase (0, strlen("patwait") + 2); val = stoul(s, -// 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patwait" + -// std::to_string(loop) + " 0x5c", PUT, nullptr, oss)); -// REQUIRE(oss.str() == "patwait" + std::to_string(loop) + " -// 0x5c\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patwait" + -// std::to_string(loop) + ' ' + sls::ToStringHex(val), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patwait" + -// std::to_string(loop), GET)); -// } -// } -// } - -// TEST_CASE("patnloop", "[.cmd][.ctb]") { -// for (int loop = 0; loop < 3; ++loop) { -// if (test::type == defs::CHIPTESTBOARD) { -// int val = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patnloop" + -// std::to_string(loop), GET, nullptr, oss)); std::string s = -// (oss.str()).erase (0, strlen("patnloop") + 2); val = -// std::stoi(s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patnloop" + -// std::to_string(loop) + " 5", PUT, nullptr, oss)); -// REQUIRE(oss.str() == "patnloop" + std::to_string(loop) + " -// 5\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patnloop" + -// std::to_string(loop) + ' ' + std::to_string(val), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patnloop" + -// std::to_string(loop), GET)); -// } -// } -// } - -// TEST_CASE("patloop", "[.cmd][.ctb]") { -// for (int loop = 0; loop < 3; ++loop) { -// if (test::type == defs::CHIPTESTBOARD) { -// uint32_t limit1 = 0, limit2 = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patloop" + -// std::to_string(loop), GET, nullptr, oss)); std::string s = -// oss.str(); auto t = sls::split(s, ' '); s = t[1].erase (0, -// 1); limit1 = stoul(s, 0, 16); limit2 = stoul(t[2], 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patloop" + -// std::to_string(loop) + " 0x20 0x5c", PUT, nullptr, oss)); -// REQUIRE(oss.str() == "patloop" + std::to_string(loop) + " -// [0x20, 0x5c]\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patloop" + -// std::to_string(loop) + ' ' + sls::ToStringHex(limit1) + ' ' + -// sls::ToStringHex(limit2), PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("patloop" + -// std::to_string(loop) + " 0x3", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patloop" + -// std::to_string(loop), GET)); -// } -// } -// } - -// TEST_CASE("patlimits", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// uint32_t patlimit1 = 0, patlimit2 = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patlimits", GET, nullptr, -// oss)); std::string s = oss.str(); auto t = sls::split(s, ' '); s -// = t[1].erase (0, 1); patlimit1 = stoul(s, 0, 16); patlimit2 = -// stoul(t[2], 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patlimits 0x20 0x5c", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "patlimits [0x20, -// 0x5c]\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patlimits " + -// sls::ToStringHex(patlimit1) + ' ' + sls::ToStringHex(patlimit2), -// PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patlimits", GET)); -// } -// } - -// TEST_CASE("patword", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// uint64_t prev_value = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patword 0x23", GET, -// nullptr, oss)); std::string s = (oss.str()).erase (0, -// strlen("patword ")); prev_value = stoul(s, 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patword 0x23 -// 0xc15004808d0a21a4", PUT, nullptr, oss)); REQUIRE(oss.str() == -// "patword [0x23, 0xc15004808d0a21a4]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patword 0x23 0x0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "patword [0x23, 0x0]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patword 0x23", GET, -// nullptr, oss)); REQUIRE(oss.str() == "patword 0x0\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patword 0x23 " + -// std::to_string(prev_value), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patword 0x23", GET)); -// } -// } - -// TEST_CASE("patclkctrl", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// uint64_t prev_value = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patclkctrl", GET, -// nullptr, oss)); std::string s = (oss.str()).erase (0, -// strlen("patclkctrl ")); prev_value = stoul(s, 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patclkctrl -// 0xc15004808d0a21a4", PUT, nullptr, oss)); REQUIRE(oss.str() == -// "patclkctrl 0xc15004808d0a21a4\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patclkctrl 0x0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "patclkctrl 0x0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patclkctrl", GET, -// nullptr, oss)); REQUIRE(oss.str() == "patclkctrl 0x0\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patclkctrl " + -// std::to_string(prev_value), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patclkctrl", GET)); -// } -// } - -// TEST_CASE("patioctrl", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// uint64_t prev_value = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patioctrl", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("patioctrl -// ")); prev_value = stoul(s, 0, 16); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patioctrl -// 0xc15004808d0a21a4", PUT, nullptr, oss)); REQUIRE(oss.str() == -// "patioctrl 0xc15004808d0a21a4\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patioctrl 0x0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "patioctrl 0x0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("patioctrl", GET, nullptr, -// oss)); REQUIRE(oss.str() == "patioctrl 0x0\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("patioctrl " + -// std::to_string(prev_value), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("patioctrl", GET)); -// } -// } - -// TEST_CASE("savepattern", "[.cmd][.ctb]") { -// REQUIRE_THROWS(multiSlsDetectorClient("savepattern", GET)); -// if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("savepattern -// /tmp/pat.txt", PUT, nullptr, oss)); REQUIRE(oss.str() == -// "savepattern /tmp/pat.txt\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("savepattern /tmp/pat.txt", -// PUT)); -// } -// } - -// TEST_CASE("pattern", "[.cmd][.ctb]") { -// REQUIRE_THROWS(multiSlsDetectorClient("pattern", GET)); -// if (test::type == defs::CHIPTESTBOARD) { -// ;// todo test with real file? -// } -// } - -// TEST_CASE("led", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("led 1", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "led 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("led 0", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "led 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("led", GET, nullptr, -// oss)); REQUIRE(oss.str() == "led 0\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("led", GET)); -// } -// } - // TEST_CASE("adcinvert", "[.cmd][.ctb]") { // if (test::type == defs::CHIPTESTBOARD || test::type == // defs::JUNGFRAU) {