diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 6ffbcf663..df8358cb1 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1331,6 +1331,9 @@ int* getDetectorPosition() { // Detector Specific int checkDetectorType() { +#ifdef VIRTUAL + return OK; +#endif LOG(logINFO, ("Checking type of module\n")); FILE* fd = fopen(TYPE_FILE_NAME, "r"); if (fd == NULL) { diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 9d7a0d297..959dd1c53 100755 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -1098,11 +1098,6 @@ int getADC(enum ADCINDEX ind){ } int setHighVoltage(int val){ -#ifdef VIRTUAL - if (val >= 0) - highvoltage = val; - return highvoltage; -#endif u_int32_t addr = HV_REG; u_int32_t sel = 0x0; diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index 96409c5f0..0d5237c6f 100755 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -1284,7 +1284,9 @@ int powerChip (int on){ bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK); } } - +#ifdef VIRTUAL + return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST); +#endif return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST); } diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 12a8e36ef..88f7db52d 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -1112,6 +1112,9 @@ uint64_t getPatternBitMask() { } int checkDetectorType() { +#ifdef VIRTUAL + return OK; +#endif LOG(logINFO, ("Checking type of module\n")); FILE* fd = fopen(TYPE_FILE_NAME, "r"); if (fd == NULL) { diff --git a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp index 30dda3df2..2e5045320 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-jungfrau.cpp @@ -13,37 +13,7 @@ using sls::Detector; using test::GET; using test::PUT; -TEST_CASE("powerchip", "[.cmd][!mayfail]") { - // TODO! this test currently fails with the - // virtual detecto server - Detector det; - CmdProxy proxy(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::JUNGFRAU) { - auto pc = det.getPowerChip(); - { - std::ostringstream oss; - proxy.Call("powerchip", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "powerchip 1\n"); - } - { - std::ostringstream oss; - proxy.Call("powerchip", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "powerchip 0\n"); - } - { - std::ostringstream oss; - proxy.Call("powerchip", {}, -1, GET, oss); - REQUIRE(oss.str() == "powerchip 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPowerChip(pc[i], {i}); - } - } else { - REQUIRE_THROWS(proxy.Call("powerchip", {}, -1, GET)); - } -} TEST_CASE("nframes", "[.cmd]") { Detector det; diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 4166b26d4..182e56c34 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -702,26 +702,26 @@ TEST_CASE("vhighvoltage", "[.cmd][.new]") { else if (det_type == defs::EIGER) { { std::ostringstream oss1, oss2; - proxy.Call("vhighvoltage", {"50"}, -1, PUT, oss1); + proxy.Call("vhighvoltage", {"50"}, 0, PUT, oss1); REQUIRE(oss1.str() == "vhighvoltage 50\n"); std::this_thread::sleep_for(std::chrono::seconds(2)); - proxy.Call("vhighvoltage", {}, -1, GET, oss2); + proxy.Call("vhighvoltage", {}, 0, GET, oss2); REQUIRE(oss2.str() == "vhighvoltage 50\n"); } { std::ostringstream oss1, oss2; - proxy.Call("vhighvoltage", {"120"}, -1, PUT, oss1); + proxy.Call("vhighvoltage", {"120"}, 0, PUT, oss1); REQUIRE(oss1.str() == "vhighvoltage 120\n"); std::this_thread::sleep_for(std::chrono::seconds(2)); - proxy.Call("vhighvoltage", {}, -1, GET, oss2); + proxy.Call("vhighvoltage", {}, 0, GET, oss2); REQUIRE(oss2.str() == "vhighvoltage 120\n"); } { std::ostringstream oss1, oss2; - proxy.Call("vhighvoltage", {"0"}, -1, PUT, oss1); + proxy.Call("vhighvoltage", {"0"}, 0, PUT, oss1); REQUIRE(oss1.str() == "vhighvoltage 0\n"); std::this_thread::sleep_for(std::chrono::seconds(2)); - proxy.Call("vhighvoltage", {}, -1, GET, oss2); + proxy.Call("vhighvoltage", {}, 0, GET, oss2); REQUIRE(oss2.str() == "vhighvoltage 0\n"); } } @@ -754,9 +754,70 @@ 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(); + if (det_type == defs::JUNGFRAU || + det_type == defs::MYTHEN3 || + det_type == defs::GOTTHARD2 || + det_type == defs::MOENCH) { + auto prev_val = det.getPowerChip(); + { + std::ostringstream oss; + proxy.Call("powerchip", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "powerchip 1\n"); + } + { + std::ostringstream oss; + proxy.Call("powerchip", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "powerchip 0\n"); + } + { + std::ostringstream oss; + proxy.Call("powerchip", {}, -1, GET, oss); + REQUIRE(oss.str() == "powerchip 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPowerChip(prev_val[i], {i}); + } + } else { + REQUIRE_THROWS(proxy.Call("powerchip", {}, -1, GET)); + } +} - +TEST_CASE("imagetest", "[.cmd][.new]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::GOTTHARD) { + auto prev_val = det.getImageTestMode(); + { + std::ostringstream oss1, oss2; + proxy.Call("imagetest", {"1"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "imagetest 1\n"); + proxy.Call("imagetest", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "imagetest 1\n"); + } + { + std::ostringstream oss1, oss2; + proxy.Call("imagetest", {"0"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "imagetest 0\n"); + proxy.Call("imagetest", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "imagetest 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setImageTestMode(prev_val[i], {i}); + } + } else if (det_type != defs::JUNGFRAU && + det_type != defs::EIGER) { + // wont fail for eiger and jungfrau virtual servers + REQUIRE_THROWS(proxy.Call("imagetest", {}, -1, GET)); + } +}