Skip to content

Commit

Permalink
ApertureScatterguard now set using a well defined enum (#755)
Browse files Browse the repository at this point in the history
* ApertureScatterguard now set using a well defined enum

* Remove unused method

* Fix device instantiation for 3.10

* Add function to get GDA name aperture name
  • Loading branch information
DominicOram authored Aug 20, 2024
1 parent 696ccf0 commit b39f55c
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 298 deletions.
19 changes: 10 additions & 9 deletions src/dodal/beamlines/i03.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from ophyd_async.panda import HDFPanda

from dodal.common.beamlines.beamline_parameters import get_beamline_parameters
from dodal.common.beamlines.beamline_utils import (
device_instantiation,
get_directory_provider,
set_directory_provider,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.udc_directory_provider import PandASubdirectoryProvider
from dodal.devices.aperturescatterguard import AperturePositions, ApertureScatterguard
from dodal.devices.aperturescatterguard import (
ApertureScatterguard,
load_positions_from_beamline_parameters,
load_tolerances_from_beamline_params,
)
from dodal.devices.attenuator import Attenuator
from dodal.devices.backlight import Backlight
from dodal.devices.cryostream import CryoStream
Expand Down Expand Up @@ -53,24 +58,20 @@
def aperture_scatterguard(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
aperture_positions: AperturePositions | None = None,
) -> ApertureScatterguard:
"""Get the i03 aperture and scatterguard device, instantiate it if it hasn't already
been. If this is called when already instantiated in i03, it will return the existing
object. If aperture_positions is specified, it will update them.
object.
"""

def load_positions(a_s: ApertureScatterguard):
if aperture_positions is not None:
a_s.load_aperture_positions(aperture_positions)

params = get_beamline_parameters()
return device_instantiation(
device_factory=ApertureScatterguard,
name="aperture_scatterguard",
prefix="",
wait=wait_for_connection,
fake=fake_with_ophyd_sim,
post_create=load_positions,
loaded_positions=load_positions_from_beamline_parameters(params),
tolerances=load_tolerances_from_beamline_params(params),
)


Expand Down
19 changes: 10 additions & 9 deletions src/dodal/beamlines/i04.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from dodal.common.beamlines.beamline_parameters import get_beamline_parameters
from dodal.common.beamlines.beamline_utils import device_instantiation
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.devices.aperturescatterguard import AperturePositions, ApertureScatterguard
from dodal.devices.aperturescatterguard import (
ApertureScatterguard,
load_positions_from_beamline_parameters,
load_tolerances_from_beamline_params,
)
from dodal.devices.attenuator import Attenuator
from dodal.devices.backlight import Backlight
from dodal.devices.beamstop import BeamStop
Expand Down Expand Up @@ -219,24 +224,20 @@ def backlight(
def aperture_scatterguard(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
aperture_positions: AperturePositions | None = None,
) -> ApertureScatterguard:
"""Get the i04 aperture and scatterguard device, instantiate it if it hasn't already
been. If this is called when already instantiated in i04, it will return the existing
object. If aperture_positions is specified, it will update them.
object.
"""

def load_positions(a_s: ApertureScatterguard):
if aperture_positions is not None:
a_s.load_aperture_positions(aperture_positions)

params = get_beamline_parameters()
return device_instantiation(
device_factory=ApertureScatterguard,
name="aperture_scatterguard",
prefix="",
wait=wait_for_connection,
fake=fake_with_ophyd_sim,
post_create=load_positions,
loaded_positions=load_positions_from_beamline_parameters(params),
tolerances=load_tolerances_from_beamline_params(params),
)


Expand Down
Loading

0 comments on commit b39f55c

Please sign in to comment.