mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-06-28 22:39:37 +02:00
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
|
|
#include "Acquire.h"
|
|
#include "CTBState.h"
|
|
#include "FileState.h"
|
|
|
|
#include "catch.hpp"
|
|
#include <chrono>
|
|
#include <thread>
|
|
|
|
namespace sls::test::acquire {
|
|
|
|
void wait_until_idle(const Detector &det) {
|
|
bool idle = false;
|
|
while (!idle) {
|
|
auto statusList = det.getDetectorStatus();
|
|
if (statusList.any(defs::ERROR)) {
|
|
throw RuntimeError("error status during acquisition");
|
|
}
|
|
if (statusList.contains_only(defs::IDLE, defs::STOPPED)) {
|
|
idle = true;
|
|
}
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
}
|
|
}
|
|
|
|
void run_acquisition(Detector &det) {
|
|
det.startReceiver();
|
|
det.startDetector();
|
|
wait_until_idle(det);
|
|
det.stopReceiver();
|
|
}
|
|
|
|
void run(Detector &det, const AcquisitionState &acq_state,
|
|
const FileState &file_state) {
|
|
run(det, acq_state, file_state, default_ctb_state());
|
|
}
|
|
|
|
void run(Detector &det, const AcquisitionState &acq_state,
|
|
const FileState &file_state, const CTBState &ctb_state) {
|
|
FileStateGuard file_guard(det, file_state);
|
|
AcquisitionStateGuard acq_guard(det, acq_state);
|
|
run_acquisition(det);
|
|
auto frames_caught = det.getFramesCaught()[0][0];
|
|
REQUIRE(frames_caught == acq_state.num_frames);
|
|
}
|
|
|
|
} // namespace sls::test::acquire
|