diff --git a/slsDetectorSoftware/tests/acquire/ExpectedState.cpp b/slsDetectorSoftware/tests/acquire/ExpectedState.cpp index 88affcda6..acb9afeb5 100644 --- a/slsDetectorSoftware/tests/acquire/ExpectedState.cpp +++ b/slsDetectorSoftware/tests/acquire/ExpectedState.cpp @@ -277,17 +277,15 @@ acq::Gotthard2ExpectedState build_gotthard2_specific_state(const Detector& det) return e; } -acq::CTBExpectedState build_ctb_specific_state(const Detector& det) { +acq::CTBExpectedState build_ctb_specific_state(const Detector& det, const acq::CTBState& ctb_state) { acq::CTBExpectedState e; e.exptime = get_exptime(det); e.period = get_period(det); - auto detType = get_detector_type(det); - bool isAltera = (detType == defs::CHIPTESTBOARD); - e.ctb_acq_state = acq::get_ctb_state(det, isAltera); + e.ctb_acq_state = ctb_state; return e; } -acq::DetectorSpecificState build_detector_specific_state(const Detector& det) { +acq::DetectorSpecificState build_detector_specific_state(const Detector& det, const acq::CTBState& ctb_state) { switch (det.getDetectorType().tsquash("bad type")) { case defs::JUNGFRAU: return build_jungfrau_specific_state(det); @@ -301,7 +299,7 @@ acq::DetectorSpecificState build_detector_specific_state(const Detector& det) { return build_gotthard2_specific_state(det); case defs::CHIPTESTBOARD: case defs::XILINX_CHIPTESTBOARD: - return build_ctb_specific_state(det); + return build_ctb_specific_state(det, ctb_state); } throw sls::RuntimeError("Unsupported detector type"); } @@ -311,11 +309,12 @@ acq::DetectorSpecificState build_detector_specific_state(const Detector& det) { namespace sls::test::acquire { -ExpectedState build_expected_state(const Detector& det) { +ExpectedState build_expected_state(const Detector& det, const AcquisitionState &acq_state, const FileState &file_state, const CTBState &ctb_state) { ExpectedState e; e.common_state = build_common_state(det); - e.file_state = get_file_state(det); - e.detector_specific_state = build_detector_specific_state(det); + e.file_state = file_state; + e.acquisition_state = acq_state; + e.detector_specific_state = build_detector_specific_state(det, ctb_state); return e; } diff --git a/slsDetectorSoftware/tests/acquire/ExpectedState.h b/slsDetectorSoftware/tests/acquire/ExpectedState.h index 9af6725fe..52fb95f55 100644 --- a/slsDetectorSoftware/tests/acquire/ExpectedState.h +++ b/slsDetectorSoftware/tests/acquire/ExpectedState.h @@ -5,6 +5,7 @@ #include "CTBState.h" #include "FileState.h" +#include "Acquire.h" #include @@ -54,7 +55,7 @@ struct EigerExpectedState { ns sub_period{}; bool quad{}; int read_n_rows{}; - std::vector rate_corrections{}; + std::vector rate_corrections{}; defs::speedLevel readout_speed{}; }; @@ -95,6 +96,7 @@ using DetectorSpecificState = std::variant< struct ExpectedState { FileState file_state{}; + AcquisitionState acquisition_state{}; CommonExpectedState common_state{}; DetectorSpecificState detector_specific_state{}; }; @@ -104,6 +106,6 @@ const T& get_detector_specific_state(const ExpectedState& expected_state) { return std::get(expected_state.detector_specific_state); } -ExpectedState build_expected_state(const Detector& det); +ExpectedState build_expected_state(const Detector& det, const AcquisitionState &acq_state = default_acquisition_state(), const FileState &file_state = default_file_state(), const CTBState &ctb_state = default_ctb_state()); } // namespace sls::test::acquire \ No newline at end of file diff --git a/slsDetectorSoftware/tests/checks/MasterFileChecks.h b/slsDetectorSoftware/tests/checks/MasterFileChecks.h index a788a6bf6..163bd7132 100644 --- a/slsDetectorSoftware/tests/checks/MasterFileChecks.h +++ b/slsDetectorSoftware/tests/checks/MasterFileChecks.h @@ -115,130 +115,72 @@ void check_readout_speed(CheckerT &checker, const acq::ExpectedState& expected) checker.template check(MasterAttributes::N_READOUT_SPEED.data(), ToString(expected.detector_specific_state.readout_speed)); } +template +void check_dynamic_range(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_DYNAMIC_RANGE.data(), expected.detector_specific_state.dynamic_range); +} +template +void check_ten_giga(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_TEN_GIGA.data(), static_cast(expected.detector_specific_state.ten_giga)); +} + +template +void check_threshold_energy(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_THRESHOLD_ENERGY.data(), expected.detector_specific_state.threshold_energy); +} + +template +void check_sub_exptime(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_SUB_EXPOSURE_TIME.data(), ToString(expected.detector_specific_state.sub_exptime)); +} + +template +void check_sub_period(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_SUB_ACQUISITION_PERIOD.data(), ToString(expected.detector_specific_state.sub_period)); +} + +template +void check_quad(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_QUAD.data(), static_cast(expected.detector_specific_state.quad)); +} + +template +void check_rate_corrections(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check>(MasterAttributes::N_RATE_CORRECTIONS.data(), expected.detector_specific_state.rate_corrections); +} + +template +void check_counter_mask(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_COUNTER_MASK.data(), expected.detector_specific_state.counter_mask); +} + +template +void check_exptime_array(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check>(MasterAttributes::N_EXPOSURE_TIMES.data(), expected.detector_specific_state.exp_times); +} + +template +void check_gate_delay_array(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check>(MasterAttributes::N_GATE_DELAYS.data(), expected.detector_specific_state.gate_delays); +} + +template +void check_gates(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_GATES.data(), expected.detector_specific_state.num_gates); +} + +template +void check_threshold_energies(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check>(MasterAttributes::N_THRESHOLD_ENERGIES.data(), expected.detector_specific_state.thresholdAllEnergyeV); +} + +template +void check_burst_mode(CheckerT &checker, const acq::ExpectedState& expected) { + checker.template check(MasterAttributes::N_BURST_MODE.data(), ToString(expected.detector_specific_state.burst_mode)); +} /* - - - - -template -void test_master_file_dynamic_range(const Detector &det, CheckerT &checker) { - auto dr = det.getDynamicRange().tsquash("Inconsistent dynamic range"); - - REQUIRE_NOTHROW(checker.template check( - MasterAttributes::N_DYNAMIC_RANGE.data(), dr)); -} - -template -void test_master_file_ten_giga(const Detector &det, CheckerT &checker) { - auto ten_giga = - static_cast(det.getTenGiga().tsquash("Inconsistent ten giga")); - - REQUIRE_NOTHROW(checker.template check( - MasterAttributes::N_TEN_GIGA.data(), ten_giga)); -} - -template -void test_master_file_threshold_energy(const Detector &det, CheckerT &checker) { - auto threshold = - det.getThresholdEnergy().tsquash("Inconsistent threshold energy"); - - REQUIRE_NOTHROW(checker.template check( - MasterAttributes::N_THRESHOLD_ENERGY.data(), threshold)); -} - -template -void test_master_file_sub_exptime(const Detector &det, CheckerT &checker) { - auto sub_exptime = - det.getSubExptime().tsquash("Inconsistent sub exposure time"); - - REQUIRE_NOTHROW(checker.template check( - MasterAttributes::N_SUB_EXPOSURE_TIME.data(), ToString(sub_exptime))); -} - -template -void test_master_file_sub_period(const Detector &det, CheckerT &checker) { - auto exptime = det.getSubExptime().tsquash("Inconsistent sub exptime"); - auto deadtime = det.getSubDeadTime().tsquash("Inconsistent sub deadtime"); - auto sub_period = exptime + deadtime; - - REQUIRE_NOTHROW(checker.template check( - MasterAttributes::N_SUB_ACQUISITION_PERIOD.data(), - ToString(sub_period))); -} - -template -void test_master_file_quad(const Detector &det, CheckerT &checker) { - auto quad = static_cast(det.getQuad().tsquash("Inconsistent quad")); - - REQUIRE_NOTHROW( - checker.template check(MasterAttributes::N_QUAD.data(), quad)); -} - -template -void test_master_file_rate_corrections(const Detector &det, CheckerT &checker) { - std::vector dead_times; - for (auto item : det.getRateCorrection()) - dead_times.push_back(item.count()); - - REQUIRE_NOTHROW(checker.template check>( - MasterAttributes::N_RATE_CORRECTIONS.data(), dead_times)); -} - -template -void test_master_file_counter_mask(const Detector &det, CheckerT &checker) { - auto counter_mask = static_cast( - det.getCounterMask().tsquash("Inconsistent counter mask")); - - REQUIRE_NOTHROW(checker.template check( - MasterAttributes::N_COUNTER_MASK.data(), counter_mask)); -} - -template -void test_master_file_exptimes(const Detector &det, CheckerT &checker) { - auto exptimes = - det.getExptimeForAllGates().tsquash("Inconsistent exposure times"); - - REQUIRE_NOTHROW(checker.template check>( - MasterAttributes::N_EXPOSURE_TIMES.data(), exptimes)); -} - -template -void test_master_file_gate_delays(const Detector &det, CheckerT &checker) { - auto gate_delays = - det.getGateDelayForAllGates().tsquash("Inconsistent GateDelay"); - - REQUIRE_NOTHROW(checker.template check>( - MasterAttributes::N_GATE_DELAYS.data(), gate_delays)); -} - -template -void test_master_file_gates(const Detector &det, CheckerT &checker) { - auto gates = det.getNumberOfGates().tsquash("Inconsistent number of gates"); - - REQUIRE_NOTHROW( - checker.template check(MasterAttributes::N_GATES.data(), gates)); -} - -template -void test_master_file_threadhold_energies(const Detector &det, - CheckerT &checker) { - auto threshold_energies = - det.getAllThresholdEnergy().tsquash("Inconsistent threshold energies"); - - REQUIRE_NOTHROW(checker.template check>( - MasterAttributes::N_THRESHOLD_ENERGIES.data(), threshold_energies)); -} - -template -void test_master_file_burst_mode(const Detector &det, CheckerT &checker) { - auto burst_mode = det.getBurstMode().tsquash("Inconsistent burst mode"); - - REQUIRE_NOTHROW(checker.template check( - MasterAttributes::N_BURST_MODE.data(), ToString(burst_mode))); -} - template void test_master_file_adc_mask(const Detector &det, CheckerT &checker) { acq::CTBState test_ctb_config = acq::default_ctb_state(); @@ -854,19 +796,43 @@ void check_moench_metadata(CheckerT &checker, const acq::ExpectedState& expected template void check_eiger_metadata(CheckerT &checker, const acq::ExpectedState& expected) { check_rois(checker, expected); - + check_dynamic_range(checker, expected); + check_ten_giga(checker, expected); + check_exptime(checker, expected); + check_period(checker, expected); + check_threshold_energy(checker, expected); + check_sub_exptime(checker, expected); + check_sub_period(checker, expected); + check_quad(checker, expected); + check_read_n_rows(checker, expected); + check_rate_corrections(checker, expected); + check_readout_speed(checker, expected); } template -void check_mythen3_metadata(CheckerT &checker, const acq::ExpectedState& expected); +void check_mythen3_metadata(CheckerT &checker, const acq::ExpectedState& expected) { + check_rois(checker, expected); + check_dynamic_range(checker, expected); + check_ten_giga(checker, expected); + check_period(checker, expected); + check_counter_mask(checker, expected); + check_exptime_array(checker, expected); + check_gate_delay_array(checker, expected); + check_gates(checker, expected); + check_threshold_energies(checker, expected); + check_readout_speed(checker, expected); +} template -void check_gotthard2_metadata(CheckerT &checker, const acq::ExpectedState& expected); +void check_gotthard2_metadata(CheckerT &checker, const acq::ExpectedState& expected) { + check_rois(checker, expected); + check_exptime(checker, expected); + check_period(checker, expected); + check_burst_mode(checker, expected); + check_readout_speed(checker, expected); +} template void check_ctb_metadata(CheckerT &checker, const acq::ExpectedState& expected); -template -void check_det_type(CheckerT &checker, const acq::ExpectedState& expected); - } \ No newline at end of file