diff --git a/src/aare/gui/panels/data_collection_settings.py b/src/aare/gui/panels/data_collection_settings.py index 7266597e..b3a57737 100644 --- a/src/aare/gui/panels/data_collection_settings.py +++ b/src/aare/gui/panels/data_collection_settings.py @@ -19,6 +19,7 @@ from PySide6.QtWidgets import ( from aare.gui.panels.file_path_panel import FilePathPanel from aare.gui.panels.fluorescence_data_collection import FluorescenceDataCollectionPanel from aare.gui.panels.manual_sample_panel import ManualSamplePanel +from aare.gui.panels.monochromator_panel import ENERGY_MAX_KEV, ENERGY_MIN_KEV, ENERGY_RANGE_TIP from aare.gui.panels.raster_data_collection import RasterDataCollectionPanel from aare.gui.panels.rotation_data_collection import RotationDataCollectionPanel from aare.gui.panels.smart_rotation_panel import SimpleRotationSettingsPanel @@ -111,7 +112,8 @@ class DataCollectionSettings(QFrame): # 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.setRange(ENERGY_MIN_KEV, ENERGY_MAX_KEV) + self.energy_spin.setToolTip(ENERGY_RANGE_TIP) self.energy_spin.setSingleStep(0.1) self.energy_spin.setValue(12.0) # Pending color (same movestate QSS as the value fields) from edit diff --git a/src/aare/gui/panels/monochromator_panel.py b/src/aare/gui/panels/monochromator_panel.py index 58bbcf33..15710743 100644 --- a/src/aare/gui/panels/monochromator_panel.py +++ b/src/aare/gui/panels/monochromator_panel.py @@ -5,6 +5,16 @@ from PySide6.QtWidgets import QDoubleSpinBox, QGridLayout, QLabel, QPushButton, from aare.gui.styles import THEME_SUNRISE, status_colors from aare.gui.widgets.title_label import TitleLabel +# TODO: placeholder range (was an arbitrary 1-30; nothing downstream validates — +# daq.change_energy forwards straight to bec) — confirm the real monochromator +# limits with the Beamline Scientist. Shared by both Set Energy rows. +ENERGY_MIN_KEV = 4.0 +ENERGY_MAX_KEV = 20.0 +ENERGY_RANGE_TIP = ( + f"Minimum: {ENERGY_MIN_KEV:.3f} keV\nMaximum: {ENERGY_MAX_KEV:.3f} keV\n" + "Range to be confirmed with Beamline Scientist" +) + class MonochromatorPanel(QWidget): mono_pitch_scan = Signal() @@ -43,7 +53,8 @@ class MonochromatorPanel(QWidget): self.energy_spin = QDoubleSpinBox(parent=self) self.energy_spin.setDecimals(3) - self.energy_spin.setRange(1.0, 30.0) + self.energy_spin.setRange(ENERGY_MIN_KEV, ENERGY_MAX_KEV) + self.energy_spin.setToolTip(ENERGY_RANGE_TIP) self.energy_spin.setSingleStep(0.1) self.energy_spin.setValue(12.0) grid_layout.addWidget(self.energy_spin, 3, 1) diff --git a/tests/unit/gui/test_data_collection_settings.py b/tests/unit/gui/test_data_collection_settings.py index 6e59b889..7d400c4e 100644 --- a/tests/unit/gui/test_data_collection_settings.py +++ b/tests/unit/gui/test_data_collection_settings.py @@ -351,6 +351,11 @@ def test_db_override_source_toggle_clears_pending(qapp, qtbot): def test_energy_spin_pending_until_change_energy(settings_panel): + # same placeholder limits as the Beamline setup row (shared constants) + assert settings_panel.energy_spin.minimum() == 4.0 + assert settings_panel.energy_spin.maximum() == 20.0 + assert "Beamline Scientist" in settings_panel.energy_spin.toolTip() + box = settings_panel.energy_spin.lineEdit() settings_panel.energy_spin.setValue(12.4) assert box.property("movestate") == "pending" diff --git a/tests/unit/gui/test_monochromator_panel.py b/tests/unit/gui/test_monochromator_panel.py index dabd2d2a..5c4bf1f5 100644 --- a/tests/unit/gui/test_monochromator_panel.py +++ b/tests/unit/gui/test_monochromator_panel.py @@ -36,3 +36,13 @@ def test_fast_shutter_row(qtbot, daq_status_factory): panel.open_shutter_button.click() with qtbot.waitSignal(panel.close_shutter, timeout=1000): panel.close_shutter_button.click() + + +def test_energy_spin_placeholder_limits(qtbot): + # 4-20 keV is a placeholder pending Beamline Scientist confirmation; the + # tooltip must say so because nothing downstream validates the request. + panel = MonochromatorPanel() + qtbot.addWidget(panel) + assert panel.energy_spin.minimum() == 4.0 + assert panel.energy_spin.maximum() == 20.0 + assert "Beamline Scientist" in panel.energy_spin.toolTip()