diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 6f73483c6..d6e28cdd4 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -821,7 +821,19 @@ void Detector::startDetectorReadout() { } void Detector::stopDetector(Positions pos) { - pimpl->Parallel(&Module::stopAcquisition, pos); + + // stop and check status X times + int retries{0}; + // avoid default construction of runStatus::IDLE on squash + auto status = getDetectorStatus().squash(defs::runStatus::RUNNING); + while (status != defs::runStatus::IDLE) { + pimpl->Parallel(&Module::stopAcquisition, pos); + status = getDetectorStatus().squash(defs::runStatus::RUNNING); + ++retries; + + if (retries == 10) + throw RuntimeError("Could not stop detector"); + } // validate consistent frame numbers switch (getDetectorType().squash()) {