From 344fc55464e5723df65657bb170a3a5aa66a285d Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 5 Mar 2026 12:28:13 +0100 Subject: [PATCH] 1001/fix no rx roi port (#1370) * rx_roi fixed when there is no roi for a particular port. Fixed tests for it * removing todo check if files created because its not enough to count matching pattern file names, but also look at timestamp and create files with timestamp else you read older ones. For now, checking individual rois is enough * restore md5 --- slsDetectorSoftware/src/DetectorImpl.cpp | 7 ++ .../tests/Caller/test-Caller-rx.cpp | 81 ++++++++++++++++++- 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index fceba4cb8..f824bd640 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1831,6 +1831,13 @@ void DetectorImpl::setRxROI(const std::vector &args) { auto moduleGlobalRoi = getModuleROI(iModule); // at most 2 rois per module (for each port) std::vector portRois(nPortsPerModule); + for (auto &roi : portRois) { + roi.setNoRoi(); + if (shm()->numberOfChannels.y == 1) { + roi.ymin = -1; + roi.ymax = -1; + } + } // check overlap with module for (const auto &arg : args) { diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp index 74fa821d8..a82c086ce 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -540,6 +540,16 @@ TEST_CASE("rx_roi", "[.cmdcall]") { REQUIRE(oss.str() == "rx_roi [[5, 10], [" + stringMin + ", " + stringMax + "]]\n"); + // setting to only one port and verify individual roi + { + REQUIRE_NOTHROW( + caller.call("rx_roi", {"[5, 10, -1, -1]"}, -1, PUT)); + std::ostringstream oss, oss1; + REQUIRE_NOTHROW(caller.call("rx_roi", {}, 0, GET, oss)); + REQUIRE_NOTHROW(caller.call("rx_roi", {}, 1, GET, oss1)); + REQUIRE(oss.str() == "rx_roi [[5, 10]]\n"); + REQUIRE(oss1.str() == "rx_roi [[0, 0]]\n"); + } // verify individual roi { stringMin = std::to_string(moduleSize.x - 50); @@ -643,6 +653,38 @@ TEST_CASE("rx_roi", "[.cmdcall]") { REQUIRE(oss.str() == "rx_roi [[5, 10, 20, 30], [" + stringMin + ", " + stringMax + ", 20, 30]]\n"); + // setting to only one port and verify individual roi + { + REQUIRE_NOTHROW( + caller.call("rx_roi", {"[5, 10, 20, 30]"}, -1, PUT)); + std::ostringstream oss, oss1; + REQUIRE_NOTHROW(caller.call("rx_roi", {}, 0, GET, oss)); + // eiger returns 2 values for 2 ports per module + if (det_type == defs::EIGER) { + REQUIRE(oss.str() == + "rx_roi [[5, 10, 20, 30], [0, 0, 0, 0]]\n"); + + } + // others return only 1 roi per module (1 port per module) + else { + REQUIRE(oss.str() == "rx_roi [[5, 10, 20, 30]]\n"); + } + if (det.size() > 1) { + REQUIRE_NOTHROW( + caller.call("rx_roi", {}, 1, GET, oss1)); + // eiger returns 2 values for 2 ports per module + if (det_type == defs::EIGER) { + REQUIRE(oss1.str() == + "rx_roi [[0, 0, 0, 0], [0, 0, 0, 0]]\n"); + + } + // others return only 1 roi per module (1 port per + // module) + else { + REQUIRE(oss1.str() == "rx_roi [[0, 0, 0, 0]]\n"); + } + } + } // verify individual roi { stringMin = std::to_string(portSize.x - delta); @@ -710,6 +752,43 @@ TEST_CASE("rx_roi", "[.cmdcall]") { REQUIRE(oss.str() == "rx_roi [[5, 10, 20, 30], [25, 28, " + stringMin + ", " + stringMax + "]]\n"); + // setting to only one port and verify individual roi + { + REQUIRE_NOTHROW( + caller.call("rx_roi", {"[ 5, 10, 20, 30]"}, -1, PUT)); + std::ostringstream oss, oss1; + REQUIRE_NOTHROW(caller.call("rx_roi", {}, 0, GET, oss)); + + // 2 ports + if (((det_type == defs::JUNGFRAU || + det_type == defs::MOENCH) && + (numinterfaces == 2)) || + (det_type == defs::EIGER)) { + REQUIRE(oss.str() == + "rx_roi [[5, 10, 20, 30], [0, 0, 0, 0]]\n"); + } + // others return only 1 roi per module (1 port per module) + else { + REQUIRE(oss.str() == "rx_roi [[5, 10, 20, 30]]\n"); + } + if (det.size() > 2) { + REQUIRE_NOTHROW( + caller.call("rx_roi", {}, 1, GET, oss1)); + // 2 ports + if (((det_type == defs::JUNGFRAU || + det_type == defs::MOENCH) && + (numinterfaces == 2)) || + (det_type == defs::EIGER)) { + REQUIRE(oss1.str() == + "rx_roi [[0, 0, 0, 0], [0, 0, 0, 0]]\n"); + } + // others return only 1 roi per module (1 port per + // module) + else { + REQUIRE(oss1.str() == "rx_roi [[0, 0, 0, 0]]\n"); + } + } + } // verify individual roi { stringMin = std::to_string(portSize.y - delta); @@ -741,7 +820,7 @@ TEST_CASE("rx_roi", "[.cmdcall]") { REQUIRE(oss1.str() == "rx_roi [[20, 30, " + stringMin + ", " + std::to_string(portSize.y - 1) + - "], [-1, -1]]\n"); + "], [0, 0, 0, 0]]\n"); } else { REQUIRE(oss1.str() == "rx_roi [[20, 30, " + stringMin + ", " +