diff --git a/src/aare/beamline_dispatch/beamline_dispatch.py b/src/aare/beamline_dispatch/beamline_dispatch.py index 80e1bb47..0a0281c9 100644 --- a/src/aare/beamline_dispatch/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/beamline_dispatch.py @@ -13,7 +13,7 @@ def get_beamline_dispatch() -> BeamlineDispatch: case MXBeamline.X06DA: from .x06da import X06daDispatch - return X06daDispatch() + return X06daDispatch(MXBeamline.X06DA) case MXBeamline.X06SA: from .x06sa import X06saDispatch @@ -21,4 +21,4 @@ def get_beamline_dispatch() -> BeamlineDispatch: case MXBeamline.X10SA: from .x10sa import X10saDispatch - return X10saDispatch() + return X10saDispatch(MXBeamline.X10SA) diff --git a/src/aare/beamline_dispatch/default/beamline_dispatch.py b/src/aare/beamline_dispatch/default/beamline_dispatch.py index c432da92..f69d9ba9 100644 --- a/src/aare/beamline_dispatch/default/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/default/beamline_dispatch.py @@ -1,6 +1,9 @@ import os -from aare.beamline_dispatch.protocols import AuthDispatch, BeamlineDispatch +from aarecommon.config.beamline import MXBeamline +from aarecommon.models.beam_centre import BeamCentre + +from aare.beamline_dispatch.protocols import AuthDispatch, BeamlineDispatch, Geometry class DefaultAuthDispatch(AuthDispatch): @@ -12,13 +15,28 @@ class DefaultAuthDispatch(AuthDispatch): return key +class DefaultGeometry(Geometry): + def __init__(self, beamline: MXBeamline) -> None: + super().__init__() + self._model = BeamCentre + self._beamline = beamline + + @property + def beam_centre_model(self) -> BeamCentre: ... + + class DefaultDispatch(BeamlineDispatch): """Default implementation for anything which can vary between beamlines and/or simulation. Should be safe and fail rather than assuming anything.""" - def __init__(self) -> None: + def __init__(self, beamline: MXBeamline) -> None: self._auth = DefaultAuthDispatch() + self._geo = DefaultGeometry(beamline=beamline) @property def auth(self): return self._auth + + @property + def geo(self): + return self._geo diff --git a/src/aare/beamline_dispatch/protocols.py b/src/aare/beamline_dispatch/protocols.py index d0675a7a..4039009f 100644 --- a/src/aare/beamline_dispatch/protocols.py +++ b/src/aare/beamline_dispatch/protocols.py @@ -1,6 +1,8 @@ from abc import ABC, abstractmethod from typing import Any +from aarecommon.models.beam_centre import BeamCentre + class AuthDispatch(ABC): @abstractmethod @@ -28,6 +30,12 @@ class BecMacros(ABC): def mono_pitch_scan(plot=True): ... +class Geometry(ABC): + @property + @abstractmethod + def beam_centre_model(self) -> BeamCentre: ... + + class BeamlineDispatch(ABC): @property @abstractmethod @@ -35,3 +43,6 @@ class BeamlineDispatch(ABC): @property @abstractmethod def bec_macros(self) -> BecMacros: ... + @property + @abstractmethod + def geo(self) -> Geometry: ... diff --git a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py index da0dbb87..f41434b4 100644 --- a/src/aare/beamline_dispatch/x06da/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/x06da/beamline_dispatch.py @@ -1,5 +1,7 @@ from typing import Any +from aarecommon.config.beamline import MXBeamline + from aare.beamline_dispatch.default.beamline_dispatch import DefaultDispatch from aare.beamline_dispatch.protocols import BecMacros @@ -45,8 +47,8 @@ class X06daBecMacros(BecMacros): class X06daDispatch(DefaultDispatch): - def __init__(self) -> None: - super().__init__() + def __init__(self, beamline: MXBeamline) -> None: + super().__init__(beamline=beamline) self._bec_macros = X06daBecMacros() @property diff --git a/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py b/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py index 380513cb..c7cc2942 100644 --- a/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py +++ b/src/aare/beamline_dispatch/x10sa/beamline_dispatch.py @@ -1,5 +1,7 @@ from typing import Any +from aarecommon.config.beamline import MXBeamline + from aare.beamline_dispatch.default.beamline_dispatch import DefaultDispatch from aare.beamline_dispatch.protocols import BecMacros @@ -39,8 +41,8 @@ class X10SaBecMacros(BecMacros): class X10saDispatch(DefaultDispatch): - def __init__(self) -> None: - super().__init__() + def __init__(self, beamline: MXBeamline) -> None: + super().__init__(beamline=beamline) self._bec_macros = X10SaBecMacros() @property