diff --git a/src/RawFile.cpp b/src/RawFile.cpp index 2c2f2c1..0cd712b 100644 --- a/src/RawFile.cpp +++ b/src/RawFile.cpp @@ -178,7 +178,9 @@ std::vector get_rois_from_disabled_udp_ports( if (udp_port_types == std::vector{"left", "right"}) { rois = merge_consecutive_rois(rois); } else if (udp_port_types == - std::vector{"bottom", "top"}) { + std::vector{"bottom", "top"} || + udp_port_types == + std::vector{"top", "bottom"}) { LOG(logDEBUG) << fmt::format("ROIs before merging: {}", rois.size()); diff --git a/src/RawFile.test.cpp b/src/RawFile.test.cpp index 4cf7a54..e2a7dc8 100644 --- a/src/RawFile.test.cpp +++ b/src/RawFile.test.cpp @@ -537,4 +537,40 @@ TEST_CASE("Read Eiger frame with disabled UDP ports", REQUIRE(frame.cols() == 512); REQUIRE(frame.rows() == 512); } + SECTION("2 full modules stacked vertically - right ports disabled") { + auto fpath = test_data_path() / "raw/eiger" / + "2_modules_eiger_disabled_udp_port_master_0.json"; + + REQUIRE(std::filesystem::exists(fpath)); + RawFile f(fpath); + REQUIRE(f.master().disabled_udp_ports().value() == + std::vector{1, 3, 5, 7}); + REQUIRE(f.master().udp_port_types().value() == + std::vector{"left", "right"}); + REQUIRE_THROWS_WITH( + f.read_frame(), + Catch::Matchers::ContainsSubstring( + "Multiple ROIs present in file. Use read_ROIs() " + "instead")); + auto frames = f.read_rois(); + REQUIRE(frames.size() == 2); + REQUIRE(frames[0].cols() == 512); + REQUIRE(frames[0].rows() == 512); + REQUIRE(frames[1].cols() == 512); + REQUIRE(frames[1].rows() == 512); + } + SECTION("quad module - bottom port disabled") { + auto fpath = test_data_path() / "raw/eiger" / + "quad_eiger_disabled_bottom_port_master_0.json"; + + REQUIRE(std::filesystem::exists(fpath)); + RawFile f(fpath); + REQUIRE(f.master().disabled_udp_ports().value() == + std::vector{1}); + REQUIRE(f.master().udp_port_types().value() == + std::vector{"top", "bottom"}); + auto frame = f.read_frame(); + REQUIRE(frame.cols() == 512); + REQUIRE(frame.rows() == 256); + } } diff --git a/src/RawMasterFile.cpp b/src/RawMasterFile.cpp index 0407411..73658fe 100644 --- a/src/RawMasterFile.cpp +++ b/src/RawMasterFile.cpp @@ -115,6 +115,10 @@ RawMasterFile::RawMasterFile(const std::filesystem::path &fpath) } else { throw std::runtime_error(LOCATION + "Unsupported file type"); } + + if (m_quad == 1 && m_udp_port_types.has_value()) { + m_udp_port_types.value() = {"top", "bottom"}; + } } RawMasterFile::RawMasterFile(std::istream &is, const std::string &fname)