From db8460c51e3afc2b7d2601a1b7e7a63538f7522d Mon Sep 17 00:00:00 2001 From: appleb_m Date: Fri, 22 May 2026 18:06:20 +0200 Subject: [PATCH] gui: added checks to sample queue panel, should be centralised in the future --- src/aare/gui/panels/sample_queue_panel.py | 43 ++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/aare/gui/panels/sample_queue_panel.py b/src/aare/gui/panels/sample_queue_panel.py index 4ae7550d..4495569c 100644 --- a/src/aare/gui/panels/sample_queue_panel.py +++ b/src/aare/gui/panels/sample_queue_panel.py @@ -2,7 +2,7 @@ from PySide6.QtCore import Signal, Slot, Qt, QTimer from PySide6.QtWidgets import QFrame, QVBoxLayout, QHBoxLayout, QPushButton, QHeaderView, QSizePolicy, \ QTableView, QMessageBox, QCheckBox from PySide6.QtGui import QKeySequence, QShortcut -from aare.common.models import SampleShortInfoList, SampleShortInfo, BeamlineStateEnum +from aare.common.models import SampleShortInfoList, SampleShortInfo, BeamlineStateEnum, SessionsStateEnum from aare.gui.models.sample_queue_model import SampleQueueSpreadsheet from aare.gui.widgets.message_box import ring_current_low_check, experiment_hutch_shutter_check, LOW_CURRENT_THRESHOLD, \ @@ -26,6 +26,8 @@ class SampleQueuePanel(QFrame): def __init__(self, parent=None, samples: SampleShortInfoList | None = None): super().__init__(parent) + self.__baton_holder = None + self.__busy = None self.__beamline_state = None self.__pause = True self.__set_to_pause = False @@ -198,6 +200,43 @@ class SampleQueuePanel(QFrame): info="Please change the state at the bottom of the menu") return + if self.__busy: + self.show_error_dialog( + title="Beamline is busy", + msg="Cannot run automation while beamline is busy", + info="Please wait until beamline is idle " + "or contact your local contact for support" + ) + return + + if self.__baton_holder is SessionsStateEnum.Vacant: + self.show_error_dialog( + title="Session is vacant", + msg="Starting automation while session is vacant is not currently implemented", + info="Please grab the baton before continuing " + "or contact your local contact for support" + ) + return + + elif self.__baton_holder is not SessionsStateEnum.OwnedByYou: + self.show_error_dialog( + title="You do not hold the baton", + msg="You do not hold the baton.", + info="Please request the baton if it is your shift." + "If your baton request is denied and it should be the start of your shift," + "please contact your local contact for support" + ) + return + + if self.__beamline_state is BeamlineStateEnum.Maintenance: + self.show_error_dialog( + title="Maintenance mode", + msg="Cannot run automation while beamline is in maintenance mode", + info=("Change to safe state such as Sample Exchange before trying to continue. " + "If this issue persists please contact your local contact for support."), + ) + return + if self.__pause: if len(self.table_model.samples) > 0: if CHECK_ENABLED: @@ -235,6 +274,8 @@ class SampleQueuePanel(QFrame): self.ring_current = s.bl.ring_current_mA self._experiment_shutter_state = s.bl.exp_shutter_open self.__beamline_state = s.state + self.__busy = s.busy + self.__baton_holder = s.session.session def pause_automation(self, set_id_to_None: bool = True): self.table_model.set_running(False)