diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 3d8bf5200..da2eb635a 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -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 2f51a47c1..026297a13 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -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 = {}); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 5c3ef60fb..b0d8a5154 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -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); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 20978c33e..77dbf835f 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -2201,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/test-CmdProxy-chiptestboard.cpp b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp index c9fcb0311..2a3a49b49 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-chiptestboard.cpp @@ -100,3 +100,769 @@ TEST_CASE("Setting and reading back Chip test board dacs", REQUIRE_THROWS(proxy.Call("vcom_adc2", {}, -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", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "samples 1\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", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "asamples 1\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 { + 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 { + 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 { + 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", {"0x8d0a21d4"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable 0x8d0a21d4\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", {"0xff00f0f0"}, -1, PUT, oss); + REQUIRE(oss.str() == "adcenable10g 0xff00f0f0\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 { + 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.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index a64edd837..152fe379a 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -2270,73 +2270,6 @@ TEST_CASE("resetfpga", "[.cmd]") { // } // } -// 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) { @@ -2362,30 +2295,6 @@ TEST_CASE("resetfpga", "[.cmd]") { // } // } -// 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("adcvpp", "[.cmd][.ctb]") { // if (test::type == defs::CHIPTESTBOARD) { // int prev_val = 0; @@ -2414,149 +2323,6 @@ TEST_CASE("resetfpga", "[.cmd]") { // } // } -// 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:"<