Acquisition errors return to Idle instead of Error state
Build Packages / build:viewer-tgz:cpu (push) Successful in 7m8s
Build Packages / build:viewer-tgz:cuda (push) Successful in 7m38s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m56s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 12m57s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 13m35s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 13m40s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 13m59s
Build Packages / build:windows:nocuda (push) Successful in 16m4s
Build Packages / build:windows:cuda (push) Successful in 18m16s
Build Packages / build:rpm (rocky8) (push) Successful in 11m25s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 12m34s
Build Packages / XDS test (durin plugin) (push) Successful in 7m11s
Build Packages / Generate python client (push) Successful in 34s
Build Packages / Build documentation (push) Successful in 1m4s
Build Packages / Create release (push) Skipped
Build Packages / build:rpm (ubuntu2204) (push) Successful in 11m41s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 11m44s
Build Packages / build:rpm (rocky9) (push) Successful in 13m0s
Build Packages / DIALS test (push) Successful in 13m18s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m43s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 8m33s
Build Packages / Unit tests (push) Successful in 1h1m27s

Going to the Error state after any acquisition failure forced an expensive
re-initialisation (reconnect + full detector config + pedestals), even when the
detector was still perfectly configured and only a transient problem occurred.

Split failures into two classes:
 - ordinary acquisition failures (receiver/writer/analysis problems, missed
   packets, writer disconnect) return to Idle with an Error-severity message, so
   the run can be retried without re-initialising;
 - failures that leave the detector in an undefined state throw the new
   JFJochCriticalException and still go to Error, forcing re-initialisation.

The detector layer is the single source of truth for "detector faulted":
SLSDetectorWrapper::InternalStop and DectrisDetectorWrapper::CheckBusyOrError
raise JFJochCriticalException on the ERROR state, and JFJochServices::Stop raises
it when the detector does not return to idle at the end of a run. MeasurementThread
dispatches purely on exception type - no detector-status field checks.

Also:
 - JFJochServices::Start now stops the receiver it launched if the detector fails
   to start, so the service returns to idle cleanly and the run can be retried.
 - A synchronous Start rethrows the failure to the caller (HTTP layer) via a
   stored exception_ptr, so a failed start is no longer reported as HTTP 200.
 - JFJochServices::Stop no longer throws on a writer error; it is reported through
   receiver_output.writer_err and surfaced as an Idle + Error-severity message,
   which makes the previously-dead writer_err branch in MeasurementThread live.

Initialisation, calibration/pedestal, SelectDetector and Deactivate keep the
Error-state behaviour, as those genuinely leave the system in an undefined state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 14:10:48 +02:00
co-authored by Claude Opus 4.8
parent d6389e12da
commit 0a28da7c2e
6 changed files with 85 additions and 25 deletions
+3 -1
View File
@@ -217,6 +217,8 @@ void SLSDetectorWrapper::Start(const DiffractionExperiment& experiment) {
det.setNumberOfTriggers(experiment.GetNumTriggers());
det.startDetector();
} catch (const JFJochException &) {
throw; // already a categorised JFJoch exception (incl. critical detector error) - keep its type
} catch (std::exception &e) {
logger.ErrorException(e);
throw JFJochException(JFJochExceptionCategory::Detector, e.what());
@@ -229,7 +231,7 @@ void SLSDetectorWrapper::InternalStop() {
// Assume it is executed in try-catch!
auto state = GetState();
if (state == DetectorState::ERROR)
throw JFJochException(JFJochExceptionCategory::Detector, "Detector in error state");
throw JFJochCriticalException("Detector in error state");
else if ((state == DetectorState::BUSY) || (state == DetectorState::WAITING)) {
try {
det.stopDetector();