fix: combined view only when state is moving or when in robotsampleexchange

This commit is contained in:
duan_j committed 2026-08-20 16:18:47 +02:00
1 parent 08e496f642
commit c952ddf53f
2 files changed
+18 -14

No files matched your search

+7 -9
View File
@@ -2795,15 +2795,13 @@ class MainWindow(QMainWindow):
if self._remote_close_deadline_ts is not None:
self._clear_remote_close_request()
# Busy (or the robot station) means something is physically moving:
# show the Beamline combined view so the motion can be watched, and
# return to the sample camera once it is done. Edge-triggered so a
# manual tab choice survives between transitions. Sample alignment is
# the exception: its busy moves ARE the alignment, and the user needs
# to keep watching the sample camera, not the beamline view.
moving = (
bool(s.busy) or s.state == BeamlineStateEnum.RobotSampleExchange
) and s.state != BeamlineStateEnum.SampleAlignment
# Only robot-scale motion flips to the Beamline combined view: state
# transitions (the server parks in Moving while driving motors) and
# the robot station. Busy alone no longer triggers it — Sample
# alignment, Beam location, Beamstop alignment, Flux measurement
# etc. run busy while the user watches the sample camera itself.
# Edge-triggered so a manual tab choice survives between transitions.
moving = s.state in (BeamlineStateEnum.Moving, BeamlineStateEnum.RobotSampleExchange)
if moving and not self._watching_motion:
self._watching_motion = True
self.video_tab.setCurrentWidget(self.beamline_combined_panel)
+11 -5
View File
@@ -71,10 +71,10 @@ def test_main_window_init(qtbot, mock_ui_state, daq_status_factory):
win.data_collection._emit_change_energy()
assert sent and abs(sent[0] - 12400.0) < 1e-6
# Motion watch: robot motion switches to the combined beamline view;
# alignment beginning switches straight back to the sample camera even
# while the busy flag is still set — busy moves during Sample
# alignment ARE the alignment, so it never re-triggers the switch.
# Motion watch: only a state transition (Moving) or the robot station
# switches to the combined beamline view. Busy alone never does —
# Sample alignment, Beam location etc. run busy while the user
# watches the sample camera itself.
win.update_daq_status(
daq_status_factory(state=BeamlineStateEnum.RobotSampleExchange, busy=True)
)
@@ -85,10 +85,16 @@ def test_main_window_init(qtbot, mock_ui_state, daq_status_factory):
)
assert not win._watching_motion
assert win.video_tab.currentWidget() is win.sample_camera
win.update_daq_status(daq_status_factory(state=BeamlineStateEnum.BeamLocation, busy=True))
assert not win._watching_motion
win.update_daq_status(daq_status_factory(state=BeamlineStateEnum.Moving, busy=True))
assert win._watching_motion
assert win.video_tab.currentWidget() is win.beamline_combined_panel
win.update_daq_status(
daq_status_factory(state=BeamlineStateEnum.SampleAlignment, busy=True)
daq_status_factory(state=BeamlineStateEnum.DataCollection, busy=False)
)
assert not win._watching_motion
assert win.video_tab.currentWidget() is win.sample_camera
def test_main_window_mount_view(qtbot, mock_ui_state):