GUI: added detector status to data colelciton panel
This commit is contained in:
@@ -6,7 +6,7 @@ from PySide6.QtWidgets import (
|
||||
QGridLayout,
|
||||
QPushButton,
|
||||
QWidget,
|
||||
QProgressBar, QMessageBox,
|
||||
QProgressBar, QMessageBox, QLabel,
|
||||
)
|
||||
|
||||
from aaredaqlib.diffraction_geometry import DiffractionGeometry
|
||||
@@ -66,6 +66,14 @@ class DataCollectionSettings(QFrame):
|
||||
self.progress_bar.setStyleSheet("background-color: rgb(255, 255, 255);")
|
||||
v_layout.addWidget(self.progress_bar)
|
||||
|
||||
self.detector_state = QLabel(self)
|
||||
self.detector_state.setText("Detector state: <b>Idle</b>")
|
||||
v_layout.addWidget(self.detector_state)
|
||||
|
||||
self.detector_message = QLabel(self)
|
||||
self.detector_message.setText("Detector message: <b>''</b>")
|
||||
v_layout.addWidget(self.detector_message)
|
||||
|
||||
abort_button = QPushButton("Abort measurement", parent=self)
|
||||
abort_button.setStyleSheet("color: rgb(164, 0, 0);")
|
||||
abort_button.clicked.connect(self.cancel_button_clicked)
|
||||
@@ -103,6 +111,39 @@ class DataCollectionSettings(QFrame):
|
||||
jfjoch_status = s.jfjoch_status
|
||||
progress = getattr(jfjoch_status, "progress", None)
|
||||
|
||||
#states are Enum: "Idle" "Waiting" "Busy" "Error" "Not connected"
|
||||
#message serverity is Enum: "success" "info" "warning" "error"
|
||||
#messagge is string
|
||||
#progress is float from 0 to 1
|
||||
|
||||
if (jfjoch_status.message_severity == "error" or jfjoch_status.state == "Error"
|
||||
or jfjoch_status.state == "Not connected"):
|
||||
self.detector_message.setStyleSheet("color: rgb(164, 0, 0);")
|
||||
self.detector_state.setStyleSheet("color: rgb(164, 0, 0);")
|
||||
elif jfjoch_status.message_severity == "warning":
|
||||
self.detector_message.setStyleSheet("color: rgb(255, 165, 0);")
|
||||
elif jfjoch_status.message_severity == "success":
|
||||
self.detector_message.setStyleSheet("color: rgb(0, 128, 0);")
|
||||
elif jfjoch_status.message_severity == "info":
|
||||
self.detector_message.setStyleSheet("color: rgb(0, 0, 255);")
|
||||
else:
|
||||
self.detector_message.setStyleSheet("color: rgb(0, 0, 255);")
|
||||
|
||||
if (jfjoch_status.state == "Busy" or
|
||||
jfjoch_status.state == "Measuring" or jfjoch_status.state == "Pedestal"):
|
||||
self.detector_state.setStyleSheet("color: rgb(255, 165, 0);")
|
||||
elif jfjoch_status.state == "waiting":
|
||||
self.detector_state.setStyleSheet("color: rgb(255, 165, 0);")
|
||||
elif jfjoch_status.state == "Idle":
|
||||
self.detector_state.setStyleSheet("color: rgb(0, 0, 255);")
|
||||
self.progress_bar.setVisible(False)
|
||||
else:
|
||||
self.detector_state.setStyleSheet("color: rgb(0, 0, 255);")
|
||||
logger.debug(f"unknown detector state {jfjoch_status.state}")
|
||||
|
||||
self.detector_state.setText(f"Detector state: <b>{jfjoch_status.state}</b>")
|
||||
self.detector_message.setText(f"Detector message: <b>{jfjoch_status.message}</b>")
|
||||
|
||||
if progress:
|
||||
if not self.progress_bar.isVisible():
|
||||
self.progress_bar.setVisible(True)
|
||||
@@ -114,12 +155,6 @@ class DataCollectionSettings(QFrame):
|
||||
else:
|
||||
self.progress_bar.setVisible(False)
|
||||
|
||||
#states are Enum: "Idle" "Waiting" "Busy" "Error" "Not connected"
|
||||
#message serverity is Enum: "success" "info" "warning" "error"
|
||||
#messagge is string
|
||||
#progress is float from 0 to 1
|
||||
if jfjoch_status.state == "Error":
|
||||
QMessageBox.critical(self, "Error", jfjoch_status.message)
|
||||
|
||||
|
||||
@Slot(int)
|
||||
|
||||
@@ -93,4 +93,27 @@ def ring_current_auto_check(parent, ring_current, check_func) -> bool:
|
||||
loop.exec() # returns as soon as box finishes without blocking UI processing of its signals
|
||||
|
||||
result = box.result()
|
||||
return result == QMessageBox.StandardButton.Yes
|
||||
return result == QMessageBox.StandardButton.Yes
|
||||
|
||||
def detector_status_check(parent, jfjoch_status) -> bool:
|
||||
if jfjoch_status.state == "Idle":
|
||||
return True
|
||||
elif jfjoch_status.state == "Inactive":
|
||||
QMessageBox.warning(parent, "Detector Inactive", f"Please initialise detector from JFJoch Control Panel."
|
||||
f"Message: {jfjoch_status.message}")
|
||||
elif jfjoch_status.state == "Busy":
|
||||
QMessageBox.warning(parent, "Detector busy", f"Dector in Busy State, please check JFJoch Control Panel.\n"
|
||||
f" Detector Message: {jfjoch_status.message}")
|
||||
elif jfjoch_status.state == "Measuring" or jfjoch_status.state == "Pedestal":
|
||||
QMessageBox.warning(parent, "Detector measuring", f"Detector measuring, please wait.\n"
|
||||
f"State:{jfjoch_status.state}\n"
|
||||
f"Message: {jfjoch_status.message}")
|
||||
elif jfjoch_status.state == "Error":
|
||||
QMessageBox.critical(parent, "Detector error", f"Detector in Error State, please check JFJoch Control Panel.\n"
|
||||
f"Detector status: {jfjoch_status.state}\n"
|
||||
f"Message: {jfjoch_status.message}\n")
|
||||
else:
|
||||
QMessageBox.warning(parent, "unkwown state", f"State:{jfjoch_status.state}\n"
|
||||
f"Message: {jfjoch_status.message}\n"
|
||||
f"Please Check JFJoch Control Panel.")
|
||||
return False
|
||||
Reference in New Issue
Block a user