From 550955df2c34fe4bb3fce42822ecd2a6967e27a4 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 18 Sep 2026 16:45:45 +0200 Subject: [PATCH] when changing num interfaces, also setting up file writer if file write was enabled. added tests inside numinterface (from 2 to 1) to take an acquisition and check if the file exists --- .../tests/Caller/test-Caller.cpp | 32 ++++++++++++++++--- slsReceiverSoftware/src/Implementation.cpp | 7 ++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/slsDetectorSoftware/tests/Caller/test-Caller.cpp b/slsDetectorSoftware/tests/Caller/test-Caller.cpp index fa7c55d50..0b6d2f3c1 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller.cpp @@ -2620,7 +2620,7 @@ TEST_CASE("numinterfaces", "[.detectorintegration]") { "inconsistent numinterfaces to test"); Result prev_udp_dest; IpAddr prev_src_ip2{}; - if (prev_val == 2 && det_type != defs::EIGER) { + if (prev_val == 2) { prev_udp_dest = det.getDestinationUDPList(0); prev_src_ip2 = det.getSourceUDPIP2()[0]; } @@ -2629,17 +2629,39 @@ TEST_CASE("numinterfaces", "[.detectorintegration]") { caller.call("numinterfaces", {"2"}, -1, PUT, oss); REQUIRE(oss.str() == "numinterfaces 2\n"); } + // testing file write before and after num interface change { - std::ostringstream oss; - caller.call("numinterfaces", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "numinterfaces 1\n"); + auto prev_fwrite = + det.getFileWrite().tsquash("inconsistent file write state"); + det.setFileWrite(true); + { + std::ostringstream oss; + caller.call("numinterfaces", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "numinterfaces 1\n"); + } + // testing file write after num interface change + + // file write is true + REQUIRE(det.getFileWrite().tsquash( + "inconsistent file write state") == true); + + // check if file write actually works + auto acq_state = acq::default_acquisition_state(); + auto file_state = acq::default_file_state(); + file_state.file_format = defs::BINARY; + acq::run(det, acq_state, file_state); + std::string fname = acq::get_master_file_name(file_state); + REQUIRE(std::filesystem::exists(fname)); + + det.setFileWrite(prev_fwrite); } + { std::ostringstream oss; caller.call("numinterfaces", {}, -1, GET, oss); REQUIRE(oss.str() == "numinterfaces 1\n"); } - if (prev_val == 2 && det_type != defs::EIGER) { + if (prev_val == 2) { for (int i = 0; i != det.size(); ++i) { det.setDestinationUDPList({prev_udp_dest[i]}, {i}); } diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 6a78b764e..60c704578 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -1164,6 +1164,13 @@ void Implementation::setNumberofUDPInterfaces(const int n) { // test socket buffer size with current set up setUDPSocketBufferSize(0); + + // set up file write if enabled + if (fileWriteEnable) { + for (const auto &it : dataProcessor) + it->SetupFileWriter(fileWriteEnable, fileFormatType, + &hdf5LibMutex); + } } LOG(logINFO) << "Number of Interfaces: " << generalData->numUDPInterfaces;