feat: add Change Energy row to experiment configuration

Copy of the Beamline Setup energy row (keV display, eV emit), placed
below the ML Loop Centring / Make Raster Grid row and always visible.
Wired to the same daq.change_energy; not staff-gated, server enforces
write permission.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
duan_jandClaude Fable 5 committed 2026-08-13 11:46:44 +02:00
1 parent 252e08384d
commit c618354c01
2 files changed
+29

No files matched your search

+4
View File
@@ -925,6 +925,10 @@ class MainWindow(QMainWindow):
self.beamline.illumination_panel.front_light.connect(self.daq.front_light)
self.beamline.illumination_panel.back_light.connect(self.daq.back_light)
# Energy row inside Exp. Config. — not staff-gated like the Beamline
# Setup copy; the server enforces write permission anyway.
self.data_collection.change_energy.connect(self.daq.change_energy)
if self._decoded_token.staff:
self.monochromator_panel.mono_pitch_scan.connect(self.daq.mono_pitch_scan)
self.monochromator_panel.change_energy.connect(self.daq.change_energy)
@@ -3,8 +3,10 @@ from aarecommon.math.sample_geometry import SampleGeometryModel
from aarecommon.models.models import DAQStatusModel
from PySide6.QtCore import Signal, Slot
from PySide6.QtWidgets import (
QDoubleSpinBox,
QFrame,
QHBoxLayout,
QLabel,
QPushButton,
QSizePolicy,
QStackedWidget,
@@ -26,6 +28,8 @@ from aare.gui.widgets.title_label import TitleLabel, tighten_column
class DataCollectionSettings(QFrame):
cancel = Signal()
# Same convention as the Beamline Setup panel: keV in the GUI, eV on emit.
change_energy = Signal(float)
set_width = 400
@@ -81,6 +85,22 @@ class DataCollectionSettings(QFrame):
centering_layout.addWidget(self.find_tip)
centering_layout.addWidget(self.bounding_box)
# Energy row copied from the Beamline Setup panel so users can change
# energy without leaving the experiment configuration.
self.energy_spin = QDoubleSpinBox(parent=self)
self.energy_spin.setDecimals(3)
self.energy_spin.setRange(1.0, 30.0)
self.energy_spin.setSingleStep(0.1)
self.energy_spin.setValue(12.0)
self.change_energy_button = QPushButton("Change Energy", parent=self)
self.change_energy_button.clicked.connect(self._emit_change_energy)
energy_row = QWidget(self)
energy_layout = QHBoxLayout(energy_row)
energy_layout.setContentsMargins(0, 0, 0, 0)
energy_layout.addWidget(QLabel("Energy (keV)", parent=energy_row))
energy_layout.addWidget(self.energy_spin)
energy_layout.addWidget(self.change_energy_button)
# Pane frame carries the border QTabWidget::pane used to draw
# (#expConfigPane rule in styles.py).
pane = QFrame(self)
@@ -90,6 +110,7 @@ class DataCollectionSettings(QFrame):
# border, and the Abort button should hug the pane.
pane_layout.setContentsMargins(6, 6, 6, 0)
pane_layout.addWidget(centering_row)
pane_layout.addWidget(energy_row)
pane_layout.addWidget(self._stack)
# Own container: TitleLabel collapse hides its siblings, so without it
@@ -147,6 +168,10 @@ class DataCollectionSettings(QFrame):
page.setSizePolicy(QSizePolicy.Policy.Preferred, vertical)
self._stack.adjustSize()
@Slot()
def _emit_change_energy(self):
self.change_energy.emit(float(self.energy_spin.value()) * 1000.0)
@Slot()
def switch_to_raster(self):
self._tab_bar.setCurrentIndex(0)