GUI/DAQ: hutch-safety gating, error pop-ups, and automation pause-and-wait

Fix the GUI pop-up path and add personnel-safety-system (PSS) gating so
door-open / beam-down / shutter-closed conditions are surfaced and acted on.

- exception pop-ups: connect the previously-orphaned http_error signal;
  failed user operations now raise a modal dialog, background/polling errors
  a non-modal banner.
- PSS device (devices/pss_state.py) reading EH1-PSYS PROHIBITED-STATE /
  ALARM-STATE; new critical DoorSafetyError + DOOR_SAFETY_ERROR code.
- mounting service blocks mount/unmount when the hutch is not prohibited or
  an alarm is active; /status now publishes pss_prohibited / pss_alarm.
- GUI blocks manual mount/unmount and the automation Run button immediately
  (pop-up) on door-open, and shows a warning banner while an alarm is active.
- centralise per-action precondition checks (ring current, safety shutter,
  hutch door) into one combined "continue?" dialog with a session-global
  "don't ask again for 1 hour" snooze, applied to all data-collection buttons.
- live automation pauses and auto-resumes on bad conditions (beam, shutter,
  door, robot) with continue-now / stop overrides, gated by a default-on
  "Pause on bad conditions" checkbox replacing the dead CHECK_ENABLED constant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
appleb_mandClaude Opus 4.8 committed 2026-06-24 15:30:08 +02:00
1 parent a8855bfbba
commit 47e05dc28c
14 files changed
+523 -46

No files matched your search

@@ -2,7 +2,7 @@ import types
import sys
from aare.common.coordinate import AerotechCoordinate, Coordinate
from aare.common.exception_handler import CriticalTellException, MountingFailed
from aare.common.exception_handler import CriticalTellException, DoorSafetyError, MountingFailed
from aare.common.models import DewarAddress, SampleShortInfo
from aare.devices.tell_client import TellEventValueEnum
from aare.daq.operations.mounting.models import MountingContext, MountingResult, MountingDependencies, MountingSettings
@@ -35,7 +35,7 @@ def _make_sample(sample_id: int, name: str) -> SampleShortInfo:
)
def _make_context(previous_sample=None):
def _make_context(previous_sample=None, *, prohibited=True, alarm=False):
tell = types.SimpleNamespace(
mount=lambda **kwargs: TellEventValueEnum.SUCCESS,
unmount=lambda **kwargs: None,
@@ -51,6 +51,10 @@ def _make_context(previous_sample=None):
aerotech_pos=None,
tell=tell,
magnet_position_sensor=types.SimpleNamespace(value=0),
pss=types.SimpleNamespace(
is_prohibited=lambda: prohibited,
alarm_active=lambda: alarm,
),
)
streak = {"count": 0}
@@ -225,4 +229,47 @@ def test_execute_mount_critical_tell_error_does_not_increment_failure_streak(moc
assert result.success is False
assert isinstance(result.error, CriticalTellException)
assert ctx.deps.cfg.get_mount_failure_streak() == 0
assert ctx.deps.cfg.get_mount_failure_streak() == 0
def test_mount_blocked_when_not_prohibited(mock_logger):
"""Doors open / hutch not in prohibited state -> critical DoorSafetyError,
and it is not counted as a mount-failure streak."""
target_sample = _make_sample(2, "new")
ctx = _make_context(prohibited=False)
service = MountingService(context=ctx, logger=mock_logger)
result = service.execute(target=target_sample)
assert result.success is False
assert isinstance(result.error, DoorSafetyError)
assert result.error.critical is True
# Door safety is a pre-flight gate, not a mount attempt: streak stays clear.
assert ctx.deps.cfg.get_mount_failure_streak() == 0
def test_mount_blocked_when_alarm_active(mock_logger):
target_sample = _make_sample(3, "new")
ctx = _make_context(alarm=True)
service = MountingService(context=ctx, logger=mock_logger)
result = service.execute(target=target_sample)
assert result.success is False
assert isinstance(result.error, DoorSafetyError)
assert result.error.critical is True
def test_unmount_blocked_when_not_prohibited_keeps_door_error(mock_logger):
"""Unmount path must not swallow DoorSafetyError into UnmountingFailed."""
previous_sample = _make_sample(1, "old")
ctx = _make_context(previous_sample=previous_sample, prohibited=False)
service = MountingService(context=ctx, logger=mock_logger)
result = service.execute(target=None)
assert result.success is False
assert isinstance(result.error, DoorSafetyError)
assert result.error.critical is True