diff --git a/src/aare/beamline_dispatch/protocols.py b/src/aare/beamline_dispatch/protocols.py index e6f2e340..1d9b54cd 100644 --- a/src/aare/beamline_dispatch/protocols.py +++ b/src/aare/beamline_dispatch/protocols.py @@ -28,6 +28,9 @@ class BecMacros(ABC): @staticmethod @abstractmethod def mono_pitch_scan(plot=True): ... + @staticmethod + @abstractmethod + def auto_exposure(): ... class Geometry(ABC): diff --git a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py index f41434b4..f972a3dd 100644 --- a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py @@ -20,6 +20,7 @@ class X06daBecMacros(BecMacros): get_current_energy, mono_pitch_scan, ) + from pxiii_bec.macros.katscripts import auto_exposure # pyright: ignore[reportMissingImports, reportMissingModuleSource] self.save_and_reload = save_and_reload self.save_current_position = save_current_position @@ -31,6 +32,7 @@ class X06daBecMacros(BecMacros): self.bl_energy = _bl_energy self.get_current_energy = get_current_energy self.mono_pitch_scan = mono_pitch_scan + self.auto_exposure = auto_exposure @staticmethod def save_and_reload() -> tuple[Any, Any]: ... @@ -44,6 +46,8 @@ class X06daBecMacros(BecMacros): def get_current_energy(): ... @staticmethod def mono_pitch_scan(plot=True): ... + @staticmethod + def auto_exposure(): ... class X06daDispatch(DefaultDispatch): diff --git a/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py b/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py index c7cc2942..0ba67a41 100644 --- a/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py @@ -8,16 +8,17 @@ from aare.beamline_dispatch.protocols import BecMacros class X10SaBecMacros(BecMacros): def __init__(self) -> None: - from pxii_bec.macros.build_devices import ( # type: ignore + from pxii_bec.macros.build_devices import ( # pyright: ignore[reportMissingImports, reportMissingModuleSource] save_and_reload, save_current_position, ) - from pxii_bec.macros.init_beamline import init_beamline_environment # type: ignore - from pxii_bec.macros.pxii_energy import ( # type: ignore + from pxii_bec.macros.init_beamline import init_beamline_environment # pyright: ignore[reportMissingImports, reportMissingModuleSource] + from pxii_bec.macros.pxii_energy import ( # pyright: ignore[reportMissingImports, reportMissingModuleSource] bl_energy, get_current_energy, mono_pitch_scan, ) + from pxii_bec.macros.katscripts import auto_exposure # pyright: ignore[reportMissingImports, reportMissingModuleSource] self.save_and_reload = save_and_reload self.save_current_position = save_current_position @@ -25,6 +26,7 @@ class X10SaBecMacros(BecMacros): self.bl_energy = bl_energy self.get_current_energy = get_current_energy self.mono_pitch_scan = mono_pitch_scan + self.auto_exposure = auto_exposure @staticmethod def save_and_reload() -> tuple[Any, Any]: ... @@ -38,6 +40,8 @@ class X10SaBecMacros(BecMacros): def get_current_energy(): ... @staticmethod def mono_pitch_scan(plot=True): ... + @staticmethod + def auto_exposure(): ... class X10saDispatch(DefaultDispatch): diff --git a/src/aare/daq/daq.py b/src/aare/daq/daq.py index 5e90d291..60d785fd 100644 --- a/src/aare/daq/daq.py +++ b/src/aare/daq/daq.py @@ -17,6 +17,7 @@ from aarecommon.config.logger_events import ( sample_log_context, ) from aarecommon.errors.exception_handler import ( + AareException, AerotechCommunicationError, AutoRasterSampleSkipped, BeamlineBusyException, @@ -3471,7 +3472,13 @@ class AareDAQ: if "beam_steering" not in self._devs.bec_worker.dev: raise BECCommunicationError("Beam steering device does not exist in the BEC config.") self._cfg.try_set_busy(timeout=360) + try: + if not self.shutter: + raise AareException( + "Shutter not open! Please open the shutter before running beam steering." + ) + self._dispatch.bec_macros.auto_exposure() if x is not None: self._devs.bec_worker.dev.beam_steering.sample_loc_x_px.set(x).wait() if y is not None: