Skip to content

Commit

Permalink
move away from ophyd devices
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Aug 16, 2024
1 parent e759a05 commit ffeac92
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 88 deletions.
28 changes: 28 additions & 0 deletions src/dodal/beamlines/i18.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from pathlib import Path

from ophyd_async.panda import HDFPanda
Expand All @@ -13,6 +14,8 @@
from dodal.common.visit import DirectoryServiceClient, StaticVisitDirectoryProvider
from dodal.devices.focusing_mirror import FocusingMirror
from dodal.devices.i18.diode import Diode
from dodal.devices.i18.sim_detector import SimDetector
from dodal.devices.i18.sim_raster_stage import RasterStage
from dodal.devices.i18.table import Table
from dodal.devices.i22.dcm import DoubleCrystalMonochromator
from dodal.devices.slits import Slits
Expand All @@ -23,6 +26,9 @@
from dodal.log import set_beamline as set_log_beamline
from dodal.utils import BeamlinePrefix, get_beamline_name, skip_device

# Make sure EPICS_CA_SERVER_PORT is set to correct value (6064 for DLS sim area detector and motors, 5064 on beamlines)
os.environ["EPICS_CA_SERVER_PORT"] = "6064"

BL = get_beamline_name("i18")
set_log_beamline(BL)
set_utils_beamline(BL)
Expand Down Expand Up @@ -221,3 +227,25 @@ def table(wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False) -
wait_for_connection,
fake_with_ophyd_sim,
)


def raster_stage(
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False
) -> RasterStage:
return device_instantiation(
RasterStage,
"raster_stage",
"-MO-SIM-01:",
wait_for_connection,
fake_with_ophyd_sim,
)


def sim_detector(wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False):
return device_instantiation(
SimDetector,
"sim_detector",
"-MO-SIM-01:",
wait_for_connection,
fake_with_ophyd_sim,
)
2 changes: 2 additions & 0 deletions src/dodal/beamlines/i22.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def hfm(


crystal_metadata = CrystalMetadata("Si111")


def dcm(
wait_for_connection: bool = True,
fake_with_ophyd_sim: bool = False,
Expand Down
18 changes: 18 additions & 0 deletions src/dodal/devices/i18/sim_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from ophyd_async.epics.motion import Motor
from ophyd_async.sim import PatternGenerator


class SimDetector:
def __init__(self, name: str, motor: Motor, motor_field: str):
self.name = name
self.motor = motor
self.motor_field = motor_field
self.pattern_generator = PatternGenerator(
saturation_exposure_time=0.1, detector_height=100, detector_width=100
)

def read(self):
return {self.name: {"value": self.pattern_generator}}

def describe(self):
return {self.name: {"source": "synthetic", "dtype": "number"}}
88 changes: 0 additions & 88 deletions src/dodal/devices/i18/sim_motor_set.py

This file was deleted.

11 changes: 11 additions & 0 deletions src/dodal/devices/i18/sim_raster_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from bluesky.protocols import Movable
from ophyd_async.core import StandardReadable
from ophyd_async.epics.motion import Motor


class RasterStage(StandardReadable, Movable):
def __init__(self, prefix: str, name: str = "") -> None:
with self.add_children_as_readables():
self.offset_in_mm = Motor(prefix + "M1")
self.perp_in_mm = Motor(prefix + "M2")
super().__init__(name)

0 comments on commit ffeac92

Please sign in to comment.