Skip to content

Commit

Permalink
Change all centre -> center
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-fernandes committed May 20, 2024
1 parent 4a62271 commit a0508fe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
from ophyd import Device


class GapAndCentreSlit1d(Device, Movable, ABC):
"""Class defining interface between Ophyd and 1-dimensional gap and centre slits."""
class GapAndCenterSlit1d(Device, Movable, ABC):
"""Class defining interface between Ophyd and 1-dimensional gap and center slits."""

@abstractmethod
def set(self, position_tuple: Tuple[float, float]):
"""Method to set position of slit.
Parameters:
position_tuple: A 2-tuple containing:
x_centre_value: Central coordinate of gap
x_center_value: Central coordinate of gap
x_size_value: Width of gap
"""
...


def read(self) -> Tuple[float, float]:
"""Method to read position of slit.
Expand All @@ -30,22 +29,22 @@ def read(self) -> Tuple[float, float]:
"""
...

class GapAndCentreSlit2d(Device, Movable, ABC):
"""Class defining interface between Ophyd and 2-dimensional gap and centre slits."""

class GapAndCenterSlit2d(Device, Movable, ABC):
"""Class defining interface between Ophyd and 2-dimensional gap and center slits."""

@abstractmethod
def set(self, position_tuple: Tuple[float, float, float, float]):
"""Method to set position of slit.
Parameters:
position_tuple: A 4-tuple containing:
x_centre_value: Central x-coordinate of gap
x_center_value: Central x-coordinate of gap
x_size_value: Width of gap in x-dimension
y_centre_value: Central y-coordinate of gap
y_center_value: Central y-coordinate of gap
y_size_value: Width of gap in y-dimension
"""
...


def read(self) -> Tuple[float, float, float, float]:
"""Method to read position of slit.
Expand All @@ -57,4 +56,4 @@ def read(self) -> Tuple[float, float, float, float]:
Central y-coordinate of gap
Width of gap in y-dimension
"""
...
...
20 changes: 10 additions & 10 deletions src/dodal/devices/slits/i24_slits_04_virtual_motors.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
from ophyd import Component, Device
from ophyd.status import StatusBase

from dodal.devices.slits.gap_and_centre_slit_base_classes import GapAndCentreSlit2d
from dodal.devices.slits.gap_and_center_slit_base_classes import GapAndCenterSlit2d
from dodal.devices.slits.slit_motor import SlitMotor


class I24Slits04VirtualMotors(GapAndCentreSlit2d):
x_centre: Device = Component(SlitMotor, "X:CENTER")
class I24Slits04VirtualMotors(GapAndCenterSlit2d):
x_center: Device = Component(SlitMotor, "X:CENTER")
x_size: Device = Component(SlitMotor, "X:SIZE")

y_centre: Device = Component(SlitMotor, "Y:CENTER")
x_center: Device = Component(SlitMotor, "Y:CENTER")
y_size: Device = Component(SlitMotor, "Y:SIZE")

def set(self, position_tuple):
x_centre_value, x_size_value, y_centre_value, y_size_value = position_tuple
x_center_value, x_size_value, x_center_value, y_size_value = position_tuple

status = StatusBase()
status.set_finished()

status &= self.x_centre.set(x_centre_value)
status &= self.x_center.set(x_center_value)
status &= self.x_size.set(x_size_value)
status &= self.y_centre.set(y_centre_value)
status &= self.x_center.set(x_center_value)
status &= self.y_size.set(y_size_value)

return status

def read(self):
return (
self.x_centre.read(),
self.x_center.read(),
self.x_size.read(),
self.y_centre.read(),
self.y_size.read()
self.x_center.read(),
self.y_size.read(),
)
27 changes: 13 additions & 14 deletions src/dodal/devices/slits/s5_blo2j_al_slits_95.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from ophyd import Component, Device

from dodal.devices.slits.gap_and_centre_slit_base_classes import GapAndCentreSlit2d
from dodal.devices.slits.gap_and_center_slit_base_classes import GapAndCenterSlit2d
from dodal.devices.slits.slit_motor import SlitMotor


class S5Bl02jAlSlits(GapAndCentreSlit2d):
class S5Bl02jAlSlits(GapAndCenterSlit2d):
"""Class to interact with slit simulator set up as BL02J temporary equipment.
Many thanks to Andrew Foster!
Expand All @@ -17,35 +17,34 @@ class S5Bl02jAlSlits(GapAndCentreSlit2d):
x_minus: Device = Component(SlitMotor, "X:MINUS")

y_size: Device = Component(SlitMotor, "Y:SIZE")
y_centre: Device = Component(SlitMotor, "Y:CENTRE")
y_center: Device = Component(SlitMotor, "Y:CENTER")

x_size: Device = Component(SlitMotor, "X:SIZE")
x_centre: Device = Component(SlitMotor, "X:CENTRE")
x_center: Device = Component(SlitMotor, "X:CENTER")

def set(self, position_tuple: tuple[float, float, float, float]):
"""Method to set position of slit.
Parameters:
position_tuple: A 4-tuple containing:
x_centre_value: Central x-coordinate of gap
x_center_value: Central x-coordinate of gap
x_size_value: Width of gap in x-dimension
y_centre_value: Central y-coordinate of gap
y_center_value: Central y-coordinate of gap
y_size_value: Width of gap in y-dimension
"""
x_centre_value, x_size_value, y_centre_value, y_size_value = position_tuple
x_center_value, x_size_value, y_center_value, y_size_value = position_tuple

status = self.x_centre.set(x_centre_value)
status = self.x_center.set(x_center_value)
status &= self.x_size.set(x_size_value)
status &= self.y_centre.set(y_centre_value)
status &= self.y_center.set(y_center_value)
status &= self.y_size.set(y_size_value)

return status


def read(self):
return (
self.x_centre.read(),
self.x_center.read(),
self.x_size.read(),
self.y_centre.read(),
self.y_size.read()
)
self.y_center.read(),
self.y_size.read(),
)
2 changes: 1 addition & 1 deletion src/dodal/devices/slits/slit_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MoveState(IntEnum):
class SlitMotor(Device, Movable, Readable):
"""A class representing a slit motor.
This could be gap, centre, x, y, etc...
This could be gap, center, x, y, etc...
By default sets to .VAL and reads from .RBV
Unimplemented signals:
Expand Down

0 comments on commit a0508fe

Please sign in to comment.