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
This commit is contained in:
2024-08-15 17:09:36 +02:00
committed by GitHub
parent de33aff077
commit d57643434d

View File

@ -1219,10 +1219,14 @@ int DetectorImpl::acquire() {
if (acquisition_finished != nullptr) { if (acquisition_finished != nullptr) {
// status // status
runStatus status = IDLE;
auto statusList = Parallel(&Module::getRunStatus, {}); auto statusList = Parallel(&Module::getRunStatus, {});
status = statusList.squash(ERROR); // if any slave still waiting, wait up to 1s (gotthard)
// difference, but none error 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))) { if (status == ERROR && (!statusList.any(ERROR))) {
// handle jf sync issue (master idle, slaves stopped) // handle jf sync issue (master idle, slaves stopped)
if (statusList.contains_only(IDLE, STOPPED)) { if (statusList.contains_only(IDLE, STOPPED)) {
@ -1318,13 +1322,13 @@ void DetectorImpl::startAcquisition(const bool blocking, Positions pos) {
Parallel(&Module::startAndReadAll, masters); Parallel(&Module::startAndReadAll, masters);
// ensure all status normal (slaves not blocking) // ensure all status normal (slaves not blocking)
// to catch those slaves that are still 'waiting' // to catch those slaves that are still 'waiting'
auto status = Parallel(&Module::getRunStatus, pos); auto statusList = Parallel(&Module::getRunStatus, pos);
// if any slave still waiting, wait up to 1s // if any slave still waiting, wait up to 1s (gotthard)
for (int i = 0; i != 20 && status.any(WAITING); ++i) { for (int i = 0; i != 20 && statusList.any(WAITING); ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(50)); 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. " throw RuntimeError("Acquisition not successful. "
"Unexpected detector status"); "Unexpected detector status");
} }