Using a loop to stop (#585)

* loop for stop, 10 retries
  For example, if module A got a "stop" during an acquisition, it stops to an 'Idle' state. If module B gets a "stop" before an acquisition, it will return it is in 'Idle' state and continue to start the next acquisition, but module B then waits for "ready  for trigger" synchronization from module A, which it will never get. Since module B missed the asynchronous stop command, the workaround in the client is to send another "stop" command (upto 10 retries) till it returns Idle.
This commit is contained in:
Erik Fröjdh
2022-11-25 09:55:51 +01:00
committed by GitHub
parent 8472cca81f
commit df40665c5e
2 changed files with 54 additions and 6 deletions

View File

@@ -780,7 +780,39 @@ 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()) {
case defs::EIGER:
case defs::JUNGFRAU:
case defs::MOENCH:
case defs::CHIPTESTBOARD: {
auto res = getNextFrameNumber(pos);
if (!res.equal()) {
uint64_t maxVal = 0;
for (auto it : res) {
maxVal = std::max(maxVal, it);
}
setNextFrameNumber(maxVal + 1);
}
} break;
default:
break;
}
}
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {