Skip to content

Commit

Permalink
Remove ophyd references from motion devices (#985)
Browse files Browse the repository at this point in the history
* Change p45 to phyd async

* Use standard readable instead of device

* Instantiate p45 devices correctly

* Add prefix to device pvs

* Convert i03 and i04 devices to ophyd_async

---------

Co-authored-by: Shihab Suliman <[email protected]>
  • Loading branch information
shihab-dls and Shihab Suliman authored Jan 15, 2025
1 parent 317698f commit 157afd6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
13 changes: 10 additions & 3 deletions src/dodal/devices/flux.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
from ophyd import Component, Device, EpicsSignalRO, Kind
from ophyd_async.core import (
StandardReadable,
StandardReadableFormat,
)
from ophyd_async.epics.core import epics_signal_r


class Flux(Device):
class Flux(StandardReadable):
"""Simple device to get the flux reading"""

flux_reading = Component(EpicsSignalRO, "SAMP", kind=Kind.hinted)
def __init__(self, prefix: str, name="") -> None:
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL):
self.flux_reading = epics_signal_r(float, prefix + "SAMP")
super().__init__(name=name)
51 changes: 31 additions & 20 deletions src/dodal/devices/p45.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
from ophyd import Component as Cpt
from ophyd import EpicsMotor, MotorBundle
from ophyd.areadetector.base import ADComponent as Cpt
from ophyd_async.core import StandardReadable
from ophyd_async.epics.motor import Motor


class SampleY(MotorBundle):
class SampleY(StandardReadable):
"""
Motors for controlling the sample's y position and stretch in the y axis.
"""

base = Cpt(EpicsMotor, "CS:Y")
stretch = Cpt(EpicsMotor, "CS:Y:STRETCH")
top = Cpt(EpicsMotor, "Y:TOP")
bottom = Cpt(EpicsMotor, "Y:BOT")
def __init__(self, prefix: str, name="") -> None:
with self.add_children_as_readables():
self.base = Motor(prefix + "CS:Y")
self.stretch = Motor(prefix + "CS:Y:STRETCH")
self.top = Motor(prefix + "Y:TOP")
self.bottom = Motor(prefix + "Y:BOT")
super().__init__(name=name)


class SampleTheta(MotorBundle):
class SampleTheta(StandardReadable):
"""
Motors for controlling the sample's theta position and skew
"""

base = Cpt(EpicsMotor, "THETA:POS")
skew = Cpt(EpicsMotor, "THETA:SKEW")
top = Cpt(EpicsMotor, "THETA:TOP")
bottom = Cpt(EpicsMotor, "THETA:BOT")
def __init__(self, prefix: str, name="") -> None:
with self.add_children_as_readables():
self.base = Motor(prefix + "THETA:POS")
self.skew = Motor(prefix + "THETA:SKEW")
self.top = Motor(prefix + "THETA:TOP")
self.bottom = Motor(prefix + "THETA:BOT")
super().__init__(name=name)


class TomoStageWithStretchAndSkew(MotorBundle):
class TomoStageWithStretchAndSkew(StandardReadable):
"""
Grouping of motors for the P45 tomography stage
"""

x = Cpt(EpicsMotor, "X")
y = Cpt(SampleY, "")
theta = Cpt(SampleTheta, "")
def __init__(self, prefix: str, name="") -> None:
with self.add_children_as_readables():
self.x = Motor(prefix + "X")
self.y = SampleY(prefix)
self.theta = SampleTheta(prefix)
super().__init__(name=name)


class Choppers(MotorBundle):
class Choppers(StandardReadable):
"""
Grouping for the P45 chopper motors
"""

x = Cpt(EpicsMotor, "ENDAT")
y = Cpt(EpicsMotor, "BISS")
def __init__(self, prefix: str, name="") -> None:
with self.add_children_as_readables():
self.x = Motor(prefix + "ENDAT")
self.y = Motor(prefix + "BISS")
super().__init__(name=name)
12 changes: 8 additions & 4 deletions src/dodal/devices/s4_slit_gaps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from ophyd import Component, Device, EpicsMotor
from ophyd_async.core import StandardReadable
from ophyd_async.epics.motor import Motor


class S4SlitGaps(Device):
class S4SlitGaps(StandardReadable):
"""Note that the S4 slits have a different PV fromat to other beamline slits"""

xgap = Component(EpicsMotor, "XGAP")
ygap = Component(EpicsMotor, "YGAP")
def __init__(self, prefix: str, name="") -> None:
with self.add_children_as_readables():
self.xgap = Motor(prefix + "XGAP")
self.ygap = Motor(prefix + "YGAP")
super().__init__(name=name)

0 comments on commit 157afd6

Please sign in to comment.