From 3b6733be6dee9ce25bc1b34ccecea997a15d454c Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 28 May 2026 19:26:34 +0200 Subject: [PATCH] wip, acquire done --- .../tests/Caller/test-Caller-acquire.cpp | 195 ++++++++---------- slsDetectorSoftware/tests/acquire/Acquire.cpp | 2 +- 2 files changed, 89 insertions(+), 108 deletions(-) diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp index d4e44a088..2c00e356d 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-acquire.cpp @@ -34,130 +34,111 @@ TEST_CASE("acquire_check_binary_file_size", Detector det; auto det_type = det.getDetectorType().tsquash("Inconsistent detector types to test"); - if (det_type == defs::CHIPTESTBOARD || - det_type == defs::XILINX_CHIPTESTBOARD) { - // skip for CTB as it has different tests for file size - return; - } + if (det_type == defs::CHIPTESTBOARD || det_type == defs::XILINX_CHIPTESTBOARD) + test_ctb_binary_file_size(det); + else + REQUIRE_NOTHROW(acquire_and_check_file_size(det)); +} + +void acquire_and_check_file_size(Detector &det, const acq::CTBState &ctb_state = acq::default_ctb_state()) { auto acq_state = acq::default_acquisition_state(); acq_state.num_frames = 2; - acq::run(det, acq_state); - auto image_size = acq::get_expected_image_size(det); - checks::check_binary_file_size(image_size, acq_state.num_frames); + auto file_state = acq::default_file_state(); + acq::run(det, acq_state, file_state, ctb_state); + auto image_size = acq::get_expected_image_size(det, ctb_state); + REQUIRE_NOTHROW(checks::check_binary_file_size(image_size, acq_state.num_frames)); } -void test_ctb_file_size_with_acquire(Detector &det, int64_t num_frames, - const acq::CTBState &test_info, - bool isXilinxCtb) { - auto acq_state = acq::default_acquisition_state(); - acq_state.num_frames = num_frames; - acq::run(det, acq_state); - auto image_size = acq::get_expected_image_size(det, test_info); - checks::check_binary_file_size(image_size, acq_state.num_frames); -} - -// disable for xilinx_ctb as it requires higher maximum receive buffer size -// sysctl net.core.rmem_max=$((100*1024*1024)) -// sysctl net.core.rmem_default=$((100*1024*1024)) -TEST_CASE("ctb_acquire_check_file_size", - "[.detectorintegration][.disable_check_data_file]") { - Detector det; - Caller caller(&det); +void test_ctb_binary_file_size(Detector &det) { auto det_type = det.getDetectorType().tsquash("Inconsistent detector types to test"); - if (det_type == defs::CHIPTESTBOARD || - det_type == defs::XILINX_CHIPTESTBOARD) { - bool isXilinxCtb = (det_type == defs::XILINX_CHIPTESTBOARD); - bool isAltera = !isXilinxCtb; - int64_t num_frames_to_acquire = 2; - // all the test cases - acq::CTBState ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::ANALOG_AND_DIGITAL; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::ANALOG_AND_DIGITAL; - ctb_state.dbit_offset = 16; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::ANALOG_AND_DIGITAL; + acq::CTBState ctb_state = acq::default_ctb_state(det_type == defs::CHIPTESTBOARD); + // readout mode = defs::ANALOG_AND_DIGITAL + // analog samples = 5000 + // digital samples = 6000 + // trans samples = 288 + // ten_giga = isAltera ? false : true + // adc enable 1g = 0xFFFFFF00 + // adc enable 1g = 0xFF00FFFF + // dbit offset = 0 + // dbit list = {0, 12, 2, 43} + // dbit reorder = false + // trans mask = 0x3 + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); ctb_state.dbit_reorder = true; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::ANALOG_AND_DIGITAL; + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.dbit_offset = 16; + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.dbit_offset = 16; + ctb_state.dbit_reorder = true; + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; + ctb_state.dbit_offset = 16; + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; + ctb_state.dbit_reorder = true; + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; ctb_state.dbit_offset = 16; ctb_state.dbit_reorder = true; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::ANALOG_AND_DIGITAL; - ctb_state.dbit_offset = 16; - ctb_state.dbit_list.clear(); - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::ANALOG_AND_DIGITAL; - ctb_state.dbit_offset = 16; - ctb_state.dbit_list.clear(); + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.readout_mode = defs::TRANSCEIVER_ONLY; + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.readout_mode = defs::TRANSCEIVER_ONLY; ctb_state.dbit_reorder = true; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; - ctb_state.dbit_offset = 16; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; - ctb_state.dbit_list.clear(); - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; - ctb_state.dbit_offset = 16; - ctb_state.dbit_list.clear(); - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); - ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; - ctb_state.dbit_offset = 16; - ctb_state.dbit_list.clear(); - ctb_state.dbit_reorder = true; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); ctb_state.readout_mode = defs::TRANSCEIVER_ONLY; ctb_state.dbit_offset = 16; - ctb_state.dbit_list.clear(); + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); + ctb_state.readout_mode = defs::DIGITAL_AND_TRANSCEIVER; + ctb_state.dbit_offset = 16; ctb_state.dbit_reorder = true; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); - - ctb_state = acq::default_ctb_state(isAltera); + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); + } + { + acq::CTBStateGuard ctb_guard(det, ctb_state); ctb_state.readout_mode = defs::ANALOG_ONLY; ctb_state.dbit_offset = 16; - ctb_state.dbit_list.clear(); ctb_state.dbit_reorder = true; - REQUIRE_NOTHROW(test_ctb_file_size_with_acquire( - det, num_frames_to_acquire, ctb_state, isXilinxCtb)); + REQUIRE_NOTHROW(acquire_and_check_file_size(det, num_frames_to_acquire, ctb_state)); } } diff --git a/slsDetectorSoftware/tests/acquire/Acquire.cpp b/slsDetectorSoftware/tests/acquire/Acquire.cpp index 23bc0863f..c95453692 100644 --- a/slsDetectorSoftware/tests/acquire/Acquire.cpp +++ b/slsDetectorSoftware/tests/acquire/Acquire.cpp @@ -34,7 +34,7 @@ void run_acquisition(Detector &det) { void run(Detector &det, const AcquisitionState &acq_state, const FileState &file_state, const CTBState &ctb_state) { - CTBStateGuard ctb_guard(det, ctb_state); + //CTBStateGuard ctb_guard(det, ctb_state); FileStateGuard file_guard(det, file_state); AcquisitionStateGuard acq_guard(det, acq_state); run_acquisition(det);