From ae6e6639954c8a07925e48a908ff00be66c0a824 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 18 Aug 2026 11:18:57 +0200 Subject: [PATCH] 10.1.0: fix no rx roi port (#1529) * 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 --- 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 4f1e6fcbd..2f9313614 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1806,6 +1806,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 fc604fe78..80d7e322d 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -542,6 +542,16 @@ TEST_CASE("rx_roi", "[.detectorintegration][.disable_check_data_file]") { 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); @@ -645,6 +655,38 @@ TEST_CASE("rx_roi", "[.detectorintegration][.disable_check_data_file]") { 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); @@ -712,6 +754,43 @@ TEST_CASE("rx_roi", "[.detectorintegration][.disable_check_data_file]") { 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); @@ -743,7 +822,7 @@ TEST_CASE("rx_roi", "[.detectorintegration][.disable_check_data_file]") { 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 + ", " +