GUI: Show only available transitions
This commit is contained in:
1 parent
41f10aef22
commit
20e9a4d5ed
1 file changed
+36
-8
@@ -1,4 +1,5 @@
|
||||
from PySide6.QtCore import Signal, Slot, QPoint
|
||||
from PySide6.QtGui import QFont
|
||||
from PySide6.QtWidgets import QStatusBar, QDialog, QMenu, QLabel
|
||||
|
||||
from aaredaqlib.models import TokenData, BeamlineStateEnum, DAQStatusModel, SessionsStateEnum
|
||||
@@ -22,6 +23,7 @@ class StatusBar(QStatusBar):
|
||||
def __init__(self, token: TokenData, parent=None):
|
||||
super().__init__(parent)
|
||||
self.__decoded_token = token
|
||||
self.__status = None
|
||||
|
||||
self.flux = ValueLabel("Flux", "x 10<sup>9</sup> ph/s", self)
|
||||
self.transmission = ValueLabel("Transmission", "", self)
|
||||
@@ -57,6 +59,7 @@ class StatusBar(QStatusBar):
|
||||
|
||||
@Slot(DAQStatusModel)
|
||||
def update_daq_status(self, status: DAQStatusModel):
|
||||
self.__status = status
|
||||
if status.bl.flux_ph_s is None:
|
||||
self.flux.set_value(f"0")
|
||||
else:
|
||||
@@ -178,16 +181,41 @@ class StatusBar(QStatusBar):
|
||||
menu.exec()
|
||||
|
||||
def show_state_menu(self):
|
||||
if self.__status is None:
|
||||
return
|
||||
|
||||
print(self.__status.state)
|
||||
menu = QMenu(self)
|
||||
|
||||
action_2 = menu.addAction("Sample exchange")
|
||||
action_2.triggered.connect(self.se)
|
||||
action_1 = menu.addAction("Sample alignment")
|
||||
action_1.triggered.connect(self.sa)
|
||||
action_3 = menu.addAction("Dewar transfer")
|
||||
action_3.triggered.connect(self.dl)
|
||||
action_4 = menu.addAction("Beam location")
|
||||
action_4.triggered.connect(self.beam_location)
|
||||
if self.__status.busy or self.__status.state in [BeamlineStateEnum.Moving]:
|
||||
return
|
||||
|
||||
action_0 = menu.addAction("Available transitions")
|
||||
font = QFont()
|
||||
font.setBold(True)
|
||||
action_0.setFont(font)
|
||||
# Optionally make it non-clickable since it's a header
|
||||
action_0.setEnabled(False)
|
||||
menu.addSeparator()
|
||||
|
||||
if self.__status.state in [BeamlineStateEnum.RobotSampleExchange,
|
||||
BeamlineStateEnum.SampleExchange,
|
||||
BeamlineStateEnum.DewarTransfer,
|
||||
BeamlineStateEnum.BeamLocation,
|
||||
BeamlineStateEnum.DataCollection,
|
||||
BeamlineStateEnum.XrayFluorescence]:
|
||||
action_1 = menu.addAction("Sample alignment")
|
||||
action_1.triggered.connect(self.sa)
|
||||
elif self.__status.state in [BeamlineStateEnum.SampleAlignment, ]:
|
||||
action_2 = menu.addAction("Manual sample exchange")
|
||||
action_2.triggered.connect(self.se)
|
||||
action_3 = menu.addAction("Dewar transfer")
|
||||
action_3.triggered.connect(self.dl)
|
||||
action_4 = menu.addAction("Beam location")
|
||||
action_4.triggered.connect(self.beam_location)
|
||||
elif self.__status.state in [BeamlineStateEnum.Maintenance, ]:
|
||||
action_2 = menu.addAction("Manual sample exchange")
|
||||
action_2.triggered.connect(self.se)
|
||||
|
||||
label_geometry = self.state_label.geometry()
|
||||
menu.move(self.mapToGlobal(label_geometry.topLeft()) - QPoint(0, menu.sizeHint().height()))
|
||||
|
||||
Reference in new issue
Block a user