Files
slsDetectorPackage/slsDetectorSoftware/tests/acquire/Acquire.h
T
maliakal_d 8477152318
Build on RHEL9 docker image / build (push) Successful in 3m49s
Build on RHEL8 docker image / build (push) Successful in 5m1s
Run Simulator Tests on local RHEL9 / build (push) Failing after 14m37s
Run Simulator Tests on local RHEL8 / build (push) Failing after 16m52s
ctb fix with ctb state
2026-06-09 17:16:46 +02:00

60 lines
1.7 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include "sls/Detector.h"
#include "sls/logger.h"
namespace sls::test::acquire {
class FileState;
// at the moment, only number of frames
struct AcquisitionState {
int64_t num_frames;
};
inline AcquisitionState default_acquisition_state() { return {1}; }
inline AcquisitionState get_acquisition_state(const Detector &det) {
return AcquisitionState{
det.getNumberOfFrames().tsquash("Inconsistent number of frames")};
}
inline void set_acquisition_state(Detector &det, const AcquisitionState &s) {
det.setNumberOfFrames(s.num_frames);
}
inline std::ostream &operator<<(std::ostream &os, const AcquisitionState &s) {
os << "Acquisition State:"
<< "\n Number of Frames: " << s.num_frames;
return os;
}
/**
* @brief RAII guard for restoring the acquisition state of a detector.
* The constructor saves the current acquisition state and sets a new state,
* while the destructor restores the original state.
*
*/
class AcquisitionStateGuard {
public:
explicit AcquisitionStateGuard(Detector &det,
const AcquisitionState &new_state)
: det(det), saved_(get_acquisition_state(det)) {
set_acquisition_state(det, new_state);
}
~AcquisitionStateGuard() { set_acquisition_state(det, saved_); }
private:
Detector &det;
AcquisitionState saved_;
};
void wait_until_idle(const Detector &det);
void run_acquisition(Detector &det);
void run(Detector &det, const AcquisitionState &acq_state,
const FileState &file_state);
} // namespace sls::test::acquire