From d57643434d58d1249d1b0f3e96379b7c791d4a0e Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 15 Aug 2024 17:09:36 +0200 Subject: [PATCH] dev: client: status for blocking acquire stop with slave temporarily in waiting (#944) * acq finish call back gets status squashed with default error but before that need to wait for gotthard slaves to catch up from waiting to stopped --- slsDetectorSoftware/src/DetectorImpl.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 169c0d086..39caeb265 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1219,10 +1219,14 @@ int DetectorImpl::acquire() { if (acquisition_finished != nullptr) { // status - runStatus status = IDLE; auto statusList = Parallel(&Module::getRunStatus, {}); - status = statusList.squash(ERROR); - // difference, but none error + // if any slave still waiting, wait up to 1s (gotthard) + for (int i = 0; i != 20 && statusList.any(WAITING); ++i) { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + statusList = Parallel(&Module::getRunStatus, {}); + } + runStatus status = statusList.squash(ERROR); + // inconsistent status (squash error), but none of them in error if (status == ERROR && (!statusList.any(ERROR))) { // handle jf sync issue (master idle, slaves stopped) if (statusList.contains_only(IDLE, STOPPED)) { @@ -1317,14 +1321,14 @@ void DetectorImpl::startAcquisition(const bool blocking, Positions pos) { if (blocking) { Parallel(&Module::startAndReadAll, masters); // ensure all status normal (slaves not blocking) - // to catch those slaves that are still 'waiting' - auto status = Parallel(&Module::getRunStatus, pos); - // if any slave still waiting, wait up to 1s - for (int i = 0; i != 20 && status.any(WAITING); ++i) { + // to catch those slaves that are still 'waiting' + auto statusList = Parallel(&Module::getRunStatus, pos); + // if any slave still waiting, wait up to 1s (gotthard) + for (int i = 0; i != 20 && statusList.any(WAITING); ++i) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); - status = Parallel(&Module::getRunStatus, pos); + statusList = Parallel(&Module::getRunStatus, pos); } - if (!status.contains_only(IDLE, STOPPED, RUN_FINISHED)) { + if (!statusList.contains_only(IDLE, STOPPED, RUN_FINISHED)) { throw RuntimeError("Acquisition not successful. " "Unexpected detector status"); }