GUI: connected smart_rotation_panel.py to main_window.py and data_collection_settings.py. Updated payload and values in smart_rotation_panel.py.

This commit is contained in:
2025-10-01 17:12:25 +02:00
parent 34b614a166
commit 3a24fc2aa1
3 changed files with 54 additions and 15 deletions
+1
View File
@@ -227,6 +227,7 @@ class MainWindow(QMainWindow):
self.raster.grid_scan.connect(self.daq.raster_scan)
self.raster.grid_scan_auto.connect(self.daq.raster_scan_auto)
self.data_collection.screening.rotation_scan.connect(self.daq.standard_scan)
self.data_collection.simple.rotation_scan.connect(self.daq.standard_scan)
self.raster.grid_scan_size_changed.connect(self.data_collection.raster.grid_scan_size_change)
self.status_bar.set_pgroup.connect(self.daq.set_pgroup)
@@ -60,8 +60,11 @@ class DataCollectionSettings(QFrame):
raster_mgr.update_filename(self.file_path_panel.filename)
self.screening.update_filename(self.file_path_panel.filename)
self.simple.update_filename(self.file_path_panel.filename)
self.file_path_panel.path_updated.connect(raster_mgr.update_filename)
self.file_path_panel.path_updated.connect(self.screening.update_filename)
self.file_path_panel.path_updated.connect(self.simple.update_filename)
self.__sample_id = None
@Slot()
+50 -15
View File
@@ -1,14 +1,25 @@
from PySide6.QtCore import Slot, Qt
from PySide6.QtCore import Slot, Qt, Signal
from PySide6.QtWidgets import QWidget, QGridLayout, QLabel, QFrame, QPushButton, QSpacerItem, QSizePolicy
from aaredaqlib.models import DAQStatusModel
from aaredaqlib.rotation_scan import RotationScanRequest
from aaregui.widgets.number_line_edit import NumberLineEdit
class SimpleRotationSettingsPanel(QWidget):
rotation_scan = Signal(RotationScanRequest)
viewer_track_online = Signal()
def __init__(self, parent=None):
super().__init__(parent)
self._filename = ""
self.dtz = 120
self.n_images = None
self.transmission = 1.0
self.image_time_s = None
self.image_angle = 0.2
self.__d = None
self._layout = QGridLayout(self)
@@ -73,12 +84,22 @@ class SimpleRotationSettingsPanel(QWidget):
@Slot(DAQStatusModel)
def update_daq_status(self, s: DAQStatusModel):
self.__d = s
best = getattr(s, "last_best_res", None)
if best is not None:
# clamp to control limits and update field; this will also trigger recalculation
lo, hi = 0.8, 10.0
v = max(lo, min(hi, float(best)))
self.visible_res_enter.update_value(v)
self.set_visible_resolution(v)
self.update_calculated_labels()
@Slot(float)
def set_visible_resolution(self, v: float):
self.update_calculated_labels()
@Slot(str)
def update_filename(self, filename: str):
self._filename = filename
def update_calculated_labels(self):
if self.__d is None:
@@ -94,24 +115,38 @@ class SimpleRotationSettingsPanel(QWidget):
dose_rate_MGy_s = (flux / (self.__d.geom.beam_size_mm.x * 1000 * self.__d.geom.beam_size_mm.y * 1000 * Kdose)) / 1e6
target_dose_MGy = 10 * d_tar / 2.0
total_time_s = target_dose_MGy / dose_rate_MGy_s
image_angle = 0.2
self.image_angle_label.setText(f"{image_angle:.3f}")
nimages = total_angle / image_angle
image_time_s = total_time_s / nimages
if image_time_s < 0.01:
transmission = image_time_s / 0.01
self.image_angle = 0.2
self.image_angle_label.setText(f"{self.image_angle:.3f}")
self.n_images = total_angle / self.image_angle
self.image_time_s = total_time_s / self.n_images
if self.image_time_s < 0.01:
self.transmission = self.image_time_s / 0.01
image_time_s = 0.01
else:
transmission = 1.0
self.transmission = 1.0
dtz = self.__d.diffraction.calc_dtz_mm(d_tar)
self.dtz = self.__d.diffraction.calc_dtz_mm(d_tar)
self.transmission_label.setText(f"{transmission * 100:.1f}")
self.image_time_label.setText(f"{image_time_s:.4f}")
self.transmission_label.setText(f"{self.transmission * 100:.1f}")
self.image_time_label.setText(f"{self.image_time_s:.4f}")
if dtz <= 0.0:
if self.dtz <= 0.0:
self.dtz_label.setText(f"""<span style="color: red ; ">-</span>""")
elif dtz < self.__d.bl.dtz_min:
self.dtz_label.setText(f"""<span style="color: red ; ">{dtz:.2f}</span>""")
elif self.dtz < self.__d.bl.dtz_min:
self.dtz_label.setText(f"""<span style="color: red ; ">{self.dtz:.2f}</span>""")
else:
self.dtz_label.setText(f"{dtz:.2f}")
self.dtz_label.setText(f"{self.dtz:.2f}")
@Slot()
def run_measurement(self):
r = RotationScanRequest(
file_prefix=self._filename,
start_omega_deg=0,#,self.start_angle.value,
steps=self.n_images,
incr_omega_deg=self.image_angle,
dtz=self.dtz,
transmission=self.transmission,
screening=False,
exp_time_s=self.image_time_s)
self.rotation_scan.emit(r)
self.viewer_track_online.emit()