diff --git a/docs/source/upcoming_release_notes/1255-add_preset_support_for_SQR1.rst b/docs/source/upcoming_release_notes/1255-add_preset_support_for_SQR1.rst new file mode 100644 index 00000000000..baed1d35709 --- /dev/null +++ b/docs/source/upcoming_release_notes/1255-add_preset_support_for_SQR1.rst @@ -0,0 +1,30 @@ +IssueNumber Title +################# + +API Breaks +---------- +- N/A + +Features +-------- +- N/A + +Device Updates +-------------- +- `sqr1` add preset support + +New Devices +----------- +- N/A + +Bugfixes +-------- +- N/A + +Maintenance +----------- +- N/A + +Contributors +------------ +- baljamal diff --git a/pcdsdevices/sqr1.py b/pcdsdevices/sqr1.py index 0de04601d38..4815ef9b3e3 100644 --- a/pcdsdevices/sqr1.py +++ b/pcdsdevices/sqr1.py @@ -22,6 +22,8 @@ from ophyd.status import MoveStatus as StatusBase from ophyd.status import wait as status_wait +from pcdsdevices.interface import FltMvInterface + logger = logging.getLogger(__name__) @@ -45,7 +47,7 @@ class Axis(str, enum.Enum): rZ = 'rZ' -class SQR1Axis(PVPositionerIsClose): +class SQR1Axis(FltMvInterface, PVPositionerIsClose): """ Single axis of the square-one tri-sphere motion system. @@ -290,6 +292,7 @@ def sync_setpoints(self): def multi_axis_move( self, + preset_pos: str | None = None, x_sp: float | None = None, y_sp: float | None = None, z_sp: float | None = None, @@ -304,6 +307,8 @@ def multi_axis_move( Parameters ---------- + preset_pos: str or None, optional + Move to a preset position labeled by the preset_pos string. x_sp : float or None, optional The desired position for the X-axis.If None (default), the current position is used. @@ -343,6 +348,19 @@ def multi_axis_move( >>> tri_sphere = SQR1(prefix="SQR1:", name="tri_sphere") >>> status = tri_sphere.multi_axis_move(x_sp=1.0, y_sp=2.0, z_sp=3.0) """ + + if preset_pos is not None: + axis_list = [self.x, self.y, self.z, self.rz, self.ry, self.rz] + if any(hasattr(a.presets.positions, preset_pos) for a in axis_list): + x_sp = (getattr(self.x.presets.positions, preset_pos)).pos + y_sp = (getattr(self.y.presets.positions, preset_pos)).pos + z_sp = (getattr(self.z.presets.positions, preset_pos)).pos + rx_sp = (getattr(self.rx.presets.positions, preset_pos)).pos + ry_sp = (getattr(self.ry.presets.positions, preset_pos)).pos + rz_sp = (getattr(self.rz.presets.positions, preset_pos)).pos + else: + logger.error('One of the axes is missing the desired state.') + x_sp = self.x.readback.get() if x_sp is None else x_sp y_sp = self.y.readback.get() if y_sp is None else y_sp z_sp = self.z.readback.get() if z_sp is None else z_sp @@ -373,3 +391,13 @@ def multi_axis_move( def stop(self): """stop command for all axes.""" self.stop_signal.put(self.stop_value) + + def preset_list(self): + """return a list of preset positions.""" + preset_list = [] + axis_list = [self.x, self.y, self.z, self.rz, self.ry, self.rz] + for axis in axis_list: + for preset in list(vars(axis.presets.positions).keys()): + if preset not in preset_list: + preset_list.append(preset) + return preset_list