diff --git a/python/tests/test_det_api.py b/python/tests/test_det_api.py index 6db456a34..ad70c29ef 100644 --- a/python/tests/test_det_api.py +++ b/python/tests/test_det_api.py @@ -394,3 +394,85 @@ def test_patternstart(session_simulator, request): assert "not implemented" in str(exc_info.value) Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") + + +@pytest.mark.detectorintegration +def test_v_limit(session_simulator, request): + """Test v_limit.""" + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + + if det_type in ['ctb', 'xilinx_ctb']: + + # save previous value + from slsdet import dacIndex + prev_val = d.getDAC(dacIndex.V_LIMIT, True) + prev_dac_val = d.getDAC(dacIndex.DAC_0, False) + + with pytest.raises(Exception): + d.v_limit = (1200, 'mV') #mV unit not supported, should be 'no unit' + + with pytest.raises(Exception): + d.v_limit = -100 + + d.v_limit = 0 + assert d.v_limit == 0 + d.setDAC(dacIndex.DAC_0, 1200, True, [0]) + + d.v_limit = 1500 + assert d.v_limit == 1500 + + with pytest.raises(Exception): + d.setDAC(dacIndex.DAC_0, 1501, True, [0]) + + # restore previous value + for i in range(len(d)): + d.setDAC(dacIndex.V_LIMIT, prev_val[i], True, [i]) + d.setDAC(dacIndex.DAC_0, prev_dac_val[i], False, [i]) + + else: + with pytest.raises(Exception) as exc_info: + d.v_limit + assert "not implemented" in str(exc_info.value) + + Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") + + +''' +@pytest.mark.detectorintegration +def test_dac(session_simulator, request): + """Test dac.""" + det_type, num_interfaces, num_mods, d = session_simulator + assert d is not None + + if det_type in ['ctb', 'xilinx_ctb']: + + # save previous value + from slsdet import dacIndex + prev_val = d.getDAC(dacIndex.V_LIMIT, True) + prev_dac_val = d.getDAC(dacIndex.DAC_0, True) + + with pytest.raises(Exception): + d.v_limit = (1200, 'mV') #mV unit not supported, should be 'no unit' + + with pytest.raises(Exception): + d.v_limit = -100 + + d.v_limit = 0 + assert d.v_limit == 0 + d.setDAC(dacIndex.DAC_0, 1200, True, {0}) + + d.v_limit = 1500 + assert d.v_limit == 1500 + + with pytest.raises(Exception): + d.setDAC(dacIndex.DAC_0, 1501, True, {0}) + + # restore previous value + for i in range(len(d)): + d.setDAC(dacIndex.V_LIMIT, prev_val[i], True, {i}) + d.setDAC(dacIndex.DAC_0, prev_dac_val[i], True, {i}) + + + Log(LogLevel.INFOGREEN, f"✅ {request.node.name} passed") +''' \ No newline at end of file diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h index c524089c1..3464d7373 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h @@ -47,7 +47,7 @@ #define DEFAULT_PERIOD (1 * 1000 * 1000) // ns #define DEFAULT_DELAY (0) #define DEFAULT_HIGH_VOLTAGE (0) -#define DEFAULT_VLIMIT (-100) +#define DEFAULT_VLIMIT (0) #define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_TX_UDP_PORT (0x7e9a) #define DEFAULT_RUN_CLK (200) // 40 diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h index 591bf7545..aa113871b 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h @@ -56,7 +56,7 @@ #define DEFAULT_NUM_DSAMPLES (1) #define DEFAULT_NUM_TSAMPLES (200) #define DEFAULT_STARTING_FRAME_NUMBER (1) -#define DEFAULT_VLIMIT (-100) +#define DEFAULT_VLIMIT (0) #define DEFAULT_DELAY (0) #define MAX_TRANSCEIVER_MASK (0xF) diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp index 49c6ded55..68619bce0 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp @@ -579,6 +579,11 @@ TEST_CASE("dac", "[.detectorintegration][.dacs]") { test_dac_caller(static_cast(idac), "dac", 1200, true); test_dac_caller(static_cast(idac), "dac", -100); + det.setDacName(static_cast(idac), + "dacname" + std::to_string(idac)); + + test_dac_caller(defs::DAC_0, "dacname" + std::to_string(idac), + -100); } REQUIRE_THROWS( caller.call("dac", {std::to_string(idac), "-2"}, -1, PUT)); @@ -873,21 +878,12 @@ TEST_CASE("v_limit", "[.detectorintegration]") { if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getDAC(defs::V_LIMIT, true); + auto prev_dac_val = det.getDAC(defs::DAC_0, false); + REQUIRE_THROWS(caller.call("v_limit", {"1200", "mV"}, -1, PUT)); REQUIRE_THROWS(caller.call("v_limit", {"-100"}, -1, PUT)); REQUIRE_THROWS(caller.call("v_limit", {"-100", "mV"}, -1, PUT)); REQUIRE_THROWS(caller.call("v_limit", {"0", "mV"}, -1, PUT)); - - { - std::ostringstream oss; - caller.call("v_limit", {"1500"}, -1, PUT, oss); - REQUIRE(oss.str() == "v_limit 1500 mV\n"); - } - { - std::ostringstream oss; - caller.call("v_limit", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "v_limit 0 mV\n"); - } { std::ostringstream oss; caller.call("v_limit", {"0"}, -1, PUT, oss); @@ -898,11 +894,15 @@ TEST_CASE("v_limit", "[.detectorintegration]") { caller.call("v_limit", {}, -1, GET, oss); REQUIRE(oss.str() == "v_limit 0 mV\n"); } + { + std::ostringstream oss; + caller.call("v_limit", {"1500"}, -1, PUT, oss); + REQUIRE(oss.str() == "v_limit 1500 mV\n"); + REQUIRE_THROWS(caller.call("dac", {"0", "1501", "mV"}, -1, PUT)); + } for (int i = 0; i != det.size(); ++i) { - if (prev_val[i] == -100) { - prev_val[i] = 0; - } det.setDAC(defs::V_LIMIT, prev_val[i], true, {i}); + det.setDAC(defs::DAC_0, prev_dac_val[i], false, {i}); } } else { REQUIRE_THROWS(caller.call("v_limit", {}, -1, GET));