diff --git a/settingsdir/eiger/standard/4500eV/noise.sn000 b/settingsdir/eiger/standard/4500eV/noise.sn000 new file mode 100755 index 000000000..4f333106f Binary files /dev/null and b/settingsdir/eiger/standard/4500eV/noise.sn000 differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index fae9b0e4d..fab4d6a62 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -96,6 +96,8 @@ uint64_t eiger_virtual_startingframenumber = 1; int eiger_virtual_detPos[2] = {0, 0}; int eiger_virtual_test_mode = 0; int eiger_virtual_quad_mode = 0; +int eiger_virtual_read_nlines = 256; +int eiger_virtual_interrupt_subframe = 0; #endif int isInitCheckDone() { return initCheckDone; } @@ -1516,13 +1518,15 @@ int setInterruptSubframe(int value) { if (!Feb_Control_SetInterruptSubframe(value)) { return FAIL; } +#else + eiger_virtual_interrupt_subframe = value; #endif return OK; } int getInterruptSubframe() { #ifdef VIRTUAL - return 0; + return eiger_virtual_interrupt_subframe; #else return Feb_Control_GetInterruptSubframe(); #endif @@ -1536,13 +1540,15 @@ int setReadNLines(int value) { return FAIL; } Beb_SetReadNLines(value); +#else + eiger_virtual_read_nlines = value; #endif return OK; } int getReadNLines() { #ifdef VIRTUAL - return 0; + return eiger_virtual_read_nlines; #else return Feb_Control_GetReadNLines(); #endif @@ -1835,6 +1841,7 @@ void setExternalGating(int enable[]) { } int setAllTrimbits(int val) { + LOG(logINFO, ("Setting all trimbits to %d\n", val)); #ifndef VIRTUAL if (!Feb_Control_SaveAllTrimbitsTo(val, top)) { LOG(logERROR, ("Could not set all trimbits\n")); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 9702eab60..3d8bf5200 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -4775,7 +4775,7 @@ int set_read_n_lines(int file_des) { } else { if (setReadNLines(arg) == FAIL) { ret = FAIL; - sprintf(mess, "Could not set read n lines.\n"); + sprintf(mess, "Could not set read n lines to %d.\n", arg); LOG(logERROR, (mess)); } else { int retval = getReadNLines(); diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index a2128bcdf..2f51a47c1 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -117,6 +117,16 @@ class Detector { /**[Eiger][Mythen3] */ void setAllTrimbits(int value, Positions pos = {}); + /**[Eiger][Jungfrau] */ + bool getGapPixelsinCallback() const; + + /** + * [Eiger][Jungfrau] + * Only in client data call back + * Fills in gap pixels in data + */ + void setGapPixelsinCallback(const bool enable); + /************************************************** * * * Callbacks * @@ -146,16 +156,6 @@ class Detector { void *), void *pArg); - /**[Eiger][Jungfrau] */ - bool getGapPixelsinCallback() const; - - /** - * [Eiger][Jungfrau] - * Only in client data call back - * Fills in gap pixels in data - */ - void setGapPixelsinCallback(const bool enable); - /************************************************** * * * Acquisition Parameters * diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index ee7c248f2..f65ccf1b8 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -331,6 +331,37 @@ std::string CmdProxy::DetectorSize(int action) { return os.str(); } +std::string CmdProxy::GapPixels(int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == defs::HELP_ACTION) { + os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data " + "call back." + << '\n'; + } else if (action == defs::GET_ACTION) { + if (det_id != -1) { + throw sls::RuntimeError("Cannot get gap pixels at module level"); + } + if (!args.empty()) { + WrongNumberOfParameters(0); + } + auto t = det->getGapPixelsinCallback(); + os << t << '\n'; + } else if (action == defs::PUT_ACTION) { + if (det_id != -1) { + throw sls::RuntimeError("Cannot add gap pixels at module level"); + } + if (args.size() != 1) { + WrongNumberOfParameters(1); + } + det->setGapPixelsinCallback(StringTo(args[0])); + os << args.front() << '\n'; + } else { + throw sls::RuntimeError("Unknown action"); + } + return os.str(); +} + /* acquisition parameters */ std::string CmdProxy::Exptime(int action) { @@ -1224,37 +1255,6 @@ std::string CmdProxy::ThresholdNoTb(int action) { return os.str(); } -std::string CmdProxy::GapPixels(int action) { - std::ostringstream os; - os << cmd << ' '; - if (action == defs::HELP_ACTION) { - os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data " - "call back." - << '\n'; - } else if (action == defs::GET_ACTION) { - if (det_id != -1) { - throw sls::RuntimeError("Cannot get gap pixels at module level"); - } - if (!args.empty()) { - WrongNumberOfParameters(0); - } - auto t = det->getGapPixelsinCallback(); - os << t << '\n'; - } else if (action == defs::PUT_ACTION) { - if (det_id != -1) { - throw sls::RuntimeError("Cannot add gap pixels at module level"); - } - if (args.size() != 1) { - WrongNumberOfParameters(1); - } - det->setGapPixelsinCallback(StringTo(args[0])); - os << args.front() << '\n'; - } else { - throw sls::RuntimeError("Unknown action"); - } - return os.str(); -} - std::string CmdProxy::TrimEnergies(int action) { std::ostringstream os; os << cmd << ' '; @@ -1271,13 +1271,11 @@ std::string CmdProxy::TrimEnergies(int action) { auto t = det->getTrimEnergies({det_id}); os << OutString(t) << '\n'; } else if (action == defs::PUT_ACTION) { - if (args.empty()) { - WrongNumberOfParameters(1); - } - std::vector t(args.size()); - for (size_t i = 0; i < t.size(); ++i) { - t[i] = StringTo(args[i]); + if (!args.empty()) { + for (size_t i = 0; i < t.size(); ++i) { + t[i] = StringTo(args[i]); + } } det->setTrimEnergies(t, {det_id}); os << sls::ToString(args) << '\n'; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 99d1fd717..1f53d552f 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -565,6 +565,7 @@ class CmdProxy { {"settings", &CmdProxy::settings}, {"trimbits", &CmdProxy::trimbits}, {"trimval", &CmdProxy::trimval}, + {"gappixels", &CmdProxy::GapPixels}, /* acquisition parameters */ {"acquire", &CmdProxy::acquire}, @@ -754,7 +755,6 @@ class CmdProxy { {"threshold", &CmdProxy::Threshold}, {"thresholdnotb", &CmdProxy::ThresholdNoTb}, {"settingspath", &CmdProxy::settingspath}, - {"gappixels", &CmdProxy::GapPixels}, {"parallel", &CmdProxy::parallel}, {"overflow", &CmdProxy::overflow}, {"storeinram", &CmdProxy::storeinram}, @@ -923,6 +923,7 @@ class CmdProxy { std::string PackageVersion(int action); std::string ClientVersion(int action); std::string DetectorSize(int action); + std::string GapPixels(int action); /* acquisition parameters */ std::string acquire(int action); std::string Exptime(int action); @@ -954,7 +955,6 @@ class CmdProxy { std::string DynamicRange(int action); std::string Threshold(int action); std::string ThresholdNoTb(int action); - std::string GapPixels(int action); std::string TrimEnergies(int action); std::string RateCorrection(int action); std::string Activate(int action); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 1a8988fa0..5c3ef60fb 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -161,6 +161,14 @@ void Detector::setAllTrimbits(int value, Positions pos) { pimpl->Parallel(&Module::setAllTrimbits, pos, value); } +bool Detector::getGapPixelsinCallback() const { + return pimpl->getGapPixelsinCallback(); +} + +void Detector::setGapPixelsinCallback(bool enable) { + pimpl->setGapPixelsinCallback(enable); +} + // Callback void Detector::registerAcquisitionFinishedCallback(void (*func)(double, int, @@ -175,14 +183,6 @@ void Detector::registerDataCallback(void (*func)(detectorData *, uint64_t, pimpl->registerDataCallback(func, pArg); } -bool Detector::getGapPixelsinCallback() const { - return pimpl->getGapPixelsinCallback(); -} - -void Detector::setGapPixelsinCallback(bool enable) { - pimpl->setGapPixelsinCallback(enable); -} - // Acquisition Parameters Result Detector::getNumberOfFrames(Positions pos) const { diff --git a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp index 49449d2ce..1a9b7b859 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp @@ -315,7 +315,7 @@ TEST_CASE("txndelay_right", "[.cmd][.new]") { /* Eiger Specific */ -TEST_CASE("dr", "[.cmd]") { +TEST_CASE("dr", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -347,124 +347,7 @@ TEST_CASE("dr", "[.cmd]") { } } -TEST_CASE("interruptsubframe", "[.cmd][!mayfail]") { - // TODO! Fix this for virtual server - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - auto previous = det.getInterruptSubframe(); - - std::ostringstream oss1, oss2, oss3; - proxy.Call("interruptsubframe", {"1"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "interruptsubframe 1\n"); - proxy.Call("interruptsubframe", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "interruptsubframe 1\n"); - proxy.Call("interruptsubframe", {"0"}, -1, PUT, oss3); - REQUIRE(oss3.str() == "interruptsubframe 0\n"); - for (int i = 0; i != det.size(); ++i) { - det.setInterruptSubframe(previous[i], {i}); - } - - } else { - REQUIRE_THROWS(proxy.Call("interruptsubframe", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("interruptsubframe", {"1"}, -1, PUT)); - } -} - -TEST_CASE("overflow", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - auto previous = det.getOverFlowMode(); - - std::ostringstream oss1, oss2, oss3; - proxy.Call("overflow", {"1"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "overflow 1\n"); - proxy.Call("overflow", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "overflow 1\n"); - proxy.Call("overflow", {"0"}, -1, PUT, oss3); - REQUIRE(oss3.str() == "overflow 0\n"); - for (int i = 0; i != det.size(); ++i) { - det.setOverFlowMode(previous[i], {i}); - } - - } else { - REQUIRE_THROWS(proxy.Call("overflow", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("overflow", {"1"}, -1, PUT)); - } -} - -TEST_CASE("trimen", "[.cmd][.this]") { - // TODO! Also Mythen? - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - - auto previous = det.getTrimEnergies(); - std::ostringstream oss1, oss2; - proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "trimen [4500, 5400, 6400]\n"); - proxy.Call("trimen", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "trimen [4500, 5400, 6400]\n"); - - for (int i = 0; i != det.size(); ++i) { - det.setTrimEnergies(previous[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("trimen", {}, -1, GET)); - } -} - -// TEST_CASE("threshold"{ - -// }) - -// TEST_CASE("activate", "[.cmd][.eiger]") { -// if (test::type == slsDetectorDefs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "activate 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 1 nopadding", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 1 -// nopadding\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 0 padding", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 0 -// padding\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 0 nopadding", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 0 -// nopadding\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate 1 padding", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "activate 1 -// padding\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:activate", GET, -// nullptr, oss)); REQUIRE(oss.str() == "activate 1 padding\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("activate", GET)); -// } -// } - -TEST_CASE("subexptime", "[.cmd]") { +TEST_CASE("subexptime", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); @@ -485,7 +368,7 @@ TEST_CASE("subexptime", "[.cmd]") { } } -TEST_CASE("subdeadtime", "[.cmd]") { +TEST_CASE("subdeadtime", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); @@ -506,37 +389,468 @@ TEST_CASE("subdeadtime", "[.cmd]") { } } -TEST_CASE("tengiga", "[.cmd]") { +TEST_CASE("threshold", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD) { - auto tengiga = det.getTenGiga(); - det.setTenGiga(false); - - std::ostringstream oss1, oss2; - proxy.Call("tengiga", {"1"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "tengiga 1\n"); - proxy.Call("tengiga", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "tengiga 1\n"); - - for (int i = 0; i != det.size(); ++i) { - det.setTenGiga(tengiga[i], {i}); + if (det_type == defs::EIGER) { + auto prev_threshold = det.getThresholdEnergy(); + auto prev_energies = + det.getTrimEnergies().tsquash("inconsistent trim energies to test"); + if (prev_energies.size() != 0) { + std::ostringstream oss1, oss2; + proxy.Call("threshold", {"4500", "standard"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "threshold [4500, standard]\n"); + proxy.Call("threshold", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "threshold 4500\n"); + det.setTrimEnergies(prev_energies); + for (int i = 0; i != det.size(); ++i) { + if (prev_threshold[i] >= 0) { + det.setThresholdEnergy(prev_threshold[i], defs::STANDARD, + true, {i}); + } + } } + REQUIRE_NOTHROW(proxy.Call("threshold", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("threshold", {}, -1, GET)); } } -TEST_CASE("quad", "[.cmd]") { - // TODO! set and get once available in virtual detector +TEST_CASE("thresholdnotb", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_threshold = det.getThresholdEnergy(); + auto prev_energies = + det.getTrimEnergies().tsquash("inconsistent trim energies to test"); + if (prev_energies.size() != 0) { + std::ostringstream oss1, oss2; + proxy.Call("thresholdnotb", {"4500 standard"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "thresholdnotb [4500 standard]\n"); + proxy.Call("threshold", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "threshold 4500\n"); + det.setTrimEnergies(prev_energies); + for (int i = 0; i != det.size(); ++i) { + if (prev_threshold[i] >= 0) { + det.setThresholdEnergy(prev_threshold[i], defs::STANDARD, + false, {i}); + } + } + } + REQUIRE_NOTHROW(proxy.Call("threshold", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("thresholdnotb", {}, -1, GET)); + } +} + +TEST_CASE("settingspath", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto prev_val = det.getSettingsPath(); + { + std::ostringstream oss1, oss2; + proxy.Call("settingspath", {"/tmp"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "settingspath /tmp\n"); + proxy.Call("settingspath", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "settingspath /tmp\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setSettingsPath(prev_val[i], {i}); + } +} + +TEST_CASE("parallel", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::EIGER) { + auto prev_val = det.getParallelMode(); + { + std::ostringstream oss; + proxy.Call("parallel", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "parallel 1\n"); + } + { + std::ostringstream oss; + proxy.Call("parallel", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "parallel 0\n"); + } + { + std::ostringstream oss; + proxy.Call("parallel", {}, -1, GET, oss); + REQUIRE(oss.str() == "parallel 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setParallelMode(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("parallel", {}, -1, GET)); + } +} + +TEST_CASE("overflow", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::EIGER) { + auto previous = det.getOverFlowMode(); + std::ostringstream oss1, oss2, oss3; + proxy.Call("overflow", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "overflow 1\n"); + proxy.Call("overflow", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "overflow 1\n"); + proxy.Call("overflow", {"0"}, -1, PUT, oss3); + REQUIRE(oss3.str() == "overflow 0\n"); + for (int i = 0; i != det.size(); ++i) { + det.setOverFlowMode(previous[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("overflow", {}, -1, GET)); + } +} + +TEST_CASE("storeinram", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto previous = det.getStoreInRamMode(); + std::ostringstream oss1, oss2, oss3; + proxy.Call("storeinram", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "storeinram 1\n"); + proxy.Call("storeinram", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "storeinram 1\n"); + proxy.Call("storeinram", {"0"}, -1, PUT, oss3); + REQUIRE(oss3.str() == "storeinram 0\n"); + for (int i = 0; i != det.size(); ++i) { + det.setStoreInRamMode(previous[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("storeinram", {}, -1, GET)); + } +} + +TEST_CASE("flippeddatax", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto previous = det.getBottom(); + std::ostringstream oss1, oss2, oss3; + proxy.Call("flippeddatax", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "flippeddatax 1\n"); + proxy.Call("flippeddatax", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "flippeddatax 1\n"); + proxy.Call("flippeddatax", {"0"}, -1, PUT, oss3); + REQUIRE(oss3.str() == "flippeddatax 0\n"); + for (int i = 0; i != det.size(); ++i) { + det.setBottom(previous[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("flippeddatax", {}, -1, GET)); + } +} + +TEST_CASE("trimen", "[.cmd][.this][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto previous = det.getTrimEnergies(); + std::ostringstream oss1, oss2; + proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "trimen [4500, 5400, 6400]\n"); + proxy.Call("trimen", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "trimen [4500, 5400, 6400]\n"); + + for (int i = 0; i != det.size(); ++i) { + det.setTrimEnergies(previous[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("trimen", {"4500", "5400", "6400"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("trimen", {}, -1, GET)); + } +} + +TEST_CASE("ratecorr", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_dr = det.getDynamicRange().tsquash("inconsistent dr to test"); + auto prev_tau = det.getRateCorrection(); + det.setDynamicRange(16); + { + std::ostringstream oss; + proxy.Call("ratecorr", {"120"}, -1, PUT, oss); + REQUIRE(oss.str() == "ratecorr 120ns\n"); + } + { + std::ostringstream oss; + proxy.Call("ratecorr", {}, -1, GET, oss); + REQUIRE(oss.str() == "ratecorr 120ns\n"); + } + // may fail if default settings not loaded + // REQUIRE_NOTHROW(proxy.Call("ratecorr", {"-1"}, -1, PUT)); + { + std::ostringstream oss; + proxy.Call("ratecorr", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "ratecorr 0ns\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRateCorrection(prev_tau[i], {i}); + } + det.setDynamicRange(prev_dr); + } else { + REQUIRE_THROWS(proxy.Call("ratecorr", {}, -1, GET)); + } +} + +TEST_CASE("readnlines", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_val = det.getPartialReadout(); + { + std::ostringstream oss; + proxy.Call("readnlines", {"256"}, -1, PUT, oss); + REQUIRE(oss.str() == "readnlines 256\n"); + } + { + std::ostringstream oss; + proxy.Call("readnlines", {}, -1, GET, oss); + REQUIRE(oss.str() == "readnlines 256\n"); + } + { + std::ostringstream oss; + proxy.Call("readnlines", {"16"}, -1, PUT, oss); + REQUIRE(oss.str() == "readnlines 16\n"); + } + REQUIRE_THROWS(proxy.Call("readnlines", {"0"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setPartialReadout(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("readnlines", {}, -1, GET)); + } +} + +TEST_CASE("interruptsubframe", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_val = det.getInterruptSubframe(); + + std::ostringstream oss1, oss2, oss3; + proxy.Call("interruptsubframe", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "interruptsubframe 1\n"); + proxy.Call("interruptsubframe", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "interruptsubframe 1\n"); + proxy.Call("interruptsubframe", {"0"}, -1, PUT, oss3); + REQUIRE(oss3.str() == "interruptsubframe 0\n"); + for (int i = 0; i != det.size(); ++i) { + det.setInterruptSubframe(prev_val[i], {i}); + } + + } else { + REQUIRE_THROWS(proxy.Call("interruptsubframe", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("interruptsubframe", {"1"}, -1, PUT)); + } +} + +TEST_CASE("measuredperiod", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_frames = det.getNumberOfFrames().tsquash( + "inconsistent number of frames to test"); + auto prev_timing = + det.getTimingMode().tsquash("inconsistent timing mode to test"); + auto prev_period = det.getPeriod(); + det.setNumberOfFrames(2); + det.setPeriod(std::chrono::seconds(1)); + det.setTimingMode(defs::AUTO_TIMING); + det.startDetector(); + std::this_thread::sleep_for(std::chrono::seconds(3)); + std::ostringstream oss; + proxy.Call("measuredperiod", {}, -1, GET, oss); + std::string st = oss.str(); + std::string s = st.erase(0, strlen("measuredperiod ")); + double val = std::stod(s); + // REQUIRE(val >= 1.0); + REQUIRE(val < 2.0); + for (int i = 0; i != det.size(); ++i) { + det.setPeriod(prev_period[i], {i}); + } + det.setNumberOfFrames(prev_frames); + det.setTimingMode(prev_timing); + } else { + REQUIRE_THROWS(proxy.Call("measuredperiod", {}, -1, GET)); + } +} + +TEST_CASE("measuredsubperiod", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_frames = det.getNumberOfFrames().tsquash( + "inconsistent number of frames to test"); + auto prev_timing = + det.getTimingMode().tsquash("inconsistent timing mode to test"); + auto prev_period = det.getPeriod(); + auto prev_dr = det.getDynamicRange().tsquash("inconsistent dr to test"); + det.setNumberOfFrames(1); + det.setPeriod(std::chrono::seconds(1)); + det.setTimingMode(defs::AUTO_TIMING); + det.setDynamicRange(32); + det.startDetector(); + std::this_thread::sleep_for(std::chrono::seconds(3)); + std::ostringstream oss; + proxy.Call("measuredsubperiod", {}, -1, GET, oss); + std::string st = oss.str(); + std::string s = st.erase(0, strlen("measuredsubperiod ")); + double val = std::stod(s); + REQUIRE(val >= 0); + REQUIRE(val < 1000); + for (int i = 0; i != det.size(); ++i) { + det.setPeriod(prev_period[i], {i}); + } + det.setNumberOfFrames(prev_frames); + det.setTimingMode(prev_timing); + det.setDynamicRange(prev_dr); + } else { + REQUIRE_THROWS(proxy.Call("measuredsubperiod", {}, -1, GET)); + } +} + +TEST_CASE("activate", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_val = det.getActive(); + { + std::ostringstream oss; + proxy.Call("activate", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "activate 1\n"); + } + { + std::ostringstream oss; + proxy.Call("activate", {"1", "nopadding"}, -1, PUT, oss); + REQUIRE(oss.str() == "activate 1 nopadding\n"); + } + { + std::ostringstream oss; + proxy.Call("activate", {"0", "padding"}, -1, PUT, oss); + REQUIRE(oss.str() == "activate 0 padding\n"); + } + { + std::ostringstream oss; + proxy.Call("activate", {"0", "nopadding"}, -1, PUT, oss); + REQUIRE(oss.str() == "activate 0 nopadding\n"); + } + { + std::ostringstream oss; + proxy.Call("activate", {"1", "padding"}, -1, PUT, oss); + REQUIRE(oss.str() == "activate 1 padding\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setActive(prev_val[i], {i}); + } + + } else { + REQUIRE_THROWS(proxy.Call("activate", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("activate", {"1"}, -1, PUT)); + } +} + +TEST_CASE("partialreset", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_val = det.getPartialReset(); + std::ostringstream oss1, oss2, oss3; + proxy.Call("partialreset", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "partialreset 1\n"); + proxy.Call("partialreset", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "partialreset 1\n"); + proxy.Call("partialreset", {"0"}, -1, PUT, oss3); + REQUIRE(oss3.str() == "partialreset 0\n"); + for (int i = 0; i != det.size(); ++i) { + det.setPartialReset(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("partialreset", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("partialreset", {"1"}, -1, PUT)); + } +} + +TEST_CASE("pulse", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + REQUIRE_THROWS(proxy.Call("pulse", {}, -1, GET)); + std::ostringstream oss; + proxy.Call("pulse", {"1", "1", "5"}, -1, PUT, oss); + REQUIRE(oss.str() == "pulse [1, 1, 5]\n"); + } else { + REQUIRE_THROWS(proxy.Call("pulse", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("pulse", {"1", "1", "5"}, -1, PUT)); + } +} + +TEST_CASE("pulsenmove", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + REQUIRE_THROWS(proxy.Call("pulsenmove", {}, -1, GET)); + std::ostringstream oss; + proxy.Call("pulsenmove", {"1", "1", "5"}, -1, PUT, oss); + REQUIRE(oss.str() == "pulsenmove [1, 1, 5]\n"); + } else { + REQUIRE_THROWS(proxy.Call("pulsenmove", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("pulsenmove", {"1", "1", "5"}, -1, PUT)); + } +} + +TEST_CASE("pulsechip", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + REQUIRE_THROWS(proxy.Call("pulsechip", {}, -1, GET)); + std::ostringstream oss; + proxy.Call("pulsechip", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "pulsechip 1\n"); + } else { + REQUIRE_THROWS(proxy.Call("pulsechip", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("pulsechip", {"1"}, -1, PUT)); + } +} + +TEST_CASE("quad", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_val = det.getQuad().tsquash("inconsistent quad to test"); // Quad only works with a single half module EIGER std::ostringstream oss; proxy.Call("quad", {}, -1, GET, oss); REQUIRE(oss.str() == "quad 0\n"); + det.setQuad(prev_val); } else { REQUIRE_THROWS(proxy.Call("quad", {}, -1, GET)); } diff --git a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index bd45b1086..fa5d65221 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -125,114 +125,217 @@ TEST_CASE("selinterface", "[.cmd][.new]") { } } -TEST_CASE("nframes", "[.cmd]") { +/* Jungfrau Specific */ + +TEST_CASE("temp_threshold", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { - auto nframes = det.getNumberOfFramesFromStart().squash(); - std::ostringstream oss; - proxy.Call("nframes", {}, -1, GET, oss); - REQUIRE(oss.str() == "nframes " + std::to_string(nframes) + "\n"); - + if (det_type == defs::JUNGFRAU) { + auto prev_val = det.getThresholdTemperature(); + { + std::ostringstream oss; + proxy.Call("temp_threshold", {"65"}, -1, PUT, oss); + REQUIRE(oss.str() == "temp_threshold 65\n"); + } + { + std::ostringstream oss; + proxy.Call("temp_threshold", {"70"}, -1, PUT, oss); + REQUIRE(oss.str() == "temp_threshold 70\n"); + } + { + std::ostringstream oss; + proxy.Call("temp_threshold", {}, -1, GET, oss); + REQUIRE(oss.str() == "temp_threshold 70\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setThresholdTemperature(prev_val[i], {i}); + } } else { - REQUIRE_THROWS(proxy.Call("nframes", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_threshold", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_threshold", {"70"}, -1, PUT)); } } -TEST_CASE("now", "[.cmd]") { - // TODO! can we test this? +TEST_CASE("temp_control", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { - std::ostringstream oss; - proxy.Call("now", {}, -1, GET, oss); - - // Get only - REQUIRE_THROWS(proxy.Call("now", {"2019"}, -1, PUT)); + if (det_type == defs::JUNGFRAU) { + auto prev_val = det.getTemperatureControl(); + { + std::ostringstream oss; + proxy.Call("temp_control", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "temp_control 0\n"); + } + { + std::ostringstream oss; + proxy.Call("temp_control", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "temp_control 1\n"); + } + { + std::ostringstream oss; + proxy.Call("temp_control", {}, -1, GET, oss); + REQUIRE(oss.str() == "temp_control 1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setTemperatureControl(prev_val[i], {i}); + } } else { - REQUIRE_THROWS(proxy.Call("now", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_control", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_control", {"0"}, -1, PUT)); } } -TEST_CASE("timestamp", "[.cmd]") { - // TODO! can we test this? +TEST_CASE("temp_event", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { - std::ostringstream oss; - proxy.Call("timestamp", {}, -1, GET, oss); - - // Get only - REQUIRE_THROWS(proxy.Call("timestamp", {"2019"}, -1, PUT)); + if (det_type == defs::JUNGFRAU) { + { + std::ostringstream oss; + proxy.Call("temp_event", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "temp_event cleared\n"); + } + { + std::ostringstream oss; + proxy.Call("temp_event", {}, -1, GET, oss); + REQUIRE(oss.str() == "temp_event 0\n"); + } } else { - REQUIRE_THROWS(proxy.Call("timestamp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_event", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_event", {"0"}, -1, PUT)); } } -TEST_CASE("adcreg", "[.cmd]") { - // TODO! what is a safe value to use? +TEST_CASE("auto_comp_disable", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD || - det_type == defs::GOTTHARD) { - std::ostringstream oss; - proxy.Call("adcreg", {"0x0", "0"}, -1, PUT, oss); - REQUIRE(oss.str() == "adcreg [0x0, 0]\n"); - // This is a put only command - REQUIRE_THROWS(proxy.Call("adcreg", {}, -1, GET)); + if (det_type == defs::JUNGFRAU) { + auto prev_val = det.getAutoCompDisable(); + { + std::ostringstream oss; + proxy.Call("auto_comp_disable", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "auto_comp_disable 0\n"); + } + { + std::ostringstream oss; + proxy.Call("auto_comp_disable", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "auto_comp_disable 1\n"); + } + { + std::ostringstream oss; + proxy.Call("auto_comp_disable", {}, -1, GET, oss); + REQUIRE(oss.str() == "auto_comp_disable 1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setAutoCompDisable(prev_val[i], {i}); + } } else { - REQUIRE_THROWS(proxy.Call("adcreg", {"0x0", "0"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("adcreg", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("auto_comp_disable", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("auto_comp_disable", {"0"}, -1, PUT)); } } -TEST_CASE("bustest", "[.cmd]") { +TEST_CASE("storagecells", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD || - det_type == defs::GOTTHARD) { - std::ostringstream oss; - proxy.Call("bustest", {}, -1, PUT, oss); - REQUIRE(oss.str() == "bustest successful\n"); - REQUIRE_THROWS(proxy.Call("bustest", {}, -1, GET)); + if (det_type == defs::JUNGFRAU) { + auto prev_val = det.getNumberOfAdditionalStorageCells().tsquash( + "inconsistent #additional storage cells to test"); + { + std::ostringstream oss; + proxy.Call("storagecells", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecells 1\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecells", {"15"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecells 15\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecells", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecells 0\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecells", {}, -1, GET, oss); + REQUIRE(oss.str() == "storagecells 0\n"); + } + REQUIRE_THROWS(proxy.Call("storagecells", {"16"}, -1, PUT)); + det.setNumberOfAdditionalStorageCells(prev_val); } else { - REQUIRE_THROWS(proxy.Call("bustest", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("bustest", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("storagecells", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("storagecells", {"0"}, -1, PUT)); } } -TEST_CASE("firmwaretest", "[.cmd]") { +TEST_CASE("storagecell_start", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD || - det_type == defs::GOTTHARD) { - std::ostringstream oss; - proxy.Call("firmwaretest", {}, -1, PUT, oss); - REQUIRE(oss.str() == "firmwaretest successful\n"); - REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, GET)); + if (det_type == defs::JUNGFRAU) { + auto prev_val = det.getStorageCellStart(); + { + std::ostringstream oss; + proxy.Call("storagecell_start", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecell_start 1\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecell_start", {"15"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecell_start 15\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecell_start", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecell_start 0\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecell_start", {}, -1, GET, oss); + REQUIRE(oss.str() == "storagecell_start 0\n"); + } + REQUIRE_THROWS(proxy.Call("storagecell_start", {"16"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setStorageCellStart(prev_val[i], {i}); + } } else { - REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("storagecell_start", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("storagecell_start", {"0"}, -1, PUT)); } } -TEST_CASE("resetfpga", "[.cmd]") { +TEST_CASE("storagecell_delay", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { - std::ostringstream oss; - proxy.Call("resetfpga", {}, -1, PUT, oss); - REQUIRE(oss.str() == "resetfpga successful\n"); - REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, GET)); + if (det_type == defs::JUNGFRAU) { + auto prev_val = det.getStorageCellDelay(); + { + std::ostringstream oss; + proxy.Call("storagecell_delay", {"1.62ms"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecell_delay 1.62ms\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecell_delay", {}, -1, GET, oss); + REQUIRE(oss.str() == "storagecell_delay 1.62ms\n"); + } + { + std::ostringstream oss; + proxy.Call("storagecell_delay", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "storagecell_delay 0\n"); + } + REQUIRE_THROWS(proxy.Call("storagecell_delay", {"1638376ns"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setStorageCellDelay(prev_val[i], {i}); + } } else { - REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("storagecell_delay", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("storagecell_delay", {"0"}, -1, PUT)); } -} +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 03c0f964a..602c65ae1 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -132,9 +132,6 @@ TEST_CASE("settings", "[.cmd][.new]") { auto det_type = det.getDetectorType().squash(); std::vector sett; switch (det_type) { - case defs::EIGER: - // FIXME: need to remove when settings removed - break; case defs::JUNGFRAU: sett.push_back("dynamicgain"); sett.push_back("dynamichg0"); @@ -166,7 +163,13 @@ TEST_CASE("settings", "[.cmd][.new]") { sett.push_back("g4_lg"); break; default: - REQUIRE_THROWS(proxy.Call("settings", {}, -1, GET)); + if (det_type == defs::EIGER) { + // FIXME: need to remove when settings removed + REQUIRE_NOTHROW(proxy.Call("settings", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("settings", {"standard"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("settings", {}, -1, GET)); + } return; } @@ -835,8 +838,6 @@ TEST_CASE("vhighvoltage", "[.cmd][.new]") { } TEST_CASE("powerchip", "[.cmd][.new]") { - // TODO! this test currently fails with the - // virtual detecto server Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -1148,6 +1149,34 @@ TEST_CASE("startingfnum", "[.cmd][.new]") { } } +TEST_CASE("gappixels", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::JUNGFRAU || det_type == defs::EIGER) { + auto prev_val = det.getGapPixelsinCallback(); + { + std::ostringstream oss; + proxy.Call("gappixels", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "gappixels 1\n"); + } + { + std::ostringstream oss; + proxy.Call("gappixels", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gappixels 0\n"); + } + { + std::ostringstream oss; + proxy.Call("gappixels", {}, -1, GET, oss); + REQUIRE(oss.str() == "gappixels 0\n"); + } + det.setGapPixelsinCallback(prev_val); + } else { + REQUIRE_THROWS(proxy.Call("gappixels", {}, -1, GET)); + } +} + /* Network Configuration (Detector<->Receiver) */ TEST_CASE("numinterfaces", "[.cmd][.new]") { @@ -1321,6 +1350,29 @@ TEST_CASE("udp_dstport2", "[.cmd][.new]") { } } +TEST_CASE("tengiga", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD) { + auto tengiga = det.getTenGiga(); + det.setTenGiga(false); + + std::ostringstream oss1, oss2; + proxy.Call("tengiga", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "tengiga 1\n"); + proxy.Call("tengiga", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "tengiga 1\n"); + + for (int i = 0; i != det.size(); ++i) { + det.setTenGiga(tengiga[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("tengiga", {}, -1, GET)); + } +} + TEST_CASE("flowcontrol10g", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); @@ -1523,6 +1575,138 @@ TEST_CASE("user", "[.cmd]") { REQUIRE_THROWS(proxy.Call("user", {}, -1, PUT)); } +TEST_CASE("lock", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + { + std::ostringstream oss; + proxy.Call("lock", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "lock 1\n"); + } + { + std::ostringstream oss; + proxy.Call("lock", {}, -1, GET, oss); + REQUIRE(oss.str() == "lock 1\n"); + } + { + std::ostringstream oss; + proxy.Call("lock", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "lock 0\n"); + } +} + +TEST_CASE("nframes", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { + auto nframes = det.getNumberOfFramesFromStart().squash(); + std::ostringstream oss; + proxy.Call("nframes", {}, -1, GET, oss); + REQUIRE(oss.str() == "nframes " + std::to_string(nframes) + "\n"); + + } else { + REQUIRE_THROWS(proxy.Call("nframes", {}, -1, GET)); + } +} + +TEST_CASE("now", "[.cmd]") { + // TODO! can we test this? + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { + std::ostringstream oss; + proxy.Call("now", {}, -1, GET, oss); + + // Get only + REQUIRE_THROWS(proxy.Call("now", {"2019"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("now", {}, -1, GET)); + } +} + +TEST_CASE("timestamp", "[.cmd]") { + // TODO! can we test this? + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { + std::ostringstream oss; + proxy.Call("timestamp", {}, -1, GET, oss); + + // Get only + REQUIRE_THROWS(proxy.Call("timestamp", {"2019"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("timestamp", {}, -1, GET)); + } +} + +TEST_CASE("adcreg", "[.cmd]") { + // TODO! what is a safe value to use? + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD || + det_type == defs::GOTTHARD) { + std::ostringstream oss; + proxy.Call("adcreg", {"0x0", "0"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcreg [0x0, 0]\n"); + // This is a put only command + REQUIRE_THROWS(proxy.Call("adcreg", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("adcreg", {"0x0", "0"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("adcreg", {}, -1, GET)); + } +} + +TEST_CASE("bustest", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD || + det_type == defs::GOTTHARD) { + std::ostringstream oss; + proxy.Call("bustest", {}, -1, PUT, oss); + REQUIRE(oss.str() == "bustest successful\n"); + REQUIRE_THROWS(proxy.Call("bustest", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("bustest", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("bustest", {}, -1, PUT)); + } +} + +TEST_CASE("firmwaretest", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD || + det_type == defs::GOTTHARD) { + std::ostringstream oss; + proxy.Call("firmwaretest", {}, -1, PUT, oss); + REQUIRE(oss.str() == "firmwaretest successful\n"); + REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, PUT)); + } +} + +TEST_CASE("resetfpga", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) { + std::ostringstream oss; + proxy.Call("resetfpga", {}, -1, PUT, oss); + REQUIRE(oss.str() == "resetfpga successful\n"); + REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, PUT)); + } +} + // TEST_CASE("reg", "[.cmd]") { // if (test::type == defs::JUNGFRAU) { // { @@ -2191,105 +2375,6 @@ TEST_CASE("user", "[.cmd]") { // } // } -// TEST_CASE("vm_a", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("vm_a", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("vm_b", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("vm_c", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("vm_d", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("vm_io", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("im_a", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("im_b", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("im_c", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("im_d", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("im_io", GET)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("vm_a", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vm_b", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vm_c", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vm_d", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("vm_io", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("im_a", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("im_b", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("im_c", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("im_d", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("im_io", GET)); -// } -// } - -// TEST_CASE("v_a", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// std::string s; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:v_limit", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("v_limit 1500", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "v_limit 1500\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("v_limit", GET, nullptr, -// oss)); REQUIRE(oss.str() == "v_limit 1500\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:v_a", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT, nullptr, oss)); -// REQUIRE(oss.str() == s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:v_b", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT, nullptr, oss)); -// REQUIRE(oss.str() == s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:v_c", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT, nullptr, oss)); -// REQUIRE(oss.str() == s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:v_d", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT, nullptr, oss)); -// REQUIRE(oss.str() == s); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:v_io", GET)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:v_chip", GET)); // do not -// set vchip -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("v_limit", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("v_a", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("v_b", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("v_c", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("v_d", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("v_io", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("v_chip", GET)); -// } -// } - // TEST_CASE("adcvpp", "[.cmd][.ctb]") { // if (test::type == defs::CHIPTESTBOARD) { // int prev_val = 0; @@ -2483,74 +2568,6 @@ TEST_CASE("user", "[.cmd]") { // } // } -// TEST_CASE("extsig", "[.cmd][.gotthard]") { -// if (test::type == defs::GOTTHARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsig -// trigger_in_falling_edge", PUT, nullptr, oss)); REQUIRE(oss.str() -// == "extsig trigger_in_falling_edge\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsig -// trigger_in_rising_edge", PUT, nullptr, oss)); REQUIRE(oss.str() -// == "extsig trigger_in_rising_edge\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsig", GET, nullptr, -// oss)); REQUIRE(oss.str() == "extsig trigger_in_rising_edge\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("extsig gating", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("extsig", GET)); -// } -// } - -// TEST_CASE("exptimel", "[.cmd][.gotthard]") { -// if (test::type == defs::GOTTHARD) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("exptime 5 s", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:exptimel s", GET, -// nullptr, oss)); std::string st = oss.str(); std::string s = -// st.erase (0, strlen("exptimel ")); double val = std::stod(s); -// REQUIRE(val >= 0); -// REQUIRE(val < 1000); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("exptime 1 ms", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("exptimel", GET)); -// } -// } - -// TEST_CASE("periodl", "[.cmd][.gotthard]") { -// if (test::type == defs::GOTTHARD || test::type == -// defs::JUNGFRAU || test::type == -// defs::CHIPTESTBOARD) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 2", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("period 5", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:periodl s", GET, -// nullptr, oss)); std::string st = oss.str(); std::string s = -// st.erase (0, strlen("periodl ")); double val = std::stod(s); -// REQUIRE(val >= 0); -// REQUIRE(val < 1000); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("period 1 s", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("periodl", GET)); -// } -// } - // TEST_CASE("roi", "[.cmd][.gotthard]") { // if (test::type == defs::GOTTHARD) { // { @@ -2575,579 +2592,6 @@ TEST_CASE("user", "[.cmd]") { // } // } -// TEST_CASE("storagecell_delay", "[.cmd][.jungfrau]") { -// if (test::type == defs::JUNGFRAU) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecell_delay 1.62ms", -// PUT, nullptr, oss)); REQUIRE(oss.str() == -// "storagecell_delay 1.62ms\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecell_delay", GET, -// nullptr, oss)); REQUIRE(oss.str() == -// "storagecell_delay 1.62ms\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecell_delay 0", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "storagecell_delay -// 0\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("storagecell_delay 1638376ns", -// PUT)); } else { -// REQUIRE_THROWS(multiSlsDetectorClient("storagecell_delay", GET)); -// } -// } - -// TEST_CASE("storagecell_start", "[.cmd][.jungfrau]") { -// if (test::type == defs::JUNGFRAU) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecell_start 1", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "storagecell_start -// 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecell_start 0", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "storagecell_start -// 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecell_start 15", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "storagecell_start -// 15\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecell_start", GET, -// nullptr, oss)); REQUIRE(oss.str() == "storagecell_start 15\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("storagecell_start 16", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("storagecell_start", GET)); -// } -// } - -// TEST_CASE("storagecells", "[.cmd][.jungfrau]") { -// if (test::type == defs::JUNGFRAU) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecells 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "storagecells 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecells 15", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "storagecells 15\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecells 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "storagecells 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("storagecells", GET, -// nullptr, oss)); REQUIRE(oss.str() == "storagecells 0\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("storagecells 16", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("storagecells", GET)); -// } -// } - -// TEST_CASE("auto_comp_disable", "[.cmd][.jungfrau]") { -// if (test::type == defs::JUNGFRAU) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("auto_comp_disable 1", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "auto_comp_disable -// 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("auto_comp_disable 0", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "auto_comp_disable -// 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("auto_comp_disable", GET, -// nullptr, oss)); REQUIRE(oss.str() == "auto_comp_disable 0\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("auto_comp_disable", GET)); -// } -// } - -// TEST_CASE("temp_", "[.cmd][.jungfrau]") { -// if (test::type == defs::JUNGFRAU) { -// std::string s; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:temp_threshold", GET, -// nullptr, oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT, nullptr, oss)); -// REQUIRE(oss.str() == s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("temp_control 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "temp_control 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("temp_control 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "temp_control 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("temp_control", GET, -// nullptr, oss)); REQUIRE(oss.str() == "temp_control 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("temp_event", GET, -// nullptr, oss)); REQUIRE(oss.str() == "temp_event 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("temp_event 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "temp_event cleared\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("temp_event 1", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("temp_threshold", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("temp_control", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("temp_event", GET)); -// } -// } - -// TEST_CASE("pulse", "[.cmd][.eiger]") { -// REQUIRE_THROWS(multiSlsDetectorClient("pulse", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("pulsenmove", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("pulsechip", GET)); -// if (test::type == defs::EIGER) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("pulse 1 1 5", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("pulsenmove 1 1 5", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("pulsechip 1", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("pulse 1 1 5", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("pulsenmove 1 1 5", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("pulsechip 1", PUT)); -// } -// } - -// TEST_CASE("partialreset", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("partialreset 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "partialreset 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("partialreset", GET, -// nullptr, oss)); REQUIRE(oss.str() == "partialreset 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("partialreset 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "partialreset 0\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("partialreset 1", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("partialreset 0", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("partialreset", GET)); -// } -// } - -// TEST_CASE("measuredsubperiod", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("dr 32", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT)); -// sleep(3); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:measuredsubperiod ms", -// GET, nullptr, oss)); std::string st = oss.str(); std::string s = -// st.erase (0, strlen("measuredsubperiod ")); double val = -// std::stod(s); REQUIRE(val >= 0); REQUIRE(val < 1000); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("dr 16", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("measuredsubperiod", GET)); -// } -// } - -// TEST_CASE("measuredperiod", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 2", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("period 1", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT)); -// sleep(3); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:measuredperiod", GET, -// nullptr, oss)); std::string st = oss.str(); std::string s = -// st.erase (0, strlen("measuredperiod ")); double val = -// std::stod(s); REQUIRE(val >= 1.0); REQUIRE(val < 2.0); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("measuredperiod", GET)); -// } -// } - -// TEST_CASE("readnlines", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("readnlines 256", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "readnlines 256\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("readnlines", GET, -// nullptr, oss)); REQUIRE(oss.str() == "readnlines 256\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("readnlines 16", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "readnlines 16\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("readnlines 0", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("readnlines 256", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("readnlines", GET)); -// } -// } - -// TEST_CASE("ratecorr", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("ratecorr 120", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "ratecorr 120ns\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("ratecorr", GET, nullptr, -// oss)); REQUIRE(oss.str() == "ratecorr 120ns\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("ratecorr 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "ratecorr 0ns\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("ratecorr -1", PUT)); -// REQUIRE_NOTHROW(multiSlsDetectorClient("ratecorr 0", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("ratecorr", GET)); -// } -// } - -// TEST_CASE("flippeddatax", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:flippeddatax", GET, -// nullptr, oss)); REQUIRE(oss.str() == "flippeddatax 0\n"); -// } -// DetectorImpl d; -// if (d.size() > 1) { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("1:flippeddatax", GET, -// nullptr, oss)); REQUIRE(oss.str() == "flippeddatax 1\n"); -// } -// } else { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("flippeddatax", GET, nullptr, -// oss)); REQUIRE(oss.str() == "flippeddatax 0\n"); -// } -// } - -// TEST_CASE("parallel", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("parallel 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "parallel 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("parallel", GET, nullptr, -// oss)); REQUIRE(oss.str() == "parallel 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("parallel 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "parallel 0\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("parallel", GET)); -// } -// } - -// TEST_CASE("gappixels", "[.cmd][.eiger]") { -// if (test::type == defs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("gappixels 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "gappixels 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("gappixels", GET, nullptr, -// oss)); REQUIRE(oss.str() == "gappixels 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("gappixels 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "gappixels 0\n"); -// } -// } else { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("gappixels", GET, nullptr, -// oss)); REQUIRE(oss.str() == "gappixels 0\n"); -// REQUIRE_THROWS(multiSlsDetectorClient("gappixels 1", PUT)); -// } -// } - -// TEST_CASE("settingspath", "[.cmd][.eiger]") { -// std::string s; -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("settingspath", GET, nullptr, -// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT)); -// } - -// TEST_CASE("txndelay", "[.cmd][.eiger][.jungfrau]") { -// if (test::type == defs::EIGER) { -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_frame 50000", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_frame", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_frame 50000\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("txndelay_frame 0", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_frame", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_frame 0\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_left 50000", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_left", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_left 50000\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("txndelay_left 0", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_left", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_left 0\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_right 50000", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_right", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_right 50000\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("txndelay_right 0", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_right", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_right 0\n"); -// } -// } else if (test::type == defs::JUNGFRAU) { -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("txndelay_frame 5", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_frame", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_frame 5\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("txndelay_frame 0", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:txndelay_frame", GET, -// nullptr, oss)); REQUIRE(oss.str() == "txndelay_frame 0\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("txndelay_frame 32", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("txndelay_left 32", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("txndelay_right 32", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("txndelay_frame", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("txndelay_left 32", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("txndelay_right 32", PUT)); -// } -// } - -// TEST_CASE("flowcontrol_10g", "[.cmd][.eiger][.jungfrau]") { -// if (test::type == defs::EIGER || test::type == -// defs::JUNGFRAU) { -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("flowcontrol_10g 1", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:flowcontrol_10g", GET, -// nullptr, oss)); REQUIRE(oss.str() == "flowcontrol_10g 1\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("flowcontrol_10g 0", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:flowcontrol_10g", GET, -// nullptr, oss)); REQUIRE(oss.str() == "flowcontrol_10g 0\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("flowcontrol_10g", GET)); -// } -// } - -// TEST_CASE("network", "[.cmd]") { -// /* {TODO custom srcip in globals -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_srcip 129.129.205.203", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_srcip", GET, nullptr, -// oss)); REQUIRE(oss.str() == "udp_srcip 129.129.205.203\n"); -// }*/ -// std::string udp_dstip; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstip", GET, nullptr, -// oss)); udp_dstip = oss.str(); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient(udp_dstip, PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstip", GET, nullptr, -// oss)); REQUIRE(oss.str() == udp_dstip); -// } -// /* {TODO custom dstip in globals -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstmac -// 10:e7:c6:48:bd:3f", PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstmac", GET, nullptr, -// oss)); REQUIRE(oss.str() == "udp_dstmac 10:e7:c6:48:bd:3f\n"); -// } */ -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstport 6200", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstport", GET, nullptr, -// oss)); REQUIRE(oss.str() == "udp_dstport 6200\n"); -// } -// { -// DetectorImpl d; -// int socketsperdetector = 1; -// if (test::type == defs::EIGER) { -// socketsperdetector *= 2; -// } else if (test::type == defs::JUNGFRAU) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("numinterfaces 2", PUT)); -// socketsperdetector *= 2; -// } -// int port = 5500; -// REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport " + -// std::to_string(port), PUT)); for (int i = 0; i != d.size(); ++i) { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + -// ":udp_dstport", GET, nullptr, oss)); REQUIRE(oss.str() == -// "udp_dstport " + std::to_string(port + i * socketsperdetector) + -// '\n'); -// } -// port = 50001; -// REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport " + -// std::to_string(port), PUT)); for (int i = 0; i != d.size(); ++i) { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + -// ":udp_dstport", GET, nullptr, oss)); REQUIRE(oss.str() == -// "udp_dstport " + std::to_string(port + i * socketsperdetector) + -// '\n'); -// } -// if (test::type == defs::JUNGFRAU) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("numinterfaces 1", PUT)); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport 50001", PUT)); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("udp_srcip 0.0.0.0", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("udp_srcip 124586954", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("udp_srcip 999.999.0.0.0.5", PUT)); - -// if (test::type == defs::JUNGFRAU) { -// /* {TODO custom srcip2 in globals -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_srcip2 -// 129.129.205.203", PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_srcip2", GET, -// nullptr, oss)); REQUIRE(oss.str() == "udp_srcip2 -// 129.129.205.203\n"); -// }*/ -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstip2", GET, -// nullptr, oss)); udp_dstip = oss.str(); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient(udp_dstip, PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstip2", GET, -// nullptr, oss)); REQUIRE(oss.str() == udp_dstip); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstmac2 -// 10:e7:c6:48:bd:3f", PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstmac2", GET, -// nullptr, oss)); REQUIRE(oss.str() == "udp_dstmac2 -// 10:e7:c6:48:bd:3f\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstport2 6400", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstport2", GET, -// nullptr, oss)); REQUIRE(oss.str() == "udp_dstport2 6400\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport2 50002", PUT)); -// } else if (test::type == defs::EIGER) { -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstport2 6400", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_dstport2", GET, -// nullptr, oss)); REQUIRE(oss.str() == "udp_dstport2 6400\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport2 50002", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("udp_srcip2", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("udp_dstip2", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("udp_srcmac2", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("udp_dstmac2", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("udp_dstport2", GET)); -// } -// } - -// TEST_CASE("selinterface", "[.cmd][.jungfrau]") { -// if (test::type == defs::JUNGFRAU) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("numinterfaces 1", PUT)); -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("selinterface 0", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:selinterface", GET, -// nullptr, oss)); REQUIRE(oss.str() == "selinterface 0\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("selinterface 1", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:selinterface", GET, -// nullptr, oss)); REQUIRE(oss.str() == "selinterface 1\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("selinterface 2", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("selinterface", GET)); -// } -// } - // TEST_CASE("adc", "[.cmd][.ctb]") { // if (test::type != defs::CHIPTESTBOARD) { // REQUIRE_THROWS(multiSlsDetectorClient("adc 8", GET)); @@ -3253,89 +2697,3 @@ TEST_CASE("user", "[.cmd]") { // std::to_string(prev_runclk), PUT)); // } // } - -// TEST_CASE("threshold", "[.cmd]") { -// if (test::type == defs::EIGER) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("threshold 6400 standard", -// PUT)); REQUIRE_NOTHROW(multiSlsDetectorClient("thresholdnotb 6400 -// standard", PUT)); REQUIRE_NOTHROW(multiSlsDetectorClient("threshold -// 6400", PUT)); REQUIRE_NOTHROW(multiSlsDetectorClient("thresholdnotb -// 6400", PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("threshold", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("threshold -// ")); REQUIRE(std::stoi(s) == 6400); -// REQUIRE_THROWS(multiSlsDetectorClient("thresholdnotb", GET)); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("threshold", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("thresholdnotb", GET)); -// } -// } - -// TEST_CASE("detsize", "[.cmd]") { -// CHECK_NOTHROW(multiSlsDetectorClient("detsize", GET)); -// } - -// TEST_CASE("type", "[.cmd]") { -// CHECK_NOTHROW(multiSlsDetectorClient("type", GET)); -// } - -// TEST_CASE("status", "[.cmd]") { -// Detector det; -// CmdProxy proxy(&det); - -// proxy.Call("timing", {"auto"}, -1, PUT); -// proxy.Call("frames", {"10"}, -1, PUT); -// proxy.Call("period", {"1"}, -1, PUT); - -// { -// std::ostringstream oss; -// proxy.Call("start", {}, -1, PUT, oss); -// REQUIRE(oss.str() == "start successful\n"); -// } -// { -// std::ostringstream oss; -// proxy.Call("status", {}, -1, GET, oss); -// REQUIRE(oss.str() == "status running\n"); -// } -// { -// std::ostringstream oss; -// proxy.Call("stop", {}, -1, PUT, oss); -// REQUIRE(oss.str() == "stop successful\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET, nullptr, oss)); -// REQUIRE(oss.str() != "status running\n"); -// REQUIRE(oss.str() != "status waiting\n"); -// REQUIRE(oss.str() != "status transmitting\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// proxy.Call("frames", {"1"}, -1, PUT); -// } - -TEST_CASE("lock", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - { - std::ostringstream oss; - proxy.Call("lock", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "lock 1\n"); - } - { - std::ostringstream oss; - proxy.Call("lock", {}, -1, GET, oss); - REQUIRE(oss.str() == "lock 1\n"); - } - { - std::ostringstream oss; - proxy.Call("lock", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "lock 0\n"); - } -} - -// TEST_CASE("lastclient", "[.cmd]") { -// REQUIRE_NOTHROW(multiSlsDetectorClient("lastclient", GET)); -// }