Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 34 additions & 26 deletions src/dodal/beamlines/i17.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

from ophyd_async.core import StrictEnum

from dodal.common.beamlines.beamline_utils import (
device_factory,
)
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.device_manager import DeviceManager
from dodal.devices.i17.i17_apple2 import I17Apple2Controller
from dodal.devices.insertion_device import (
Apple2,
Expand All @@ -30,18 +28,20 @@
set_log_beamline(BL)
set_utils_beamline(BL)

devices = DeviceManager()


class I17Grating(StrictEnum):
AU_400 = "400 line/mm Au"
SI_400 = "400 line/mm Si"


@device_factory()
@devices.factory
def synchrotron() -> Synchrotron:
return Synchrotron()


@device_factory(skip=True)
@devices.factory(skip=True)
def pgm() -> PlaneGratingMonochromator:
return PlaneGratingMonochromator(
prefix=f"{PREFIX.beamline_prefix}-OP-PGM-01:",
Expand All @@ -50,12 +50,12 @@ def pgm() -> PlaneGratingMonochromator:
)


@device_factory()
@devices.factory(skip=True)
def id_gap() -> UndulatorGap:
return UndulatorGap(prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:")


@device_factory()
@devices.factory(skip=True)
def id_phase() -> UndulatorPhaseAxes:
return UndulatorPhaseAxes(
prefix=f"{PREFIX.insertion_prefix}-MO-SERVC-01:",
Expand All @@ -66,36 +66,44 @@ def id_phase() -> UndulatorPhaseAxes:
)


@device_factory(skip=True)
def id() -> Apple2:
"""I17 insertion device."""
return Apple2(
id_gap=id_gap(),
id_phase=id_phase(),
@devices.factory(skip=True)
def id(
id_gap: UndulatorGap, id_phase: UndulatorPhaseAxes
) -> Apple2[UndulatorPhaseAxes]:
return Apple2[UndulatorPhaseAxes](
id_gap=id_gap,
id_phase=id_phase,
)


@device_factory(skip=True)
def id_controller() -> Apple2Controller:
@devices.factory(skip=True)
def id_controller(
id: Apple2[UndulatorPhaseAxes],
) -> Apple2Controller[Apple2[UndulatorPhaseAxes]]:
"""I17 insertion device controller with dummy energy to motor_converter."""
return I17Apple2Controller(
apple2=id(),
apple2=id,
gap_energy_motor_lut=EnergyMotorLookup(lut=LookupTable()),
phase_energy_motor_lut=EnergyMotorLookup(lut=LookupTable()),
)


@device_factory(skip=True)
def id_energy() -> InsertionDeviceEnergy:
return InsertionDeviceEnergy(id_controller=id_controller())
@devices.factory(skip=True)
def id_energy(
id_controller: Apple2Controller[Apple2[UndulatorPhaseAxes]],
) -> InsertionDeviceEnergy:
return InsertionDeviceEnergy(id_controller=id_controller)


@device_factory(skip=True)
def id_polarisation() -> InsertionDevicePolarisation:
return InsertionDevicePolarisation(id_controller=id_controller())
@devices.factory(skip=True)
def id_polarisation(
id_controller: Apple2Controller[Apple2[UndulatorPhaseAxes]],
) -> InsertionDevicePolarisation:
return InsertionDevicePolarisation(id_controller=id_controller)


@device_factory(skip=True)
def energy() -> BeamEnergy:
"""Beam energy."""
return BeamEnergy(id_energy=id_energy(), mono=pgm().energy)
@devices.factory(skip=True)
def energy(
id_energy: InsertionDeviceEnergy, pgm: PlaneGratingMonochromator
) -> BeamEnergy:
return BeamEnergy(id_energy=id_energy, mono=pgm.energy)