DAQ/GUI: added jfjoch_status to daq for progress bar in GUI

This commit is contained in:
2025-12-02 13:34:23 +01:00
parent 4d068a49f9
commit 2142097ce6
4 changed files with 39 additions and 3 deletions
@@ -6,6 +6,7 @@ from PySide6.QtWidgets import (
QGridLayout,
QPushButton,
QWidget,
QProgressBar, QMessageBox,
)
from aaredaqlib.diffraction_geometry import DiffractionGeometry
@@ -21,6 +22,9 @@ from aaregui.panels.smart_rotation_panel import SimpleRotationSettingsPanel
from aaregui.scan_logic.raster_grid_manager import RasterGridManager
from aaregui.widgets.title_label import TitleLabel
from aaredaqlib.logger_config import setup_logger
logger = setup_logger("aareGUI")
class DataCollectionSettings(QFrame):
cancel = Signal()
@@ -57,6 +61,11 @@ class DataCollectionSettings(QFrame):
v_layout.addWidget(self.__tab_widget)
v_layout.addStretch()
self.progress_bar = QProgressBar(self)
self.progress_bar.setRange(0, 100)
self.progress_bar.setStyleSheet("background-color: rgb(255, 255, 255);")
v_layout.addWidget(self.progress_bar)
abort_button = QPushButton("Abort measurement", parent=self)
abort_button.setStyleSheet("color: rgb(164, 0, 0);")
abort_button.clicked.connect(self.cancel_button_clicked)
@@ -74,8 +83,6 @@ class DataCollectionSettings(QFrame):
self.__tab_widget.currentChanged.connect(self._on_tab_changed)
# ... existing code ...
@Slot()
def switch_to_raster(self):
self.__tab_widget.setCurrentIndex(0)
@@ -93,6 +100,28 @@ class DataCollectionSettings(QFrame):
self.__sample_id = s.sample.db_id
self.__tab_widget.setCurrentIndex(0)
jfjoch_status = s.jfjoch_status
progress = getattr(jfjoch_status, "progress", None)
if progress:
if not self.progress_bar.isVisible():
self.progress_bar.setVisible(True)
try:
p = int(max(0, min(100, round(100*progress, 2))))
self.progress_bar.setValue(p)
except Exception as e:
logger.error(f"Failed to update progress bar: {e}")
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)
def _on_tab_changed(self, idx: int):
# 0: Raster, 1: Rotation (incl. screening), 2: Simple (rotation wrapper), 3: XRF (ignore)