-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add preset support for SQR1 #1255
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side note: the new functionality you've added here is unit-testable if you have the time |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intended to be |
||
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.') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this |
||
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you run the script to generate this file? I'm surprised the filename is standard but the title here isn't