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/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index dd83c6028..f4d213b2b 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index 98bf99f1f..7e72e7ddb 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -1622,9 +1622,6 @@ int setDetectorPosition(int pos[]) { int *getDetectorPosition() { return detPos; } int enableTenGigabitEthernet(int val) { -#ifdef VIRTUAL - return 0; -#endif uint32_t addr = CONFIG_REG; // set diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 7ad3db9ac..bfbf7326d 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer 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/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 95156a086..cfa43ebac 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index b6787f389..6e0dc4b27 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 84d7d417b..e11e969cd 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index a0b431c8c..b65658212 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index aff1f21b7..7f4aa226a 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -1255,9 +1255,6 @@ int setDetectorPosition(int pos[]) { int *getDetectorPosition() { return detPos; } int enableTenGigabitEthernet(int val) { -#ifdef VIRTUAL - return 0; -#endif uint32_t addr = CONFIG_REG; // set diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index b46500b1d..d63d03585 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c index eb3a5d154..920bc4766 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c @@ -177,7 +177,9 @@ int main(int argc, char *argv[]) { #if defined(MYTHEN3D) || defined(GOTTHARD2D) rebootNiosControllerAndFPGA(); #else +#ifndef VIRTUAL system("reboot"); +#endif #endif } LOG(logINFO, ("Goodbye!\n")); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 6e0ca600f..da2eb635a 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -2591,8 +2591,8 @@ int get_period_left(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; -#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && \ - !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) +#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \ + && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/ functionNotImplemented(); #else // get only @@ -2607,8 +2607,8 @@ int get_delay_after_trigger_left(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; -#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) && !defined(CHIPTESTBOARDD) && \ - !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) +#if !defined(JUNGFRAUD) && !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \ + && !defined(MOENCHD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/ functionNotImplemented(); #else // get only @@ -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(); @@ -5633,7 +5633,8 @@ int set_readout_mode(int file_des) { if (ret == OK) { if (setReadoutMode(arg) == FAIL) { ret = FAIL; - sprintf(mess, "Could not set readout mode\n"); + sprintf(mess, "Could not set readout mode. Check #samples or " + "memory allocation\n"); LOG(logERROR, (mess)); } else { int retval = getReadoutMode(); diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index a2128bcdf..2a4d121bd 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 * @@ -1143,7 +1143,7 @@ class Detector { void setExternalSamplingSource(int value, Positions pos = {}); /** [CTB] */ - Result getExternalSampling(Positions pos = {}) const; + Result getExternalSampling(Positions pos = {}) const; /** [CTB] */ void setExternalSampling(bool value, Positions pos = {}); @@ -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 */ @@ -1324,7 +1324,7 @@ class Detector { /** [Jungfrau][CTB][Moench] */ void resetFPGA(Positions pos = {}); - /** [Jungfrau][Gotthard][CTB][Moench] + /** [Jungfrau][Gotthard][CTB][Moench][Mythen3][Gotthard2] * Copy detector server fname from tftp folder of hostname to detector * Also changes respawn server, which is effective after a reboot. */ diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index ee7c248f2..3c7e1103d 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'; @@ -1529,7 +1527,7 @@ std::string CmdProxy::ROI(int action) { t.xmin = StringTo(args[0]); t.xmax = StringTo(args[1]); det->setROI(t, det_id); - os << '[' << t.xmin << ", " << t.xmax << "] \n"; + os << '[' << t.xmin << ", " << t.xmax << "]\n"; } else { throw sls::RuntimeError("Unknown action"); } @@ -1550,7 +1548,7 @@ std::string CmdProxy::ClearROI(int action) { WrongNumberOfParameters(0); } det->clearROI({det_id}); - os << "[-1, -1] \n"; + os << "[-1, -1]\n"; } else { throw sls::RuntimeError("Unknown action"); } @@ -1963,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'; @@ -2363,7 +2361,9 @@ std::string CmdProxy::CopyDetectorServer(int action) { std::ostringstream os; os << cmd << ' '; if (action == defs::HELP_ACTION) { - os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb][Moench] Copies " + os << "[server_name] " + "[pc_host_name]\n\t[Jungfrau][Ctb][Moench][Mythen3][Gotthard2] " + "Copies " "detector " "server via tftp from pc and changes respawn server name in " "/etc/inittab of detector." diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 99d1fd717..e17172e02 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); @@ -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( @@ -2081,7 +2081,7 @@ class CmdProxy { INTEGER_COMMAND_HEX( adcinvert, getADCInvert, setADCInvert, StringTo, - "[bitmask]\n\t[Ctb][Moench][Jungfrau][Moench] ADC Inversion " + "[bitmask]\n\t[Ctb][Moench][Jungfrau] ADC Inversion " "Mask.\n\t[Jungfrau][Moench] Inversions on top of the default mask."); /* Insignificant */ @@ -2104,7 +2104,7 @@ class CmdProxy { "\n\tClient IP Address that last communicated with the detector."); GET_COMMAND(nframes, getNumberOfFramesFromStart, - "\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB][Moench] " + "\n\t[Jungfrau][Mythen3][Gotthard2][Moench][CTB] " "Number of frames from start run control." "\n\t[Gotthard2] only in continuous mode."); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 1a8988fa0..5ef42bd2c 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 { @@ -1468,7 +1468,7 @@ void Detector::setExternalSamplingSource(int value, Positions pos) { pimpl->Parallel(&Module::setExternalSamplingSource, pos, value); } -Result Detector::getExternalSampling(Positions pos) const { +Result Detector::getExternalSampling(Positions pos) const { return pimpl->Parallel(&Module::getExternalSampling, pos); } @@ -1525,13 +1525,17 @@ void Detector::savePattern(const std::string &fname) { proxy.Call("patword", {addr}, -1, defs::GET_ACTION, outfile); } // rest of pattern file - const std::vector commands{ + std::vector commands{ "patioctrl", "patclkctrl", "patlimits", "patloop0", "patnloop0", "patloop1", "patnloop1", "patloop2", "patnloop2", "patwait0", "patwaittime0", "patwait1", "patwaittime1", "patwait2", "patwaittime2", "patmask", "patsetbit", }; + auto det_type = getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + commands.erase(commands.begin(), commands.begin() + 2); + } for (const auto &cmd : commands) proxy.Call(cmd, {}, -1, defs::GET_ACTION, outfile); } diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index d4308c4ce..bf9dbf451 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -357,7 +357,7 @@ void DetectorImpl::setGapPixelsinCallback(const bool enable) { break; default: throw RuntimeError("Gap Pixels is not implemented for " + - multi_shm()->multiDetectorType); + ToString(multi_shm()->multiDetectorType)); } } multi_shm()->gapPixels = enable; diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 4940ed213..77dbf835f 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -1386,11 +1386,15 @@ bool Module::getInterruptSubframe() { uint32_t Module::writeRegister(uint32_t addr, uint32_t val) { uint32_t args[]{addr, val}; - return sendToDetector(F_WRITE_REGISTER, args); + uint32_t retval = -1; + sendToDetectorStop(F_WRITE_REGISTER, args, retval); + return retval; } uint32_t Module::readRegister(uint32_t addr) { - return sendToDetector(F_READ_REGISTER, addr); + uint32_t retval = -1; + sendToDetectorStop(F_READ_REGISTER, addr, retval); + return retval; } uint32_t Module::setBit(uint32_t addr, int n) { @@ -2197,11 +2201,14 @@ int Module::getExternalSamplingSource() { return setExternalSamplingSource(-1); } -int Module::setExternalSampling(int value) { - return sendToDetector(F_EXTERNAL_SAMPLING, value); +void Module::setExternalSampling(bool value) { + sendToDetector(F_EXTERNAL_SAMPLING, static_cast(value)); } -int Module::getExternalSampling() { return setExternalSampling(-1); } +bool Module::getExternalSampling() { + int arg = -1; + return sendToDetector(F_EXTERNAL_SAMPLING, arg); +} void Module::setReceiverDbitList(const std::vector &list) { LOG(logDEBUG1) << "Setting Receiver Dbit List"; diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 234ca6439..1e59c868b 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -1079,20 +1079,9 @@ class Module : public virtual slsDetectorDefs { */ int getExternalSamplingSource(); - /** - * Set external sampling enable (CTB only) - * @param value external sampling source (Option: 0-63) - * @param detPos -1 for all detectors in list or specific detector position - * @returns external sampling enable - */ - int setExternalSampling(int value); + void setExternalSampling(bool value); - /** - * Get external sampling source (CTB only) - * @param detPos -1 for all detectors in list or specific detector position - * @returns external sampling enable - */ - int getExternalSampling(); + bool getExternalSampling(); /** digital data bits enable (CTB only) */ void setReceiverDbitList(const std::vector &list); 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 c9fcb0311..b7300b515 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp @@ -17,8 +17,7 @@ using test::PUT; /* dacs */ -TEST_CASE("Setting and reading back Chip test board dacs", - "[.cmd][.dacs][.new]") { +TEST_CASE("dac", "[.cmd][.dacs][.new]") { // dac 0 to dac 17 Detector det; @@ -100,3 +99,803 @@ TEST_CASE("Setting and reading back Chip test board dacs", REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET)); } } + +TEST_CASE("adcvpp", "[.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.getDAC(defs::ADC_VPP, false); + { + std::ostringstream oss; + proxy.Call("adcvpp", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcvpp 1\n"); + } + { + std::ostringstream oss; + proxy.Call("adcvpp", {"1140", "mv"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcvpp 1140 mv\n"); + } + { + std::ostringstream oss; + proxy.Call("adcvpp", {"mv"}, -1, GET, oss); + REQUIRE(oss.str() == "adcvpp 1140 mv\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setDAC(defs::ADC_VPP, prev_val[i], false, {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("adcvpp", {}, -1, GET)); + } +} + +/* CTB/ Moench Specific */ + +TEST_CASE("samples", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) { + auto prev_asamples = det.getNumberOfAnalogSamples(); + sls::Result prev_dsamples = 0; + if (det_type == defs::CHIPTESTBOARD) { + prev_dsamples = det.getNumberOfDigitalSamples(); + } + { + std::ostringstream oss; + proxy.Call("samples", {"25"}, -1, PUT, oss); + REQUIRE(oss.str() == "samples 25\n"); + } + { + std::ostringstream oss; + proxy.Call("samples", {"450"}, -1, PUT, oss); + REQUIRE(oss.str() == "samples 450\n"); + } + { + std::ostringstream oss; + proxy.Call("samples", {}, -1, GET, oss); + REQUIRE(oss.str() == "samples 450\n"); + } + { + std::ostringstream oss; + proxy.Call("asamples", {}, -1, GET, oss); + REQUIRE(oss.str() == "asamples 450\n"); + } + if (det_type == defs::CHIPTESTBOARD) { + std::ostringstream oss; + proxy.Call("dsamples", {}, -1, GET, oss); + REQUIRE(oss.str() == "dsamples 450\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setNumberOfAnalogSamples(prev_asamples[i], {i}); + if (det_type == defs::CHIPTESTBOARD) { + det.setNumberOfDigitalSamples(prev_dsamples[i], {i}); + } + } + } else { + REQUIRE_THROWS(proxy.Call("samples", {}, -1, GET)); + } +} + +TEST_CASE("asamples", "[.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.getNumberOfAnalogSamples(); + { + std::ostringstream oss; + proxy.Call("asamples", {"25"}, -1, PUT, oss); + REQUIRE(oss.str() == "asamples 25\n"); + } + { + std::ostringstream oss; + proxy.Call("asamples", {"450"}, -1, PUT, oss); + REQUIRE(oss.str() == "asamples 450\n"); + } + { + std::ostringstream oss; + proxy.Call("asamples", {}, -1, GET, oss); + REQUIRE(oss.str() == "asamples 450\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setNumberOfAnalogSamples(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("asamples", {}, -1, GET)); + } +} + +TEST_CASE("adcclk", "[.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.getADCClock(); + { + std::ostringstream oss; + proxy.Call("adcclk", {"20"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcclk 20\n"); + } + { + std::ostringstream oss; + proxy.Call("adcclk", {"10"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcclk 10\n"); + } + { + std::ostringstream oss; + proxy.Call("adcclk", {}, -1, GET, oss); + REQUIRE(oss.str() == "adcclk 10\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setADCClock(prev_val[i], {i}); + } + } else { + // clock index might work + // REQUIRE_THROWS(proxy.Call("adcclk", {}, -1, GET)); + } +} + +TEST_CASE("runclk", "[.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.getRUNClock(); + { + std::ostringstream oss; + proxy.Call("runclk", {"20"}, -1, PUT, oss); + REQUIRE(oss.str() == "runclk 20\n"); + } + { + std::ostringstream oss; + proxy.Call("runclk", {"10"}, -1, PUT, oss); + REQUIRE(oss.str() == "runclk 10\n"); + } + { + std::ostringstream oss; + proxy.Call("runclk", {}, -1, GET, oss); + REQUIRE(oss.str() == "runclk 10\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRUNClock(prev_val[i], {i}); + } + } else { + // clock index might work + // REQUIRE_THROWS(proxy.Call("runclk", {}, -1, GET)); + } +} + +TEST_CASE("syncclk", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) { + REQUIRE_NOTHROW(proxy.Call("syncclk", {}, -1, GET)); + } else { + // clock index might work + // REQUIRE_THROWS(proxy.Call("syncclk", {}, -1, GET)); + } +} + +TEST_CASE("adcpipeline", "[.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.getADCPipeline(); + { + std::ostringstream oss; + proxy.Call("adcpipeline", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcpipeline 1\n"); + } + { + std::ostringstream oss; + proxy.Call("adcpipeline", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcpipeline 0\n"); + } + { + std::ostringstream oss; + proxy.Call("adcpipeline", {"15"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcpipeline 15\n"); + } + { + std::ostringstream oss; + proxy.Call("adcpipeline", {}, -1, GET, oss); + REQUIRE(oss.str() == "adcpipeline 15\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setADCPipeline(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("adcpipeline", {}, -1, GET)); + } +} + +TEST_CASE("v_limit", "[.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.getVoltage(defs::V_LIMIT); + { + std::ostringstream oss; + proxy.Call("v_limit", {"1500"}, -1, PUT, oss); + REQUIRE(oss.str() == "v_limit 1500\n"); + } + { + std::ostringstream oss; + proxy.Call("v_limit", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "v_limit 0\n"); + } + { + std::ostringstream oss; + proxy.Call("v_limit", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "v_limit 0\n"); + } + { + std::ostringstream oss; + proxy.Call("v_limit", {}, -1, GET, oss); + REQUIRE(oss.str() == "v_limit 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + if (prev_val[i] == -100) { + prev_val[i] = 0; + } + det.setVoltage(defs::V_LIMIT, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("v_limit", {}, -1, GET)); + } +} + +TEST_CASE("adcenable", "[.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.getADCEnableMask(); + { + std::ostringstream oss; + proxy.Call("adcenable", {"0x8d0aa0d8"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable 0x8d0aa0d8\n"); + } + { + std::ostringstream oss; + proxy.Call("adcenable", {"0xffffffff"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable 0xffffffff\n"); + } + { + std::ostringstream oss; + proxy.Call("adcenable", {}, -1, GET, oss); + REQUIRE(oss.str() == "adcenable 0xffffffff\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setADCEnableMask(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("adcenable", {}, -1, GET)); + } +} + +TEST_CASE("adcenable10g", "[.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.getTenGigaADCEnableMask(); + { + std::ostringstream oss; + proxy.Call("adcenable10g", {"0xff0000ff"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable10g 0xff0000ff\n"); + } + { + std::ostringstream oss; + proxy.Call("adcenable10g", {"0xffffffff"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable10g 0xffffffff\n"); + } + { + std::ostringstream oss; + proxy.Call("adcenable10g", {}, -1, GET, oss); + REQUIRE(oss.str() == "adcenable10g 0xffffffff\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setTenGigaADCEnableMask(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("adcenable10g", {}, -1, GET)); + } +} + +/* CTB Specific */ + +TEST_CASE("dsamples", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getNumberOfDigitalSamples(); + { + std::ostringstream oss; + proxy.Call("dsamples", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "dsamples 1\n"); + } + { + std::ostringstream oss; + proxy.Call("dsamples", {"450"}, -1, PUT, oss); + REQUIRE(oss.str() == "dsamples 450\n"); + } + { + std::ostringstream oss; + proxy.Call("dsamples", {}, -1, GET, oss); + REQUIRE(oss.str() == "dsamples 450\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setNumberOfDigitalSamples(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("dsamples", {}, -1, GET)); + } +} + +TEST_CASE("romode", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + auto prev_romode = det.getReadoutMode(); + auto prev_asamples = det.getNumberOfAnalogSamples(); + auto prev_dsamples = det.getNumberOfDigitalSamples(); + det.setNumberOfAnalogSamples(5000); + det.setNumberOfDigitalSamples(5000); + { + std::ostringstream oss; + proxy.Call("romode", {"digital"}, -1, PUT, oss); + REQUIRE(oss.str() == "romode digital\n"); + } + { + std::ostringstream oss; + proxy.Call("romode", {"analog_digital"}, -1, PUT, oss); + REQUIRE(oss.str() == "romode analog_digital\n"); + } + { + std::ostringstream oss; + proxy.Call("romode", {"analog"}, -1, PUT, oss); + REQUIRE(oss.str() == "romode analog\n"); + } + { + std::ostringstream oss; + proxy.Call("romode", {}, -1, GET, oss); + REQUIRE(oss.str() == "romode analog\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setReadoutMode(prev_romode[i], {i}); + det.setNumberOfAnalogSamples(prev_asamples[i], {i}); + det.setNumberOfDigitalSamples(prev_dsamples[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("romode", {}, -1, GET)); + } +} + +TEST_CASE("dbitclk", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getRUNClock(); + { + std::ostringstream oss; + proxy.Call("dbitclk", {"20"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitclk 20\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitclk", {"10"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitclk 10\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitclk", {}, -1, GET, oss); + REQUIRE(oss.str() == "dbitclk 10\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRUNClock(prev_val[i], {i}); + } + } else { + // clock index might work + // REQUIRE_THROWS(proxy.Call("dbitclk", {}, -1, GET)); + } +} + +TEST_CASE("dbitpipeline", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getDBITPipeline(); + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitpipeline 1\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitpipeline 0\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {"15"}, -1, PUT, oss); + REQUIRE(oss.str() == "dbitpipeline 15\n"); + } + { + std::ostringstream oss; + proxy.Call("dbitpipeline", {}, -1, GET, oss); + REQUIRE(oss.str() == "dbitpipeline 15\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setDBITPipeline(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("dbitpipeline", {}, -1, GET)); + } +} + +TEST_CASE("v_a", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getVoltage(defs::V_POWER_A); + { + std::ostringstream oss1, oss2; + proxy.Call("v_a", {"700"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "v_a 700\n"); + proxy.Call("v_a", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "v_a 700\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setVoltage(defs::V_POWER_A, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("v_a", {}, -1, GET)); + } +} + +TEST_CASE("v_b", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getVoltage(defs::V_POWER_B); + { + std::ostringstream oss1, oss2; + proxy.Call("v_b", {"700"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "v_b 700\n"); + proxy.Call("v_b", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "v_b 700\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setVoltage(defs::V_POWER_B, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("v_b", {}, -1, GET)); + } +} + +TEST_CASE("v_c", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getVoltage(defs::V_POWER_C); + { + std::ostringstream oss1, oss2; + proxy.Call("v_c", {"700"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "v_c 700\n"); + proxy.Call("v_c", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "v_c 700\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setVoltage(defs::V_POWER_C, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("v_c", {}, -1, GET)); + } +} + +TEST_CASE("v_d", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getVoltage(defs::V_POWER_D); + { + std::ostringstream oss1, oss2; + proxy.Call("v_d", {"700"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "v_d 700\n"); + proxy.Call("v_d", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "v_d 700\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setVoltage(defs::V_POWER_D, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("v_d", {}, -1, GET)); + } +} + +TEST_CASE("v_io", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + // better not to play with setting it + REQUIRE_NOTHROW(proxy.Call("v_io", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("v_io", {}, -1, GET)); + } +} + +TEST_CASE("v_chip", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + // better not to play with setting it + REQUIRE_NOTHROW(proxy.Call("v_chip", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("v_chip", {}, -1, GET)); + } +} + +TEST_CASE("vm_a", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("vm_a", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("vm_a", {}, -1, GET)); + } +} + +TEST_CASE("vm_b", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("vm_b", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("vm_b", {}, -1, GET)); + } +} + +TEST_CASE("vm_c", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("vm_c", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("vm_c", {}, -1, GET)); + } +} + +TEST_CASE("vm_d", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("vm_d", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("vm_d", {}, -1, GET)); + } +} + +TEST_CASE("vm_io", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("vm_io", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("vm_io", {}, -1, GET)); + } +} + +TEST_CASE("im_a", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("im_a", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("im_a", {}, -1, GET)); + } +} + +TEST_CASE("im_b", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("im_b", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("im_b", {}, -1, GET)); + } +} + +TEST_CASE("im_c", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("im_c", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("im_c", {}, -1, GET)); + } +} + +TEST_CASE("im_d", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("im_d", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("im_d", {}, -1, GET)); + } +} + +TEST_CASE("im_io", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + REQUIRE_NOTHROW(proxy.Call("im_io", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("im_io", {}, -1, GET)); + } +} + +TEST_CASE("adc", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::CHIPTESTBOARD) { + for (int i = 0; i <= 8; ++i) { + REQUIRE_NOTHROW(proxy.Call("adc", {std::to_string(i)}, -1, GET)); + REQUIRE_THROWS(proxy.Call("adc", {"0"}, -1, PUT)); + } + } else { + REQUIRE_THROWS(proxy.Call("adc", {"0"}, -1, GET)); + } +} + +TEST_CASE("extsampling", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getExternalSampling(); + { + std::ostringstream oss; + proxy.Call("extsampling", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "extsampling 1\n"); + } + { + std::ostringstream oss; + proxy.Call("extsampling", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "extsampling 0\n"); + } + { + std::ostringstream oss; + proxy.Call("extsampling", {}, -1, GET, oss); + REQUIRE(oss.str() == "extsampling 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setExternalSampling(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("extsampling", {}, -1, GET)); + } +} + +TEST_CASE("extsamplingsrc", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getExternalSamplingSource(); + { + std::ostringstream oss; + proxy.Call("extsamplingsrc", {"63"}, -1, PUT, oss); + REQUIRE(oss.str() == "extsamplingsrc 63\n"); + } + { + std::ostringstream oss; + proxy.Call("extsamplingsrc", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "extsamplingsrc 0\n"); + } + { + std::ostringstream oss; + proxy.Call("extsamplingsrc", {}, -1, GET, oss); + REQUIRE(oss.str() == "extsamplingsrc 0\n"); + } + REQUIRE_THROWS(proxy.Call("extsamplingsrc", {"64"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setExternalSamplingSource(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("extsamplingsrc", {}, -1, GET)); + } +} + +TEST_CASE("diodelay", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD) { + { + std::ostringstream oss; + proxy.Call("diodelay", {"0x01010", "0"}, -1, PUT, oss); + REQUIRE(oss.str() == "diodelay [0x01010, 0]\n"); + } + { + std::ostringstream oss; + proxy.Call("diodelay", {"0x01010", "775"}, -1, PUT, oss); + REQUIRE(oss.str() == "diodelay [0x01010, 775]\n"); + } + REQUIRE_THROWS(proxy.Call("diodelay", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("diodelay", {"0x01010", "776"}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("diodelay", {"0x01010", "775"}, -1, PUT)); + } +} + +TEST_CASE("led", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::CHIPTESTBOARD) { + auto prev_val = det.getLEDEnable(); + { + std::ostringstream oss; + proxy.Call("led", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "led 1\n"); + } + { + std::ostringstream oss; + proxy.Call("led", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "led 0\n"); + } + { + std::ostringstream oss; + proxy.Call("led", {}, -1, GET, oss); + REQUIRE(oss.str() == "led 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setLEDEnable(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("led", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp index 808621404..c2752e03d 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-eiger.cpp @@ -4,6 +4,7 @@ #include "sls_detector_defs.h" #include #include +#include #include "test-CmdProxy-global.h" #include "tests/globals.h" @@ -242,8 +243,14 @@ TEST_CASE("trigger", "[.cmd][.new]") { det.getTimingMode().tsquash("inconsistent timing mode in test"); auto prev_frames = det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + auto prev_exptime = + det.getExptime().tsquash("inconsistent exptime in test"); + auto prev_period = + det.getPeriod().tsquash("inconsistent period in test"); det.setTimingMode(defs::TRIGGER_EXPOSURE); det.setNumberOfFrames(1); + det.setExptime(std::chrono::milliseconds(1)); + det.setPeriod(std::chrono::milliseconds(1)); auto startingfnum = det.getStartingFrameNumber().tsquash( "inconsistent frame nr in test"); det.startDetector(); @@ -252,6 +259,7 @@ TEST_CASE("trigger", "[.cmd][.new]") { proxy.Call("trigger", {}, -1, PUT, oss); REQUIRE(oss.str() == "trigger successful\n"); } + std::this_thread::sleep_for(std::chrono::seconds(2)); auto currentfnum = det.getStartingFrameNumber().tsquash( "inconsistent frame nr in test"); REQUIRE(startingfnum + 1 == currentfnum); @@ -263,52 +271,55 @@ TEST_CASE("trigger", "[.cmd][.new]") { /* Network Configuration (Detector<->Receiver) */ -TEST_CASE("Eiger transmission delay", "[.cmd]") { +TEST_CASE("txndelay_left", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - auto frame = det.getTransmissionDelayFrame(); - auto left = det.getTransmissionDelayLeft(); - auto right = det.getTransmissionDelayRight(); if (det_type == defs::EIGER) { - SECTION("txndelay_frame") { - std::ostringstream oss1, oss2; - proxy.Call("txndelay_frame", {"5000"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "txndelay_frame 5000\n"); - proxy.Call("txndelay_frame", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "txndelay_frame 5000\n"); - } - SECTION("txndelay_left") { + auto prev_val = det.getTransmissionDelayLeft(); + { std::ostringstream oss1, oss2; proxy.Call("txndelay_left", {"5000"}, -1, PUT, oss1); REQUIRE(oss1.str() == "txndelay_left 5000\n"); proxy.Call("txndelay_left", {}, -1, GET, oss2); REQUIRE(oss2.str() == "txndelay_left 5000\n"); } - SECTION("txndelay_right") { + for (int i = 0; i != det.size(); ++i) { + det.setTransmissionDelayLeft(prev_val[i]); + } + } else { + REQUIRE_THROWS(proxy.Call("txndelay_left", {}, -1, GET)); + } +} + +TEST_CASE("txndelay_right", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + auto prev_val = det.getTransmissionDelayRight(); + { std::ostringstream oss1, oss2; proxy.Call("txndelay_right", {"5000"}, -1, PUT, oss1); REQUIRE(oss1.str() == "txndelay_right 5000\n"); proxy.Call("txndelay_right", {}, -1, GET, oss2); REQUIRE(oss2.str() == "txndelay_right 5000\n"); } - - // Reset to previous values for (int i = 0; i != det.size(); ++i) { - det.setTransmissionDelayFrame(frame[i]); - det.setTransmissionDelayLeft(left[i]); - det.setTransmissionDelayRight(right[i]); + det.setTransmissionDelayRight(prev_val[i]); } + } else { + REQUIRE_THROWS(proxy.Call("txndelay_right", {}, -1, GET)); } } -TEST_CASE("dr", "[.cmd]") { +/* Eiger Specific */ + +TEST_CASE("dr", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::EIGER) { - // The only detector currently supporting setting dr - // is EIGER? auto dr = det.getDynamicRange().squash(); std::array vals{4, 8, 16, 32}; for (const auto val : vals) { @@ -319,6 +330,17 @@ TEST_CASE("dr", "[.cmd]") { REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n'); } det.setDynamicRange(dr); + } else if (det_type == defs::MYTHEN3) { + // not updated in firmware to support anything other than 32 at the + // moment + std::ostringstream oss1, oss2; + proxy.Call("dr", {"32"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "dr 32\n"); + proxy.Call("dr", {"32"}, -1, PUT, oss2); + REQUIRE(oss2.str() == "dr 32\n"); + REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("dr", {"16"}, -1, PUT)); } else { // For the other detectors we should get an error message // except for dr 16 @@ -334,124 +356,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); @@ -472,7 +377,7 @@ TEST_CASE("subexptime", "[.cmd]") { } } -TEST_CASE("subdeadtime", "[.cmd]") { +TEST_CASE("subdeadtime", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); @@ -493,37 +398,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-gotthard.cpp b/slsDetectorSoftware/tests/test-CmdProxy-gotthard.cpp index 8528cecf2..189ad6741 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-gotthard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-gotthard.cpp @@ -94,3 +94,62 @@ TEST_CASE("Setting and reading back GOTTHARD dacs", "[.cmd][.dacs][.new]") { REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET)); } } + +/* Gotthard Specific */ + +TEST_CASE("roi", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD) { + auto prev_val = det.getROI(); + { + std::ostringstream oss; + proxy.Call("roi", {"0", "255"}, -1, PUT, oss); + REQUIRE(oss.str() == "roi [0, 255]\n"); + } + { + std::ostringstream oss; + proxy.Call("roi", {"256", "511"}, -1, PUT, oss); + REQUIRE(oss.str() == "roi [256, 511]\n"); + } + REQUIRE_THROWS(proxy.Call("roi", {"0", "256"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setROI(prev_val[i], i); + } + } else { + REQUIRE_THROWS(proxy.Call("roi", {}, -1, GET)); + } +} + +TEST_CASE("clearroi", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD) { + auto prev_val = det.getROI(); + { + std::ostringstream oss; + proxy.Call("clearroi", {}, -1, PUT, oss); + REQUIRE(oss.str() == "clearroi [-1, -1]\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setROI(prev_val[i], i); + } + } else { + REQUIRE_THROWS(proxy.Call("clearroi", {}, -1, PUT)); + } +} + +TEST_CASE("exptimel", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::GOTTHARD) { + REQUIRE_NOTHROW(proxy.Call("exptimel", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("exptimel", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp b/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp index ab7c19649..052f4a97e 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-gotthard2.cpp @@ -15,82 +15,6 @@ using sls::Detector; using test::GET; using test::PUT; -/* acquisition parameters */ - -TEST_CASE("bursts", "[.cmd][.new]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::GOTTHARD2) { - auto prev_burst = - det.getNumberOfBursts().tsquash("#bursts should be same to test"); - auto prev_trigger = - det.getNumberOfFrames().tsquash("#frames should be same to test"); - auto prev_frames = det.getNumberOfTriggers().tsquash( - "#triggers should be same to test"); - auto prev_timingMode = det.getTimingMode(); - auto prev_burstMode = det.getBurstMode(); - // changing continuous mode frames and bursts - det.setBurstMode(defs::BURST_INTERNAL); - det.setTimingMode(defs::AUTO_TIMING); - { - std::ostringstream oss; - proxy.Call("bursts", {"3"}, -1, PUT, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - REQUIRE_THROWS(proxy.Call("bursts", {"0"}, -1, PUT)); - // trigger mode: reg set to 1, but bursts must be same - det.setTimingMode(defs::TRIGGER_EXPOSURE); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - det.setTimingMode(defs::AUTO_TIMING); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - // continuous mode: reg set to #frames, - // but bursts should return same value - det.setBurstMode(defs::BURST_OFF); - det.setNumberOfFrames(2); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - det.setTimingMode(defs::TRIGGER_EXPOSURE); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - det.setBurstMode(defs::BURST_INTERNAL); - { - std::ostringstream oss; - proxy.Call("bursts", {}, -1, GET, oss); - REQUIRE(oss.str() == "bursts 3\n"); - } - // set to previous values - det.setNumberOfBursts(prev_burst); - det.setNumberOfFrames(prev_frames); - det.setNumberOfTriggers(prev_trigger); - for (int i = 0; i != det.size(); ++i) { - det.setTimingMode(prev_timingMode[i], {i}); - det.setBurstMode(prev_burstMode[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("bursts", {}, -1, GET)); - } -} - /* dacs */ TEST_CASE("Setting and reading back GOTTHARD2 dacs", "[.cmd][.dacs][.new]") { @@ -262,7 +186,164 @@ TEST_CASE("vchip_cs", "[.cmd][.onchipdacs][.new]") { } } -TEST_CASE("burstmode", "[.cmd]") { +/* Gotthard2 Specific */ + +TEST_CASE("bursts", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::GOTTHARD2) { + auto prev_burst = + det.getNumberOfBursts().tsquash("#bursts should be same to test"); + auto prev_trigger = + det.getNumberOfFrames().tsquash("#frames should be same to test"); + auto prev_frames = det.getNumberOfTriggers().tsquash( + "#triggers should be same to test"); + auto prev_timingMode = det.getTimingMode(); + auto prev_burstMode = det.getBurstMode(); + // changing continuous mode frames and bursts + det.setBurstMode(defs::BURST_INTERNAL); + det.setTimingMode(defs::AUTO_TIMING); + { + std::ostringstream oss; + proxy.Call("bursts", {"3"}, -1, PUT, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + REQUIRE_THROWS(proxy.Call("bursts", {"0"}, -1, PUT)); + // trigger mode: reg set to 1, but bursts must be same + det.setTimingMode(defs::TRIGGER_EXPOSURE); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + det.setTimingMode(defs::AUTO_TIMING); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + // continuous mode: reg set to #frames, + // but bursts should return same value + det.setBurstMode(defs::BURST_OFF); + det.setNumberOfFrames(2); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + det.setTimingMode(defs::TRIGGER_EXPOSURE); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + det.setBurstMode(defs::BURST_INTERNAL); + { + std::ostringstream oss; + proxy.Call("bursts", {}, -1, GET, oss); + REQUIRE(oss.str() == "bursts 3\n"); + } + // set to previous values + det.setNumberOfBursts(prev_burst); + det.setNumberOfFrames(prev_frames); + det.setNumberOfTriggers(prev_trigger); + for (int i = 0; i != det.size(); ++i) { + det.setTimingMode(prev_timingMode[i], {i}); + det.setBurstMode(prev_burstMode[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("bursts", {}, -1, GET)); + } +} + +TEST_CASE("burstperiod", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + auto previous = det.getBurstPeriod(); + + std::ostringstream oss_set, oss_get; + proxy.Call("burstperiod", {"30ms"}, -1, PUT, oss_set); + REQUIRE(oss_set.str() == "burstperiod 30ms\n"); + proxy.Call("burstperiod", {}, -1, GET, oss_get); + REQUIRE(oss_get.str() == "burstperiod 30ms\n"); + // Reset to previous value + for (int i = 0; i != det.size(); ++i) { + det.setBurstPeriod(previous[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("burstperiod", {}, -1, GET)); + } +} + +TEST_CASE("inj_ch", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + REQUIRE_THROWS( + proxy.Call("inj_ch", {"-1", "1"}, -1, PUT)); // invalid offset + REQUIRE_THROWS( + proxy.Call("inj_ch", {"0", "0"}, -1, PUT)); // invalid increment + { + std::ostringstream oss; + proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss); + REQUIRE(oss.str() == "inj_ch [0, 1]\n"); + } + { + std::ostringstream oss; + proxy.Call("inj_ch", {}, -1, GET, oss); + REQUIRE(oss.str() == "inj_ch [0, 1]\n"); + } + } else { + REQUIRE_THROWS(proxy.Call("inj_ch", {}, -1, GET)); + } +} + +TEST_CASE("vetophoton", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET)); + REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1, + PUT)); // invalid chip index + REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1, + PUT)); // invalid photon number + REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1, + PUT)); // invald file + } else { + REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET)); + } +} + +TEST_CASE("vetoref", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1, + PUT)); // invalid chip index + REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT)); + } +} + +TEST_CASE("burstmode", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -293,92 +374,7 @@ TEST_CASE("burstmode", "[.cmd]") { } } -TEST_CASE("vetoref", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1, - PUT)); // invalid chip index - REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT)); - } else { - REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT)); - } -} - -TEST_CASE("vetophoton", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET)); - REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET)); - REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1, - PUT)); // invalid chip index - REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1, - PUT)); // invalid photon number - REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1, - PUT)); // invald file - } else { - REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET)); - } -} - -TEST_CASE("inj_ch", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - auto inj = det.getInjectChannel(); - REQUIRE_THROWS( - proxy.Call("inj_ch", {"-1", "1"}, -1, PUT)); // invalid offset - REQUIRE_THROWS( - proxy.Call("inj_ch", {"0", "0"}, -1, PUT)); // invalid increment - { - std::ostringstream oss; - proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss); - REQUIRE(oss.str() == "inj_ch [0, 1]\n"); - } - { - std::ostringstream oss; - proxy.Call("inj_ch", {}, -1, GET, oss); - REQUIRE(oss.str() == "inj_ch [0, 1]\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setInjectChannel(inj[i][0], inj[i][1], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("inj_ch", {}, -1, GET)); - } -} - -TEST_CASE("burstperiod", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - - if (det_type == defs::GOTTHARD2) { - auto previous = det.getBurstPeriod(); - - std::ostringstream oss_set, oss_get; - proxy.Call("burstperiod", {"30ms"}, -1, PUT, oss_set); - REQUIRE(oss_set.str() == "burstperiod 30ms\n"); - proxy.Call("burstperiod", {}, -1, GET, oss_get); - REQUIRE(oss_get.str() == "burstperiod 30ms\n"); - // Reset to previous value - for (int i = 0; i != det.size(); ++i) { - det.setBurstPeriod(previous[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("burstperiod", {}, -1, GET)); - } -} - -TEST_CASE("currentsource", "[.cmd]") { +TEST_CASE("currentsource", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -408,7 +404,7 @@ TEST_CASE("currentsource", "[.cmd]") { } } -TEST_CASE("timingsource", "[.cmd]") { +TEST_CASE("timingsource", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -437,3 +433,33 @@ TEST_CASE("timingsource", "[.cmd]") { REQUIRE_THROWS(proxy.Call("timingsource", {}, -1, GET)); } } + +TEST_CASE("veto", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::GOTTHARD2) { + auto prev_val = det.getVeto(); + { + std::ostringstream oss; + proxy.Call("veto", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "veto 1\n"); + } + { + std::ostringstream oss; + proxy.Call("veto", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "veto 0\n"); + } + { + std::ostringstream oss; + proxy.Call("veto", {}, -1, GET, oss); + REQUIRE(oss.str() == "veto 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setVeto(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("veto", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index 7c74cd0b2..fa5d65221 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -94,114 +94,248 @@ TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmd][.dacs][.new]") { } } -TEST_CASE("nframes", "[.cmd]") { +/* Network Configuration (Detector<->Receiver) */ + +TEST_CASE("selinterface", "[.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.getSelectedUDPInterface().tsquash( + "inconsistent selected interface to test"); + { + std::ostringstream oss; + proxy.Call("selinterface", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "selinterface 1\n"); + } + { + std::ostringstream oss; + proxy.Call("selinterface", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "selinterface 0\n"); + } + { + std::ostringstream oss; + proxy.Call("selinterface", {}, -1, GET, oss); + REQUIRE(oss.str() == "selinterface 0\n"); + } + det.selectUDPInterface(prev_val); + REQUIRE_THROWS(proxy.Call("selinterface", {"2"}, -1, PUT)); } else { - REQUIRE_THROWS(proxy.Call("nframes", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("selinterface", {}, -1, GET)); } } -TEST_CASE("now", "[.cmd]") { - // TODO! can we test this? +/* 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) { - 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.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("now", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_threshold", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_threshold", {"70"}, -1, PUT)); } } -TEST_CASE("timestamp", "[.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("timestamp", {}, -1, GET, oss); - - // Get only - REQUIRE_THROWS(proxy.Call("timestamp", {"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("timestamp", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_control", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_control", {"0"}, -1, PUT)); } } -TEST_CASE("adcreg", "[.cmd]") { - // TODO! what is a safe value to use? +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 || - 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) { + { + 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("adcreg", {"0x0", "0"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("adcreg", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_event", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("temp_event", {"0"}, -1, PUT)); } } -TEST_CASE("bustest", "[.cmd]") { +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("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.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("bustest", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("bustest", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("auto_comp_disable", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("auto_comp_disable", {"0"}, -1, PUT)); } } -TEST_CASE("firmwaretest", "[.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("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.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("firmwaretest", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("firmwaretest", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("storagecells", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("storagecells", {"0"}, -1, PUT)); } } -TEST_CASE("resetfpga", "[.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) { - 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.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("resetfpga", {}, -1, GET)); - REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("storagecell_start", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("storagecell_start", {"0"}, -1, PUT)); } } + +TEST_CASE("storagecell_delay", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + 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("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-moench.cpp b/slsDetectorSoftware/tests/test-CmdProxy-moench.cpp index 8506be141..730e3b6b9 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-moench.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-moench.cpp @@ -106,3 +106,121 @@ TEST_CASE("Setting and reading back MOENCH dacs", "[.cmd][.dacs][.new]") { REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -1, GET)); } } + +/* Moench */ + +TEST_CASE("emin", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MOENCH) { + { + std::ostringstream oss; + proxy.Call("emin", {"100"}, -1, PUT, oss); + REQUIRE(oss.str() == "emin 100\n"); + } + { + std::ostringstream oss; + proxy.Call("emin", {"200"}, -1, PUT, oss); + REQUIRE(oss.str() == "emin 200\n"); + } + { + std::ostringstream oss; + proxy.Call("emin", {}, -1, GET, oss); + REQUIRE(oss.str() == "emin 200\n"); + } + } else { + REQUIRE_THROWS(proxy.Call("emin", {}, -1, GET)); + } +} + +TEST_CASE("emax", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MOENCH) { + { + std::ostringstream oss; + proxy.Call("emax", {"100"}, -1, PUT, oss); + REQUIRE(oss.str() == "emax 100\n"); + } + { + std::ostringstream oss; + proxy.Call("emax", {"200"}, -1, PUT, oss); + REQUIRE(oss.str() == "emax 200\n"); + } + { + std::ostringstream oss; + proxy.Call("emax", {}, -1, GET, oss); + REQUIRE(oss.str() == "emax 200\n"); + } + } else { + REQUIRE_THROWS(proxy.Call("emax", {}, -1, GET)); + } +} + +TEST_CASE("framemode", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MOENCH) { + { + std::ostringstream oss; + proxy.Call("framemode", {"pedestal"}, -1, PUT, oss); + REQUIRE(oss.str() == "framemode pedestal\n"); + } + { + std::ostringstream oss; + proxy.Call("framemode", {"newpedestal"}, -1, PUT, oss); + REQUIRE(oss.str() == "framemode newpedestal\n"); + } + { + std::ostringstream oss; + proxy.Call("framemode", {"flatfield"}, -1, PUT, oss); + REQUIRE(oss.str() == "framemode flatfield\n"); + } + { + std::ostringstream oss; + proxy.Call("framemode", {"newflatfield"}, -1, PUT, oss); + REQUIRE(oss.str() == "framemode newflatfield\n"); + } + { + std::ostringstream oss; + proxy.Call("framemode", {}, -1, GET, oss); + REQUIRE(oss.str() == "framemode newflatfield\n"); + } + REQUIRE_THROWS(proxy.Call("framemode", {"counting"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("framemode", {}, -1, GET)); + } +} + +TEST_CASE("detectormode", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MOENCH) { + { + std::ostringstream oss; + proxy.Call("detectormode", {"counting"}, -1, PUT, oss); + REQUIRE(oss.str() == "detectormode counting\n"); + } + { + std::ostringstream oss; + proxy.Call("detectormode", {"interpolating"}, -1, PUT, oss); + REQUIRE(oss.str() == "detectormode interpolating\n"); + } + { + std::ostringstream oss; + proxy.Call("detectormode", {"analog"}, -1, PUT, oss); + REQUIRE(oss.str() == "detectormode analog\n"); + } + std::ostringstream oss; + proxy.Call("detectormode", {}, -1, GET, oss); + REQUIRE(oss.str() == "detectormode analog\n"); + + REQUIRE_THROWS(proxy.Call("detectormode", {"pedestal"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("detectormode", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp b/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp index fff13a553..798683c7a 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-mythen3.cpp @@ -89,7 +89,9 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs][.new]") { } } -TEST_CASE("counters", "[.cmd]") { +/* Mythen3 Specific */ + +TEST_CASE("counters", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); @@ -120,3 +122,243 @@ TEST_CASE("counters", "[.cmd]") { REQUIRE_THROWS(proxy.Call("counters", {}, -1, GET)); } } + +TEST_CASE("gates", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getNumberOfGates(); + { + std::ostringstream oss; + proxy.Call("gates", {"1000"}, -1, PUT, oss); + REQUIRE(oss.str() == "gates 1000\n"); + } + { + std::ostringstream oss; + proxy.Call("gates", {}, -1, GET, oss); + REQUIRE(oss.str() == "gates 1000\n"); + } + { + std::ostringstream oss; + proxy.Call("gates", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "gates 1\n"); + } + REQUIRE_THROWS(proxy.Call("gates", {"0"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { + det.setNumberOfGates(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gates", {}, -1, GET)); + } +} + +TEST_CASE("exptime1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptime(0); + { + std::ostringstream oss; + proxy.Call("exptime1", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime1", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime1", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime1 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setExptime(0, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("exptime1", {}, -1, GET)); + } +} + +TEST_CASE("exptime2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptime(1); + { + std::ostringstream oss; + proxy.Call("exptime2", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime2", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime2", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime2 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setExptime(1, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("exptime2", {}, -1, GET)); + } +} + +TEST_CASE("exptime3", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptime(2); + { + std::ostringstream oss; + proxy.Call("exptime3", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime3", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("exptime3", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime3 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setExptime(2, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("exptime3", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getExptimeForAllGates().tsquash( + "inconsistent gatedelay to test"); + if (prev_val[0] != prev_val[1] || prev_val[1] != prev_val[2]) { + throw sls::RuntimeError("inconsistent gatedelay for all gates"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay", {"0.05"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay 0.05\n"); + } + if (det_type != defs::MYTHEN3) { + std::ostringstream oss; + proxy.Call("gatedelay", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay 50ms\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay", {"1s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay 1s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay 0\n"); + } + det.setGateDelay(-1, prev_val[0]); + } else { + REQUIRE_THROWS(proxy.Call("gatedelay", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay1", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getGateDelay(0); + { + std::ostringstream oss; + proxy.Call("gatedelay1", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay1", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay1 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay1", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay1 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setGateDelay(0, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gatedelay1", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getGateDelay(1); + { + std::ostringstream oss; + proxy.Call("gatedelay2", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay2", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay2 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay2", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay2 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setGateDelay(1, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gatedelay2", {}, -1, GET)); + } +} + +TEST_CASE("gatedelay3", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + auto prev_val = det.getGateDelay(2); + { + std::ostringstream oss; + proxy.Call("gatedelay3", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay3", {}, -1, GET, oss); + REQUIRE(oss.str() == "gatedelay3 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("gatedelay3", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gatedelay3 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setGateDelay(2, prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("gatedelay3", {}, -1, GET)); + } +} \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp b/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp new file mode 100644 index 000000000..1fdeef125 --- /dev/null +++ b/slsDetectorSoftware/tests/test-CmdProxy-pattern.cpp @@ -0,0 +1,544 @@ +#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); + REQUIRE_THROWS(proxy.Call("patternstart", {}, -1, GET)); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::MYTHEN3) { + REQUIRE_NOTHROW(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-rx.cpp b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp index 2d4f13aa6..95c2ab9f8 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp @@ -374,7 +374,7 @@ TEST_CASE("rx_lastclient", "[.cmd][.rx][.new]") { /* File */ -TEST_CASE("fformat", "[.cmd]") { +TEST_CASE("fformat", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto prev_val = det.getFileFormat(); @@ -393,7 +393,7 @@ TEST_CASE("fformat", "[.cmd]") { } } -TEST_CASE("fpath", "[.cmd]") { +TEST_CASE("fpath", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto prev_val = det.getFilePath(); @@ -412,7 +412,7 @@ TEST_CASE("fpath", "[.cmd]") { } } -TEST_CASE("fname", "[.cmd]") { +TEST_CASE("fname", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto prev_val = det.getFileNamePrefix(); @@ -436,7 +436,7 @@ TEST_CASE("fname", "[.cmd]") { } } -TEST_CASE("findex", "[.cmd]") { +TEST_CASE("findex", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto prev_val = det.getAcquisitionIndex(); @@ -460,7 +460,7 @@ TEST_CASE("findex", "[.cmd]") { } } -TEST_CASE("fwrite", "[.cmd]") { +TEST_CASE("fwrite", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto prev_val = det.getFileWrite(); @@ -484,7 +484,7 @@ TEST_CASE("fwrite", "[.cmd]") { } } -TEST_CASE("fmaster", "[.cmd]") { +TEST_CASE("fmaster", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto prev_val = det.getMasterFileWrite(); @@ -508,7 +508,7 @@ TEST_CASE("fmaster", "[.cmd]") { } } -TEST_CASE("foverwrite", "[.cmd]") { +TEST_CASE("foverwrite", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto prev_val = det.getFileOverWrite(); diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 495f917b7..72d61cfc3 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -2,6 +2,7 @@ #include "Detector.h" #include "catch.hpp" #include "sls_detector_defs.h" + #include #include #include @@ -116,7 +117,7 @@ TEST_CASE("type", "[.cmd][.new]") { proxy.Call("type", {}, -1, GET, oss); auto ans = oss.str().erase(0, strlen("type ")); REQUIRE(ans == sls::ToString(dt) + '\n'); - REQUIRE(dt == test::type); + // REQUIRE(dt == test::type); } TEST_CASE("detsize", "[.cmd][.new]") { @@ -131,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"); @@ -165,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; } @@ -193,7 +197,7 @@ TEST_CASE("settings", "[.cmd][.new]") { TEST_CASE("trimbits", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); - REQUIRE_NOTHROW(proxy.Call("trimbits", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("trimbits", {}, -1, GET)); } TEST_CASE("trimval", "[.cmd][.new]") { @@ -219,7 +223,7 @@ TEST_CASE("trimval", "[.cmd][.new]") { REQUIRE(oss.str() == "trimval 0\n"); } REQUIRE_THROWS(proxy.Call("trimval", {"64"}, -1, PUT)); - REQUIRE_THROWS(proxy.Call("trimval", {"-1"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("trimval", {"-2"}, -1, PUT)); for (int i = 0; i != det.size(); ++i) { if (prev_val[i] != -1) { det.setAllTrimbits(prev_val[i], {i}); @@ -285,13 +289,24 @@ TEST_CASE("triggers", "[.cmd][.new]") { TEST_CASE("exptime", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); - auto prev_val = det.getExptime(); + auto det_type = det.getDetectorType().squash(); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw sls::RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; + } { std::ostringstream oss; proxy.Call("exptime", {"0.05"}, -1, PUT, oss); REQUIRE(oss.str() == "exptime 0.05\n"); } - { + if (det_type != defs::MYTHEN3) { std::ostringstream oss; proxy.Call("exptime", {}, -1, GET, oss); REQUIRE(oss.str() == "exptime 50ms\n"); @@ -306,9 +321,7 @@ TEST_CASE("exptime", "[.cmd][.new]") { proxy.Call("exptime", {"0"}, -1, PUT, oss); REQUIRE(oss.str() == "exptime 0\n"); } - for (int i = 0; i != det.size(); ++i) { - det.setExptime(prev_val[i], {i}); - } + det.setExptime(-1, prev_val); } TEST_CASE("period", "[.cmd][.new]") { @@ -394,10 +407,17 @@ TEST_CASE("delayl", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { + switch (det_type) { + case defs::EIGER: + case defs::CHIPTESTBOARD: + case defs::MOENCH: + case defs::GOTTHARD2: + case defs::MYTHEN3: REQUIRE_THROWS(proxy.Call("delayl", {}, -1, GET)); - } else { + break; + default: REQUIRE_NOTHROW(proxy.Call("delayl", {}, -1, GET)); + break; } } @@ -405,10 +425,17 @@ TEST_CASE("periodl", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { + switch (det_type) { + case defs::EIGER: + case defs::CHIPTESTBOARD: + case defs::MOENCH: + case defs::GOTTHARD2: + case defs::MYTHEN3: REQUIRE_THROWS(proxy.Call("periodl", {}, -1, GET)); - } else { + break; + default: REQUIRE_NOTHROW(proxy.Call("periodl", {}, -1, GET)); + break; } } @@ -654,6 +681,8 @@ TEST_CASE("clkphase", "[.cmd][.new]") { std::string s_deg_val = "15"; if (det_type == defs::MYTHEN3) { s_deg_val = "14"; + } else if (det_type == defs::GOTTHARD2) { + s_deg_val = "23"; } { std::ostringstream oss1, oss2; @@ -809,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(); @@ -845,6 +872,7 @@ TEST_CASE("imagetest", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); auto det_type = det.getDetectorType().squash(); + // cannot test only for virtual eiger/jungfrau if (det_type == defs::GOTTHARD) { auto prev_val = det.getImageTestMode(); { @@ -886,7 +914,7 @@ TEST_CASE("extsig", "[.cmd][.new]") { oss1); REQUIRE(oss1.str() == "extsig 0 trigger_in_rising_edge\n"); proxy.Call("extsig", {"0"}, -1, GET, oss2); - REQUIRE(oss2.str() == "extsig trigger_in_rising_edge\n"); + REQUIRE(oss2.str() == "extsig 0 trigger_in_rising_edge\n"); } { std::ostringstream oss1, oss2; @@ -916,7 +944,7 @@ TEST_CASE("extsig", "[.cmd][.new]") { oss1); REQUIRE(oss1.str() == "extsig 0 trigger_in_rising_edge\n"); proxy.Call("extsig", {"0"}, -1, GET, oss2); - REQUIRE(oss2.str() == "extsig trigger_in_rising_edge\n"); + REQUIRE(oss2.str() == "extsig 0 trigger_in_rising_edge\n"); } { std::ostringstream oss1, oss2; @@ -931,7 +959,7 @@ TEST_CASE("extsig", "[.cmd][.new]") { proxy.Call("extsig", {"1", "inversion_off"}, -1, PUT, oss1); REQUIRE(oss1.str() == "extsig 1 inversion_off\n"); proxy.Call("extsig", {"1"}, -1, GET, oss2); - REQUIRE(oss2.str() == "extsig inversion_off\n"); + REQUIRE(oss2.str() == "extsig 1 inversion_off\n"); } { std::ostringstream oss1, oss2; @@ -982,6 +1010,22 @@ TEST_CASE("temp_fpga", "[.cmd][.new]") { } } +/* dacs */ + +TEST_CASE("daclist", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("daclist", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("daclist", {}, -1, PUT)); +} + +TEST_CASE("dacvalues", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("dacvalues", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("dacvalues", {}, -1, PUT)); +} + /* acquisition */ TEST_CASE("clearbusy", "[.cmd][.new]") { @@ -997,8 +1041,19 @@ TEST_CASE("start", "[.cmd][.new]") { CmdProxy proxy(&det); // PUT only command REQUIRE_THROWS(proxy.Call("start", {}, -1, GET)); - auto prev_val = det.getExptime(); - det.setExptime(std::chrono::seconds(2)); + auto det_type = det.getDetectorType().squash(); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw sls::RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; + } + det.setExptime(-1, std::chrono::seconds(2)); { std::ostringstream oss; proxy.Call("start", {}, -1, PUT, oss); @@ -1010,9 +1065,7 @@ TEST_CASE("start", "[.cmd][.new]") { REQUIRE(oss.str() == "status running\n"); } det.stopDetector(); - for (int i = 0; i != det.size(); ++i) { - det.setExptime(prev_val[i], {i}); - } + det.setExptime(-1, prev_val); } TEST_CASE("stop", "[.cmd][.new]") { @@ -1020,8 +1073,19 @@ TEST_CASE("stop", "[.cmd][.new]") { CmdProxy proxy(&det); // PUT only command REQUIRE_THROWS(proxy.Call("stop", {}, -1, GET)); - auto prev_val = det.getExptime(); - det.setExptime(std::chrono::seconds(2)); + auto det_type = det.getDetectorType().squash(); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw sls::RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; + } + det.setExptime(-1, std::chrono::seconds(2)); det.startDetector(); { std::ostringstream oss; @@ -1038,16 +1102,25 @@ TEST_CASE("stop", "[.cmd][.new]") { proxy.Call("status", {}, -1, GET, oss); REQUIRE(oss.str() == "status idle\n"); } - for (int i = 0; i != det.size(); ++i) { - det.setExptime(prev_val[i], {i}); - } + det.setExptime(-1, prev_val); } TEST_CASE("status", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); - auto prev_val = det.getExptime(); - det.setExptime(std::chrono::seconds(2)); + auto det_type = det.getDetectorType().squash(); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); + } else { + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw sls::RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; + } + det.setExptime(-1, std::chrono::seconds(2)); det.startDetector(); { std::ostringstream oss; @@ -1060,9 +1133,7 @@ TEST_CASE("status", "[.cmd][.new]") { proxy.Call("status", {}, -1, GET, oss); REQUIRE(oss.str() == "status idle\n"); } - for (int i = 0; i != det.size(); ++i) { - det.setExptime(prev_val[i], {i}); - } + det.setExptime(-1, prev_val); } TEST_CASE("startingfnum", "[.cmd][.new]") { @@ -1095,6 +1166,44 @@ 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 { + { + std::ostringstream oss; + proxy.Call("gappixels", {}, -1, GET, oss); + REQUIRE(oss.str() == "gappixels 0\n"); + } + { + std::ostringstream oss; + proxy.Call("gappixels", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "gappixels 0\n"); + } + REQUIRE_THROWS(proxy.Call("gappixels", {"1"}, -1, PUT)); + } +} + /* Network Configuration (Detector<->Receiver) */ TEST_CASE("numinterfaces", "[.cmd][.new]") { @@ -1130,1509 +1239,227 @@ TEST_CASE("numinterfaces", "[.cmd][.new]") { REQUIRE_THROWS(proxy.Call("numinterfaces", {"0"}, -1, PUT)); } -/* Advanced */ - -TEST_CASE("initialchecks", "[.cmd]") { +TEST_CASE("udp_srcip", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); - auto check = det.getInitialChecks(); - auto dtstr = sls::ToString(check); - auto hostname = det.getHostname(); - std::string hostnamestr; - for (auto &it : hostname) { - hostnamestr += (it + "+"); - } + auto prev_val = det.getSourceUDPIP(); + REQUIRE_THROWS(proxy.Call("udp_srcip", {"0.0.0.0"}, -1, PUT)); { std::ostringstream oss; - proxy.Call("initialchecks", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "initialchecks 0\n"); + proxy.Call("udp_srcip", {"129.129.205.12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcip 129.129.205.12\n"); } - { - std::ostringstream oss; - proxy.Call("initialchecks", {}, -1, GET, oss); - REQUIRE(oss.str() == "initialchecks 0\n"); - } - { - det.setHostname(hostname); - std::ostringstream oss; - proxy.Call("initialchecks", {}, -1, GET, oss); - REQUIRE(oss.str() == "initialchecks 0\n"); - } - det.setInitialChecks(check); -} - -/* Insignificant */ - -TEST_CASE("port", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - { - std::ostringstream oss; - proxy.Call("port", {"1942"}, -1, PUT, oss); - REQUIRE(oss.str() == "port 1942\n"); - } - { - std::ostringstream oss; - proxy.Call("port", {}, -1, GET, oss); - REQUIRE(oss.str() == "port 1942\n"); - } - proxy.Call("port", {"1952"}, -1, PUT); -} - -TEST_CASE("stopport", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - { - std::ostringstream oss; - proxy.Call("stopport", {"1942"}, -1, PUT, oss); - REQUIRE(oss.str() == "stopport 1942\n"); - } - { - std::ostringstream oss; - proxy.Call("stopport", {}, -1, GET, oss); - REQUIRE(oss.str() == "stopport 1942\n"); - } - proxy.Call("stopport", {"1953"}, -1, PUT); - auto port = det.getStopPort().squash(); - REQUIRE(port == 1953); -} - -// TEST_CASE("execcommand", "[.cmd]") { -// REQUIRE_NOTHROW(multiSlsDetectorClient("execcommand ls", PUT)); -// } - -TEST_CASE("user", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - proxy.Call("user", {}, -1, GET); - - // This is a get only command - REQUIRE_THROWS(proxy.Call("user", {}, -1, PUT)); -} - -// TEST_CASE("reg", "[.cmd]") { -// if (test::type == defs::JUNGFRAU) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x01", GET, nullptr, -// oss)); REQUIRE(oss.str() == "reg 0xacdc2014\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x64 5", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "reg [0x64, 5]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, -// oss)); REQUIRE(oss.str() == "frames 5\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("getbit 0x64 0", GET, -// nullptr, oss)); REQUIRE(oss.str() == "getbit 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("setbit 0x64 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "setbit [0x64, 1]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clearbit 0x64 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "clearbit [0x64, 0]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, -// oss)); REQUIRE(oss.str() == "frames 6\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// } else if (test::type == defs::GOTTHARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x023", GET, nullptr, -// oss)); REQUIRE(oss.str() == "reg 0xacdc1980\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x70 5", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "reg [0x70, 5]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, -// oss)); REQUIRE(oss.str() == "frames 5\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("getbit 0x70 0", GET, -// nullptr, oss)); REQUIRE(oss.str() == "getbit 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("setbit 0x70 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "setbit [0x70, 1]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clearbit 0x70 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "clearbit [0x70, 0]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, -// oss)); REQUIRE(oss.str() == "frames 6\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// } else if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x01", GET, nullptr, -// oss)); REQUIRE(oss.str() == "reg 0xacdc2016\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("reg 0x64 5", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "reg [0x64, 5]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, -// oss)); REQUIRE(oss.str() == "frames 5\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("getbit 0x64 0", GET, -// nullptr, oss)); REQUIRE(oss.str() == "getbit 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("setbit 0x64 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "setbit [0x64, 1]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clearbit 0x64 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "clearbit [0x64, 0]\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames", GET, nullptr, -// oss)); REQUIRE(oss.str() == "frames 6\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("frames 1", PUT)); -// } -// } - -// TEST_CASE("update", "[.cmd][.ctb][.jungfrau]") { -// if (test::type == defs::JUNGFRAU || test::type == -// defs::CHIPTESTBOARD) { -// REQUIRE_THROWS(multiSlsDetectorClient("update", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("update -// jungfrauDetectorServer_developer", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("update -// jungfrauDetectorServer_developer pc13784", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("update -// jungfrauDetectorServer_developer pc13784 dfd.pff", PUT)); -// //REQUIRE_NOTHROW(multiSlsDetectorClient("update -// jungfrauDetectorServer_developer pc13784 -// /afs/psi.ch/project/sls_det_firmware/jungfrau_firmware/cyclone_V/v0_8/Jungfrau_MCB.pof", -// PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("update", GET)); -// } -// } - -// TEST_CASE("copydetectorserver", "[.cmd][.ctb][.jungfrau]") { -// if (test::type == defs::JUNGFRAU || test::type == -// defs::CHIPTESTBOARD) { -// REQUIRE_THROWS(multiSlsDetectorClient("copydetectorserver", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("copydetectorserver -// jungfrauDetectorServer_developer", PUT)); -// //REQUIRE_NOTHROW(multiSlsDetectorClient("copydetectorserver -// jungfrauDetectorServer_developer pc13784", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("copydetectorserver", GET)); -// } -// } - -// TEST_CASE("rebootcontroller", "[.cmd][.ctb][.jungfrau]") { -// if (test::type == defs::JUNGFRAU || test::type == -// defs::CHIPTESTBOARD) { -// ;//REQUIRE_NOTHROW(multiSlsDetectorClient("rebootcontroller", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("rebootcontroller", GET)); -// } -// } - -// TEST_CASE("programfpga", "[.cmd][.ctb][.jungfrau]") { -// if (test::type == defs::JUNGFRAU || test::type == -// defs::CHIPTESTBOARD) { -// REQUIRE_THROWS(multiSlsDetectorClient("programfpga fdgd.oki", PUT)); -// //REQUIRE_NOTHROW(multiSlsDetectorClient("programfpga -// /afs/psi.ch/project/sls_det_firmware/jungfrau_firmware/cyclone_V/v0_8/Jungfrau_MCB.pof", -// PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("programfpga", GET)); -// } -// } - -// TEST_CASE("detectormode", "[.cmd][.moench]") { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode counting", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "detectormode counting\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode interpolating", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "detectormode -// interpolating\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode analog", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "detectormode analog\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("detectormode counting", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("detectormode pedestal", PUT)); -// } - -// TEST_CASE("framemode", "[.cmd][.moench]") { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("framemode pedestal", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "framemode pedestal\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("framemode newpedestal", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "framemode newpedestal\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("framemode flatfield", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "framemode flatfield\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("framemode newflatfield", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "framemode newflatfield\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("framemode pedestal", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("framemode counting", PUT)); -// } - -// TEST_CASE("emin", "[.cmd][.moench]") { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("emin 100", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "emin 100\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("emax 200", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "emax 200\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonpara emax", GET, -// nullptr, oss)); REQUIRE(oss.str() == "rx_jsonpara 200\n"); -// } -// 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("diodelay", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("diodelay 0x01010 125", PUT)); -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("diodelay 0x01010 775", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "diodelay [0x01010, -// 775]\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("diodelay 0x01010 0", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("diodelay [0x01010, 776]", -// PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("diodelay", GET)); -// } -// } - -// TEST_CASE("extsampling", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsampling 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "extsampling 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsampling", GET, -// nullptr, oss)); REQUIRE(oss.str() == "extsampling 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsampling 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "extsampling 0\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("extsampling", GET)); -// } -// } - -// TEST_CASE("extsamplingsrc", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsamplingsrc 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "extsamplingsrc 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsamplingsrc 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "extsamplingsrc 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsamplingsrc 15", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "extsamplingsrc 15\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("extsamplingsrc", GET, -// nullptr, oss)); REQUIRE(oss.str() == "extsamplingsrc 15\n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("extsamplingsrc 64", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("extsamplingsrc", GET)); -// } -// } - -// TEST_CASE("adcinvert", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD || test::type == -// defs::JUNGFRAU) { -// std::string s; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcinvert", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcinvert 0x8d0a21d4", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "adcinvert -// 0x8d0a21d4\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT, nullptr, oss)); -// REQUIRE(oss.str() == s); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("adcinvert", GET)); -// } -// } - -// TEST_CASE("adcenable", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// std::string s; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcenable", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcenable 0x8d0a21d4", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "adcenable -// 0x8d0a21d4\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT, nullptr, oss)); -// REQUIRE(oss.str() == s); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("adcenable", GET)); -// } -// } - -// 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; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcvpp", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("adcvpp ")); -// prev_val = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcvpp 1", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcvpp", GET, nullptr, -// oss)); REQUIRE(oss.str() == "adcvpp 1\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcvpp 1140 mv", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcvpp mv", GET, nullptr, -// oss)); REQUIRE(oss.str() == "adcvpp 1140 mv\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcvpp " + -// std::to_string(prev_val), PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("adcvpp", GET)); -// } -// } - -// TEST_CASE("dbitpipeline", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitpipeline 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "dbitpipeline 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitpipeline 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "dbitpipeline 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitpipeline 15", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "dbitpipeline 15\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitpipeline", GET, -// nullptr, oss)); REQUIRE(oss.str() == "dbitpipeline 15\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitpipeline 0", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("dbitpipeline", GET)); -// } -// } - -// TEST_CASE("adcpipeline", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcpipeline 1", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "adcpipeline 1\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcpipeline 0", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "adcpipeline 0\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcpipeline 15", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "adcpipeline 15\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcpipeline", GET, -// nullptr, oss)); REQUIRE(oss.str() == "adcpipeline 15\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcpipeline 0", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("adcpipeline", GET)); -// } -// } - -// TEST_CASE("romode", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("romode digital", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "romode digital\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("romode analog_digital", -// PUT, nullptr, oss)); REQUIRE(oss.str() == "romode -// analog_digital\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("romode analog", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "romode analog\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("romode", GET, nullptr, -// oss)); REQUIRE(oss.str() == "romode analog\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("romode", GET)); -// } -// } - -// TEST_CASE("samples", "[.cmd][.ctb]") { -// if (test::type == defs::CHIPTESTBOARD) { -// uint64_t prev_value1 = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("asamples", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("asamples -// ")); prev_value1 = std::stoi(s); -// } -// std::cout<<"asamples:"<= 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) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("roi 0 255", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "roi [0, 255] \n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("roi 256 511", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "roi [256, 511] \n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("clearroi", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "clearroi [-1, -1] \n"); -// } -// REQUIRE_THROWS(multiSlsDetectorClient("roi 0 256", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("roi", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("clearroi", PUT)); -// } -// } - -// TEST_CASE("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("zmqip", "[.cmd]") { - Detector det; - CmdProxy proxy(&det); - std::ostringstream oss1, oss2; - auto zmqip = det.getClientZmqIp(); - proxy.Call("zmqip", {}, 0, GET, oss1); - REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n'); - - proxy.Call("zmqip", {zmqip[0].str()}, 0, PUT, oss2); - REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n'); - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqIP(zmqip[i], {i}); + det.setSourceUDPIP(prev_val[i], {i}); } } -TEST_CASE("zmqport", "[.cmd]") { +TEST_CASE("udp_dstip", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_THROWS(proxy.Call("udp_dstip", {"0.0.0.0"}, -1, PUT)); +} + +TEST_CASE("udp_srcmac", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto prev_val = det.getSourceUDPMAC(); + REQUIRE_THROWS(proxy.Call("udp_srcmac", {"00:00:00:00:00:00"}, -1, PUT)); + { + std::ostringstream oss; + proxy.Call("udp_srcmac", {"00:50:c2:42:34:12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcmac 00:50:c2:42:34:12\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setSourceUDPMAC(prev_val[i], {i}); + } +} + +TEST_CASE("udp_dstmac", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_THROWS(proxy.Call("udp_dstmac", {"00:00:00:00:00:00"}, -1, PUT)); +} + +TEST_CASE("udp_dstport", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto prev_val = det.getDestinationUDPPort(); + { + std::ostringstream oss; + proxy.Call("udp_dstport", {"50084"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_dstport 50084\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setDestinationUDPPort(prev_val[i], {i}); + } +} + +TEST_CASE("udp_srcip2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2) { + auto prev_val = det.getSourceUDPIP2(); + REQUIRE_THROWS(proxy.Call("udp_srcip2", {"0.0.0.0"}, -1, PUT)); + { + std::ostringstream oss; + proxy.Call("udp_srcip2", {"129.129.205.12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcip2 129.129.205.12\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setSourceUDPIP2(prev_val[i], {i}); + } + } +} + +TEST_CASE("udp_dstip2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2) { + REQUIRE_THROWS(proxy.Call("udp_dstip2", {"0.0.0.0"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("udp_dstip2", {}, -1, GET)); + } +} + +TEST_CASE("udp_srcmac2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2) { + auto prev_val = det.getSourceUDPMAC2(); + REQUIRE_THROWS( + proxy.Call("udp_srcmac2", {"00:00:00:00:00:00"}, -1, PUT)); + { + std::ostringstream oss; + proxy.Call("udp_srcmac2", {"00:50:c2:42:34:12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcmac2 00:50:c2:42:34:12\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setSourceUDPMAC2(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("udp_srcmac2", {}, -1, GET)); + } +} + +TEST_CASE("udp_dstmac2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2) { + REQUIRE_THROWS( + proxy.Call("udp_dstmac2", {"00:00:00:00:00:00"}, -1, PUT)); + } else { + REQUIRE_THROWS(proxy.Call("udp_dstmac2", {}, -1, GET)); + } +} + +TEST_CASE("udp_dstport2", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD2 || + det_type == defs::EIGER) { + auto prev_val = det.getDestinationUDPPort2(); + { + std::ostringstream oss; + proxy.Call("udp_dstport2", {"50084"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_dstport2 50084\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setDestinationUDPPort2(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("udp_dstport2", {}, -1, GET)); + } +} + +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 || + det_type == defs::MOENCH) { + 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); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) { + auto prev_val = det.getTenGigaFlowControl(); + { + std::ostringstream oss; + proxy.Call("flowcontrol10g", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "flowcontrol10g 1\n"); + } + { + std::ostringstream oss; + proxy.Call("flowcontrol10g", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "flowcontrol10g 0\n"); + } + { + std::ostringstream oss; + proxy.Call("flowcontrol10g", {}, -1, GET, oss); + REQUIRE(oss.str() == "flowcontrol10g 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setTenGigaFlowControl(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("flowcontrol10g", {}, -1, GET)); + } +} + +TEST_CASE("txndelay_frame", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) { + auto prev_val = det.getTransmissionDelayFrame(); + auto val = 5000; + if (det_type == defs::JUNGFRAU) { + val = 5; + } + std::string sval = std::to_string(val); + { + std::ostringstream oss1, oss2; + proxy.Call("txndelay_frame", {sval}, -1, PUT, oss1); + REQUIRE(oss1.str() == "txndelay_frame " + sval + "\n"); + proxy.Call("txndelay_frame", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "txndelay_frame " + sval + "\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setTransmissionDelayFrame(prev_val[i]); + } + } else { + REQUIRE_THROWS(proxy.Call("txndelay_frame", {}, -1, GET)); + } +} + +/* ZMQ Streaming Parameters (Receiver<->Client) */ + +TEST_CASE("zmqport", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); @@ -2680,396 +1507,342 @@ TEST_CASE("zmqport", "[.cmd]") { } } -// 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)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("adc", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("adc 5", PUT)); -// for(int i = 0; i <= 8; ++i) { -// REQUIRE_NOTHROW(multiSlsDetectorClient("adc " + -// std::to_string(i), GET)); -// } -// } -// } - -// TEST_CASE("syncclk", "[.cmd][.ctb]") { -// if(test::type != defs::CHIPTESTBOARD) { -// REQUIRE_THROWS(multiSlsDetectorClient("syncclk", GET)); -// } else { -// REQUIRE_NOTHROW(multiSlsDetectorClient("syncclk", GET)); -// REQUIRE_THROWS(multiSlsDetectorClient("syncclk 40", PUT)); -// } -// } - -// TEST_CASE("adcclk", "[.cmd][.ctb]") { -// if(test::type != defs::CHIPTESTBOARD) { -// REQUIRE_THROWS(multiSlsDetectorClient("adcclk", GET)); -// } else { -// int prev_clk = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcclk", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("adcclk ")); -// prev_clk = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcclk 20", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcclk", GET, nullptr, -// oss)); REQUIRE(oss.str() == "adcclk 20\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcclk 10", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcclk", GET, nullptr, -// oss)); REQUIRE(oss.str() == "adcclk 10\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("adcclk " + -// std::to_string(prev_clk), PUT)); -// } -// } - -// TEST_CASE("dbitclk", "[.cmd][.ctb]") { -// if(test::type != defs::CHIPTESTBOARD) { -// REQUIRE_THROWS(multiSlsDetectorClient("dbitclk", GET)); -// } else { -// int prev_clk = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitclk", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("dbitclk ")); -// prev_clk = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitclk 20", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitclk", GET, nullptr, -// oss)); REQUIRE(oss.str() == "dbitclk 20\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitclk 10", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitclk", GET, nullptr, -// oss)); REQUIRE(oss.str() == "dbitclk 10\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("dbitclk " + -// std::to_string(prev_clk), PUT)); -// } -// } - -// TEST_CASE("runclk", "[.cmd][.ctb]") { -// if(test::type != defs::CHIPTESTBOARD) { -// REQUIRE_THROWS(multiSlsDetectorClient("runclk", GET)); -// } else { -// int prev_runclk = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("runclk", GET, nullptr, -// oss)); std::string s = (oss.str()).erase (0, strlen("runclk ")); -// prev_runclk = std::stoi(s); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("runclk 20", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("runclk", GET, nullptr, -// oss)); REQUIRE(oss.str() == "runclk 20\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("runclk 10", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("runclk", GET, nullptr, -// oss)); REQUIRE(oss.str() == "runclk 10\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("runclk " + -// 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]") { +TEST_CASE("zmqip", "[.cmd][.new]") { Detector det; CmdProxy proxy(&det); + std::ostringstream oss1, oss2; + auto zmqip = det.getClientZmqIp(); + proxy.Call("zmqip", {}, 0, GET, oss1); + REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n'); + + proxy.Call("zmqip", {zmqip[0].str()}, 0, PUT, oss2); + REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n'); + + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqIP(zmqip[i], {i}); + } +} + +/* Advanced */ + +TEST_CASE("programfpga", "[.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::JUNGFRAU || det_type == defs::MYTHEN3 || + det_type == defs::GOTTHARD2) { + // TODO program a real board? + /// afs/psi.ch/project/sls_det_firmware/jungfrau_firmware/cyclone_V/v0_8/Jungfrau_MCB.pof + REQUIRE_THROWS(proxy.Call("programfpga", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("programfpga", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("programfpga", {"/tmp/test.pof"}, -1, PUT)); + } +} + +TEST_CASE("resetfpga", "[.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::MOENCH) { + 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("copydetectorserver", "[.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::MOENCH || det_type == defs::MYTHEN3 || + det_type == defs::GOTTHARD2) { + // TODO: send real server? + // std::ostringstream oss; + // proxy.Call("copydetectorserver",{"jungfrauDetectorServerv4.0.1.0", + // "pc13784"}, -1, PUT, oss); + // REQUIRE(oss.str() == "copydetectorserver successful\n"); + REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("copydetectorserver", {}, -1, PUT)); + } +} + +TEST_CASE("rebootcontroller", "[.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::MOENCH || det_type == defs::MYTHEN3 || + det_type == defs::GOTTHARD2 || det_type == defs::GOTTHARD) { + // TODO: reboot real server? + // REQUIRE_NOTHROW(proxy.Call("rebootcontroller", {}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("rebootcontroller", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("rebootcontroller", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("rebootcontroller", {}, -1, PUT)); + } +} + +TEST_CASE("update", "[.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::MOENCH) { + // TODO: update real server and firmware? + // REQUIRE_NOTHROW(proxy.Call("update", + // {"jungfrauDetectorServerv4.0.1.0", "pc13784", + // "/afs/psi.ch/project/sls_det_firmware/jungfrau_firmware/cyclone_V/v0_8/Jungfrau_MCB.pof"}, + // -1, PUT)); + REQUIRE_THROWS(proxy.Call("update", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("update", {}, -1, GET)); + REQUIRE_THROWS(proxy.Call("update", {}, -1, PUT)); + } +} + +TEST_CASE("reg", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::EIGER) { + uint32_t addr = 0x64; + std::string saddr = sls::ToStringHex(addr); + auto prev_val = det.readRegister(addr); + { + std::ostringstream oss1, oss2; + proxy.Call("reg", {saddr, "0x5"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "reg [" + saddr + ", 0x5]\n"); + proxy.Call("reg", {saddr}, -1, GET, oss2); + REQUIRE(oss2.str() == "reg 0x5\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.writeRegister(addr, prev_val[i], {i}); + } + } + // cannot check for eiger virtual server + else { + REQUIRE_NOTHROW(proxy.Call("reg", {"0x64"}, -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::MOENCH || det_type == defs::GOTTHARD) { + std::ostringstream oss; + proxy.Call("adcreg", {"0x08", "0x3"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcreg [0x8, 0x3]\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("setbit", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::EIGER) { + uint32_t addr = 0x64; + std::string saddr = sls::ToStringHex(addr); + auto prev_val = det.readRegister(addr); + { + std::ostringstream oss1, oss2; + proxy.Call("reg", {saddr, "0x0"}, -1, PUT); + proxy.Call("setbit", {saddr, "1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "setbit [" + saddr + ", 1]\n"); + proxy.Call("reg", {saddr}, -1, GET, oss2); + REQUIRE(oss2.str() == "reg 0x2\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.writeRegister(addr, prev_val[i], {i}); + } + } +} + +TEST_CASE("clearbit", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::EIGER) { + uint32_t addr = 0x64; + std::string saddr = sls::ToStringHex(addr); + auto prev_val = det.readRegister(addr); + { + std::ostringstream oss1, oss2; + proxy.Call("reg", {saddr, "0x3"}, -1, PUT); + proxy.Call("clearbit", {saddr, "1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "clearbit [" + saddr + ", 1]\n"); + proxy.Call("reg", {saddr}, -1, GET, oss2); + REQUIRE(oss2.str() == "reg 0x1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.writeRegister(addr, prev_val[i], {i}); + } + } +} + +TEST_CASE("getbit", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::EIGER) { + uint32_t addr = 0x64; + std::string saddr = sls::ToStringHex(addr); + auto prev_val = det.readRegister(addr); + { + std::ostringstream oss1, oss2; + proxy.Call("reg", {saddr, "0x3"}, -1, PUT); + proxy.Call("getbit", {saddr, "1"}, -1, GET, oss1); + REQUIRE(oss1.str() == "getbit 1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.writeRegister(addr, prev_val[i], {i}); + } + } + // cannot check for eiger virtual server + else { + REQUIRE_NOTHROW(proxy.Call("getbit", {"0x64", "1"}, -1, GET)); + } +} + +TEST_CASE("firmwaretest", "[.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::MOENCH || det_type == defs::GOTTHARD || + det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + 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("bustest", "[.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::MOENCH || det_type == defs::GOTTHARD || + det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + 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("initialchecks", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto check = det.getInitialChecks(); + { + std::ostringstream oss; + proxy.Call("initialchecks", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "initialchecks 0\n"); + } + { + std::ostringstream oss; + proxy.Call("initialchecks", {}, -1, GET, oss); + REQUIRE(oss.str() == "initialchecks 0\n"); + } + { + std::ostringstream oss; + proxy.Call("initialchecks", {}, -1, GET, oss); + REQUIRE(oss.str() == "initialchecks 0\n"); + } + det.setInitialChecks(check); +} + +TEST_CASE("adcinvert", "[.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::JUNGFRAU) { + auto prev_val = det.getADCInvert(); + { + std::ostringstream oss; + proxy.Call("adcinvert", {"0x8d0a21d4"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcinvert 0x8d0a21d4\n"); + } + { + std::ostringstream oss; + proxy.Call("adcinvert", {}, -1, GET, oss); + REQUIRE(oss.str() == "adcinvert 0x8d0a21d4\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setADCInvert(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("adcinvert", {}, -1, GET)); + } +} + +/* Insignificant */ + +TEST_CASE("port", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto prev_val = det.getControlPort({0}).squash(); + { + std::ostringstream oss; + proxy.Call("port", {"1942"}, 0, PUT, oss); + REQUIRE(oss.str() == "port 1942\n"); + } + { + std::ostringstream oss; + proxy.Call("port", {}, 0, GET, oss); + REQUIRE(oss.str() == "port 1942\n"); + } + det.setControlPort(prev_val, {0}); +} + +TEST_CASE("stopport", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto prev_val = det.getStopPort({0}).squash(); + { + std::ostringstream oss; + proxy.Call("stopport", {"1942"}, 0, PUT, oss); + REQUIRE(oss.str() == "stopport 1942\n"); + } + { + std::ostringstream oss; + proxy.Call("stopport", {}, 0, GET, oss); + REQUIRE(oss.str() == "stopport 1942\n"); + } + det.setStopPort(prev_val, {0}); +} + +TEST_CASE("lock", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto prev_val = det.getDetectorLock(); { std::ostringstream oss; proxy.Call("lock", {"1"}, -1, PUT, oss); @@ -3085,8 +1858,76 @@ TEST_CASE("lock", "[.cmd]") { proxy.Call("lock", {"0"}, -1, PUT, oss); REQUIRE(oss.str() == "lock 0\n"); } + for (int i = 0; i != det.size(); ++i) { + det.setDetectorLock(prev_val[i], {i}); + } } -// TEST_CASE("lastclient", "[.cmd]") { -// REQUIRE_NOTHROW(multiSlsDetectorClient("lastclient", GET)); -// } +TEST_CASE("execcommand", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + REQUIRE_NOTHROW(proxy.Call("execcommand", {"ls"}, -1, PUT)); +} + +TEST_CASE("nframes", "[.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::MOENCH || det_type == defs::MYTHEN3 || + det_type == defs::GOTTHARD2) { + auto nframes = det.getNumberOfFramesFromStart().squash(); + std::ostringstream oss; + proxy.Call("nframes", {}, -1, GET, oss); + REQUIRE(oss.str() == "nframes " + std::to_string(nframes) + "\n"); + REQUIRE_NOTHROW(proxy.Call("nframes", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("nframes", {}, -1, GET)); + } +} + +TEST_CASE("now", "[.cmd][.new]") { + // 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 || + det_type == defs::MOENCH || det_type == defs::MYTHEN3 || + det_type == defs::GOTTHARD2) { + std::ostringstream oss; + proxy.Call("now", {}, -1, GET, oss); + // Get only + REQUIRE_THROWS(proxy.Call("now", {"2019"}, -1, PUT)); + REQUIRE_NOTHROW(proxy.Call("now", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("now", {}, -1, GET)); + } +} + +TEST_CASE("timestamp", "[.cmd][.new]") { + // 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 || + det_type == defs::MOENCH || det_type == defs::MYTHEN3 || + det_type == defs::GOTTHARD2) { + std::ostringstream oss; + proxy.Call("timestamp", {}, -1, GET, oss); + // Get only + REQUIRE_THROWS(proxy.Call("timestamp", {"2019"}, -1, PUT)); + REQUIRE_NOTHROW(proxy.Call("timestamp", {}, -1, GET)); + } else { + REQUIRE_THROWS(proxy.Call("timestamp", {}, -1, GET)); + } +} + +TEST_CASE("user", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + proxy.Call("user", {}, -1, GET); + + // This is a get only command + REQUIRE_THROWS(proxy.Call("user", {}, -1, PUT)); + REQUIRE_NOTHROW(proxy.Call("user", {}, -1, GET)); +} diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 9bed542f9..49c401d07 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -3,10 +3,10 @@ #define APILIB 0x200409 #define APIRECEIVER 0x200409 #define APIGUI 0x200409 -#define APICTB 0x200520 -#define APIGOTTHARD 0x200520 -#define APIJUNGFRAU 0x200520 -#define APIMOENCH 0x200515 -#define APIEIGER 0x200520 -#define APIGOTTHARD2 0x200528 -#define APIMYTHEN3 0x200528 +#define APICTB 0x200605 +#define APIGOTTHARD 0x200605 +#define APIGOTTHARD2 0x200605 +#define APIJUNGFRAU 0x200605 +#define APIMYTHEN3 0x200605 +#define APIMOENCH 0x200605 +#define APIEIGER 0x200605