diff --git a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py index 7aab4be3..da0dbb87 100644 --- a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py @@ -1,4 +1,54 @@ +from typing import Any + from aare.beamline_dispatch.default.beamline_dispatch import DefaultDispatch +from aare.beamline_dispatch.protocols import BecMacros -class X06daDispatch(DefaultDispatch): ... +class X06daBecMacros(BecMacros): + def __init__(self) -> None: + from pxiii_bec.macros.build_devices import ( # pyright: ignore[reportMissingImports, reportMissingModuleSource] + save_and_reload, + save_current_position, + ) + from pxiii_bec.macros.init_beamline import ( # pyright: ignore[reportMissingImports, reportMissingModuleSource] + init_beamline_environment, + ) + from pxiii_bec.macros.pxiii_energy import ( # pyright: ignore[reportMissingImports, reportMissingModuleSource] + bl_energy, + get_current_energy, + mono_pitch_scan, + ) + + self.save_and_reload = save_and_reload + self.save_current_position = save_current_position + self.init_beamline_environment = init_beamline_environment + + def _bl_energy(energy_ev, move_gap=True, mono_scan=True, plot=True): + return bl_energy(energy_ev=energy_ev, plot=plot) + + self.bl_energy = _bl_energy + self.get_current_energy = get_current_energy + self.mono_pitch_scan = mono_pitch_scan + + @staticmethod + def save_and_reload() -> tuple[Any, Any]: ... + @staticmethod + def save_current_position(device, position, axis=None, force=False, max_delta=0.5) -> None: ... + @staticmethod + def init_beamline_environment() -> tuple[Any, Any]: ... + @staticmethod + def bl_energy(energy_ev, move_gap=True, mono_scan=True, plot=True): ... + @staticmethod + def get_current_energy(): ... + @staticmethod + def mono_pitch_scan(plot=True): ... + + +class X06daDispatch(DefaultDispatch): + def __init__(self) -> None: + super().__init__() + self._bec_macros = X06daBecMacros() + + @property + def bec_macros(self) -> BecMacros: + return self._bec_macros diff --git a/tests/unit/utils/test_beamline_dispatch.py b/tests/unit/utils/test_beamline_dispatch.py index 8feadae6..0aa48866 100644 --- a/tests/unit/utils/test_beamline_dispatch.py +++ b/tests/unit/utils/test_beamline_dispatch.py @@ -5,6 +5,7 @@ import pytest from aare.beamline_dispatch.beamline_dispatch import get_beamline_dispatch from aare.beamline_dispatch.simulated import SimulatedDispatch +from aare.beamline_dispatch.x06da import X06daDispatch from aare.beamline_dispatch.x10sa import X10saDispatch @@ -40,6 +41,6 @@ def test_pxii_dispatch_can_be_instantiated(): importlib.util.find_spec("pxiii_bec") is None, reason="run only for pxiii flavour" ) def test_pxiii_dispatch_can_be_instantiated(): - with patch.dict("os.environ", {"BEAMLINE": "X06DA"}), pytest.raises(TypeError) as e: - _ = get_beamline_dispatch() - assert e.match("Can't instantiate abstract class") + with patch.dict("os.environ", {"BEAMLINE": "X06DA"}): + dispatch = get_beamline_dispatch() + assert isinstance(dispatch, X06daDispatch)