|
| 1 | +from bluesky.protocols import Movable |
| 2 | +from ophyd_async.core import AsyncStatus, StandardReadable, StandardReadableFormat |
| 3 | +from ophyd_async.epics.core import epics_signal_rw_rbv |
| 4 | +from ophyd_async.epics.motor import Motor |
| 5 | + |
| 6 | +from dodal.devices.motors import _OMEGA, XYZStage |
| 7 | + |
| 8 | + |
| 9 | +class VirtualAxis(StandardReadable, Movable[float]): |
| 10 | + """Represents the virtual axis coordinate system for the B07SampleManipulator52B. |
| 11 | + The value signal is the read signal for this device. |
| 12 | + """ |
| 13 | + |
| 14 | + def __init__(self, pv: str, name: str = ""): |
| 15 | + """Initialise the device via pv and name configuration. |
| 16 | +
|
| 17 | + Args: |
| 18 | + pv (str): The base PV to connect to the virtual axis. |
| 19 | + name (str, optional): Name of this device. |
| 20 | + """ |
| 21 | + with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): |
| 22 | + self.value = epics_signal_rw_rbv(float, pv, read_suffix=":RBV") |
| 23 | + super().__init__(name) |
| 24 | + |
| 25 | + @AsyncStatus.wrap |
| 26 | + async def set(self, value: float): |
| 27 | + await self.value.set(value) |
| 28 | + |
| 29 | + def set_name(self, name: str, *, child_name_separator: str | None = None) -> None: |
| 30 | + super().set_name(name, child_name_separator=child_name_separator) |
| 31 | + # Value should be named the same as its parent in read() |
| 32 | + self.value.set_name(name) |
| 33 | + |
| 34 | + |
| 35 | +class B07SampleManipulator52B(XYZStage): |
| 36 | + """Sample Manipulator of several Motors and VirtaulAxis. |
| 37 | +
|
| 38 | + Attributes: |
| 39 | + x (Motor): Controls x direction. |
| 40 | + y (Motor): Controls y direction. |
| 41 | + z (Motor): Controls z direction. |
| 42 | + roty (Motor): Controls y rotation. |
| 43 | + rotz (Motor): Controls z rotation. |
| 44 | + xp (Motor): Compound motor for x. |
| 45 | + yp (Motor): Compound motor for y. |
| 46 | + zp (Motor): Compound motor for z. |
| 47 | + omega (VirtualAxis): Virtal rotational axis for the x direction. |
| 48 | + phi (VirtualAxis): Virtal rotational axis for the y direction. |
| 49 | + kappa (VirtualAxis): Virtal rotational axis for the z direction. |
| 50 | + """ |
| 51 | + |
| 52 | + def __init__( |
| 53 | + self, |
| 54 | + prefix: str, |
| 55 | + x_infix: str = "XP", |
| 56 | + y_infix: str = "YP", |
| 57 | + z_infix: str = "ZP", |
| 58 | + roty_infix: str = "ROTY", |
| 59 | + rotz_infix: str = "ROTZ", |
| 60 | + kappa_infix: str = "KAPPA", |
| 61 | + phi_infix: str = "PHI", |
| 62 | + omega_infix: str = _OMEGA, |
| 63 | + name: str = "", |
| 64 | + ): |
| 65 | + """Initialise the device via prefix and infix PV configuration. |
| 66 | +
|
| 67 | + Args: |
| 68 | + prefix (str): Base PV used for connecting signals. |
| 69 | + x_infix (str, optional): Infix between base prefix and x motor record. |
| 70 | + y_infix (str, optional): Infix between base prefix and y motor record. |
| 71 | + z_infix (str, optional): Infix between base prefix and z motor record. |
| 72 | + roty_infix (str, optional): Infix between base prefix and roty motor record. |
| 73 | + rotz_infix (str, optional): Infix between base prefix and rotz motor record. |
| 74 | + kappa_infix (str, optional): Infix between base prefix and kappa virtual axis. |
| 75 | + phi_infix (str, optional): Infix between base prefix and phi virtual axis. |
| 76 | + omega_infix (str, optional): Infix between base prefix and omega virtual axis. |
| 77 | + name (str, optional): The name of this device. |
| 78 | + """ |
| 79 | + with self.add_children_as_readables(): |
| 80 | + # Compound motors |
| 81 | + self.xp = Motor(prefix + x_infix) |
| 82 | + self.yp = Motor(prefix + y_infix) |
| 83 | + self.zp = Motor(prefix + z_infix) |
| 84 | + |
| 85 | + # Raw motors |
| 86 | + self.roty = Motor(prefix + roty_infix) |
| 87 | + self.rotz = Motor(prefix + rotz_infix) |
| 88 | + |
| 89 | + # Not standard motors, virtual axes coordinate system. |
| 90 | + self.kappa = VirtualAxis(prefix + kappa_infix) |
| 91 | + self.phi = VirtualAxis(prefix + phi_infix) |
| 92 | + self.omega = VirtualAxis(prefix + omega_infix) |
| 93 | + |
| 94 | + super().__init__( |
| 95 | + prefix=prefix, |
| 96 | + x_infix=x_infix, |
| 97 | + y_infix=y_infix, |
| 98 | + z_infix=z_infix, |
| 99 | + name=name, |
| 100 | + ) |
0 commit comments