Skip to content

Commit

Permalink
Merge branch '483-make-device_factory-decorator-to-ease-making-and-co…
Browse files Browse the repository at this point in the history
…nnecting-ophyd-async-devices' of github.com:DiamondLightSource/dodal into 483-make-device_factory-decorator-to-ease-making-and-connecting-ophyd-async-devices
  • Loading branch information
stan-dot committed Jul 22, 2024
2 parents 2fa2bf0 + 7f29d47 commit 4e5b263
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ description = "Ophyd devices and other utils that could be used across DLS beaml
dependencies = [
"click",
"ophyd",
"ophyd-async>=0.3.1",
"ophyd-async<0.4.0", # Need to pin to <0.4.0 as this requires pydantic>2.0 see https://github.com/DiamondLightSource/dodal/issues/679
"bluesky",
"pyepics",
"dataclasses-json",
"pillow",
"zocalo",
"zocalo>=0.32.0",
"requests",
"graypy",
"pydantic",
Expand Down
14 changes: 14 additions & 0 deletions src/dodal/beamlines/i24.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dodal.devices.hutch_shutter import HutchShutter
from dodal.devices.i24.aperture import Aperture
from dodal.devices.i24.beamstop import Beamstop
from dodal.devices.i24.dcm import DCM
from dodal.devices.i24.dual_backlight import DualBacklight
from dodal.devices.i24.I24_detector_motion import DetectorMotion
from dodal.devices.i24.i24_vgonio import VGonio
Expand Down Expand Up @@ -82,6 +83,19 @@ def detector_motion(
)


def dcm(wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False) -> DCM:
"""Get the i24 DCM device, instantiate it if it hasn't already been.
If this is called when already instantiated in i24, it will return the existing object.
"""
return device_instantiation(
device_factory=DCM,
name="dcm",
prefix="",
wait=wait_for_connection,
fake=fake_with_ophyd_sim,
)


@skip_device(lambda: BL == "s24")
def eiger(
wait_for_connection: bool = True,
Expand Down
5 changes: 2 additions & 3 deletions src/dodal/devices/detector/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ class Config:
DetectorSizeConstants: lambda d: d.det_type_string,
}

@root_validator(
pre=True, skip_on_failure=True
) # should be replaced with model_validator once move to pydantic 2 is complete
# should be replaced with model_validator once move to pydantic 2 is complete
@root_validator(pre=True)
def create_beamxy_and_runnumber(cls, values: dict[str, Any]) -> dict[str, Any]:
values["beam_xy_converter"] = DetectorDistanceToBeamXYConverter(
values["det_dist_to_beam_converter_path"]
Expand Down
4 changes: 3 additions & 1 deletion src/dodal/devices/eiger.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def set(self, value, *, timeout=None, settle_time=None, **kwargs):

STALE_PARAMS_TIMEOUT = 60
GENERAL_STATUS_TIMEOUT = 10
# Long timeout for meta file to compensate for filesystem issues
META_FILE_READY_TIMEOUT = 30
ALL_FRAMES_TIMEOUT = 120
ARMING_TIMEOUT = 60

Expand Down Expand Up @@ -305,7 +307,7 @@ def _wait_for_odin_status(self) -> StatusBase:
)
LOGGER.info("Eiger staging: awaiting odin metadata")
status &= await_value(
self.odin.meta.ready, 1, timeout=self.GENERAL_STATUS_TIMEOUT
self.odin.meta.ready, 1, timeout=self.META_FILE_READY_TIMEOUT
)
return status

Expand Down
42 changes: 42 additions & 0 deletions src/dodal/devices/i24/dcm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from ophyd_async.core import StandardReadable
from ophyd_async.epics.motion import Motor
from ophyd_async.epics.signal import epics_signal_r


class DCM(StandardReadable):
"""
A double crystal monocromator device, used to select the beam energy.
"""

def __init__(self, prefix: str, name: str = "") -> None:
with self.add_children_as_readables():
# Motors
self.bragg_in_degrees = Motor(prefix + "-MO-DCM-01:BRAGG")
self.x_translation_in_mm = Motor(prefix + "-MO-DCM-01:X")
self.offset_in_mm = Motor(prefix + "-MO-DCM-01:OFFSET")
self.gap_in_mm = Motor(prefix + "-MO-DCM-01:GAP")
self.energy_in_kev = Motor(prefix + "-MO-DCM-01:ENERGY")
self.xtal1_roll = Motor(prefix + "-MO-DCM-01:XTAL1:ROLL")
self.xtal2_roll = Motor(prefix + "-MO-DCM-01:XTAL2:ROLL")
self.xtal2_pitch = Motor(prefix + "-MO-DCM-01:XTAL2:PITCH")

# Wavelength is calculated in epics from the energy
self.wavelength_in_a = epics_signal_r(float, prefix + "-MO-DCM-01:LAMBDA")

# Temperatures
self.xtal1_temp = epics_signal_r(float, prefix + "-DI-DCM-01:PT100-1")
self.xtal1_heater_temp = epics_signal_r(
float, prefix + "-DI-DCM-01:PT100-2"
)
self.xtal2_temp = epics_signal_r(float, prefix + "-DI-DCM-01:PT100-4")
self.xtal2_heater_temp = epics_signal_r(
float, prefix + "-DI-DCM-01:PT100-5"
)

self.roll_plate_temp = epics_signal_r(float, prefix + "-DI-DCM-01:PT100-3")
self.pitch_plate_temp = epics_signal_r(float, prefix + "-DI-DCM-01:PT100-6")
self.backplate_temp = epics_signal_r(float, prefix + "-DI-DCM-01:PT100-7")
self.b1_plate_temp = epics_signal_r(float, prefix + "-DI-DCM-01:PT100-7")
self.gap_temp = epics_signal_r(float, prefix + "-DI-DCM-01:TC-1")

super().__init__(name)

0 comments on commit 4e5b263

Please sign in to comment.