From 856ca1e5581287fafeb053552592092e2e706b10 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Sun, 29 Jun 2025 01:06:34 +0200 Subject: [PATCH] 1d fixes --- slsDetectorSoftware/src/CallerSpecial.cpp | 10 ++++---- .../tests/Caller/test-Caller-rx.cpp | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index 4d921ef3a..7362af87d 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -819,15 +819,17 @@ std::vector Caller::parseRoiVector(const std::string &input) { parts.push_back(num); } - if (parts.size() != 4) { - throw RuntimeError("ROI must have 4 comma-separated integers"); + if (parts.size() != 2 && parts.size() != 4) { + throw RuntimeError("ROI must have 2 or 4 comma-separated integers"); } defs::ROI roi; roi.xmin = StringTo(parts[0]); roi.xmax = StringTo(parts[1]); - roi.ymin = StringTo(parts[2]); - roi.ymax = StringTo(parts[3]); + if (parts.size() == 4) { + roi.ymin = StringTo(parts[2]); + roi.ymax = StringTo(parts[3]); + } rois.emplace_back(roi); } return rois; diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp index ba429a82a..2b7fbec98 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -476,6 +476,8 @@ TEST_CASE("rx_roi", "[.cmdcall]") { } else { auto prev_val = det.getRxROI(); defs::xy detsize = det.getDetectorSize(); + auto portSize = det.getPortSize()[0]; + int delta = 50; // 1d if (det_type == defs::GOTTHARD2 || det_type == defs::MYTHEN3) { @@ -528,6 +530,19 @@ TEST_CASE("rx_roi", "[.cmdcall]") { REQUIRE(oss.str() == "rx_roi [[5, 10], [" + stringMin + ", " + stringMax + "]]\n"); + // verify individual roi + { + stringMin = std::to_string(moduleSize.x - 50); + stringMax = std::to_string(moduleSize.x + 50); + std::ostringstream oss, oss1; + REQUIRE_NOTHROW(caller.call( + "rx_roi", {"[" + stringMin + ", " + stringMax + "]"}, -1, PUT, oss)); + REQUIRE(oss.str() == + "rx_roi [[" + stringMin + ", " + stringMax + "]]\n"); + REQUIRE_NOTHROW( + caller.call("rx_roi", {}, 0, GET, oss1)); + REQUIRE(oss1.str() == "rx_roi [[" + stringMin + ", " + std::to_string(moduleSize.x - 1) + "]]\n"); + } } } // 2d eiger, jungfrau, moench @@ -590,8 +605,7 @@ TEST_CASE("rx_roi", "[.cmdcall]") { int numinterfaces = det.getNumberofUDPInterfaces().tsquash( "inconsistent number of interfaces"); - auto portSize = det.getPortSize()[0]; - int delta = 50; + // multiple ports horizontally if (det_type == defs::EIGER || (det.size() == 2 && det.getModuleGeometry().x > 1)) { std::string stringMin = std::to_string(portSize.x); @@ -619,11 +633,11 @@ TEST_CASE("rx_roi", "[.cmdcall]") { caller.call("rx_roi", {}, 0, GET, oss1)); // eiger returns 2 values for 2 ports per module if (det_type == defs::EIGER) { - REQUIRE(oss1.str() == "rx_roi [[" + stringMin + ", " + std::to_string(portSize.x - 1) + ", 20, 30], [" + std::to_string(portSize.x) + ", " + stringMax + ", 20, 30]]\n"); + REQUIRE(oss1.str() == "rx_roi [[" + stringMin + ", " + std::to_string(portSize.x - 1) + ", 20, 30], [0, " + std::to_string(delta) + ", 20, 30]]\n"); } // others return only 1 roi per module (1 port per module) else { - REQUIRE(oss1.str() == "rx_roi [[" + stringMin + ", " + std::to_string(portSize.x - 1) + "20, 30]]\n"); + REQUIRE(oss1.str() == "rx_roi [[" + stringMin + ", " + std::to_string(portSize.x - 1) + ", 20, 30]]\n"); } } } @@ -657,7 +671,7 @@ TEST_CASE("rx_roi", "[.cmdcall]") { // non-eiger with 2 interfaces returns 2 values for 2 ports per module if ((det_type == defs::JUNGFRAU || det_type == defs::MOENCH) && (numinterfaces == 2)) { - REQUIRE(oss1.str() == "rx_roi [[20, 30, " + stringMin + ", " + std::to_string(portSize.y - 1) + "], [20, 30, " + std::to_string(portSize.y) + ", " + stringMax + "]]\n"); + REQUIRE(oss1.str() == "rx_roi [[20, 30, " + stringMin + ", " + std::to_string(portSize.y - 1) + "], [20, 30, 0, " + std::to_string(delta) + "]]\n"); } // others return only 1 roi per module (1 port per module) else {