-
Notifications
You must be signed in to change notification settings - Fork 11
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
Tidy apple2 undulator #1002
Tidy apple2 undulator #1002
Conversation
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): | ||
self.user_setpoint_readback = epics_signal_r(float, fullPV + ".RBV") | ||
self.user_setpoint_readback = epics_signal_r(float, motor_PV + ".RBV") |
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.
@Relm-Arrowny I could instead make everything use user_readback
but this changes the name of the signal when it is read()
I wasn't sure if the name was important so left it.
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.
I think it should be safe to change it to user_readback in fact it is better if we inherit from motor but I think super need to goes before the signal definition otherwise when we call the super class constructor it will override the user_setpoint we define.
Now that I am typing away I remember why I did not use motor, The main reason is I do not want them to be stoppable as we are not meant to try to stop the id once they are moving. I was also worry that leaving movable/locatable in there where they would not function as intended, as we have this strange relationship of user_setpoint return done immediately and nothing happen until we say go.
May be we should call this UndulatorPhaseIO/signals instead?
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.
Ok, if the motor bit is the controversial one I'll revert that and make a follow up issue
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1002 +/- ##
==========================================
- Coverage 97.67% 97.66% -0.02%
==========================================
Files 159 159
Lines 6590 6560 -30
==========================================
- Hits 6437 6407 -30
Misses 153 153 ☔ View full report in Codecov by Sentry. |
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.
Thanks for doing this, it looks good, there are only one part I am not sure about.
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): | ||
self.user_setpoint_readback = epics_signal_r(float, fullPV + ".RBV") | ||
self.user_setpoint_readback = epics_signal_r(float, motor_PV + ".RBV") |
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.
I think it should be safe to change it to user_readback in fact it is better if we inherit from motor but I think super need to goes before the signal definition otherwise when we call the super class constructor it will override the user_setpoint we define.
Now that I am typing away I remember why I did not use motor, The main reason is I do not want them to be stoppable as we are not meant to try to stop the id once they are moving. I was also worry that leaving movable/locatable in there where they would not function as intended, as we have this strange relationship of user_setpoint return done immediately and nothing happen until we say go.
May be we should call this UndulatorPhaseIO/signals instead?
|
||
|
||
class UndulatorPhaseMotor(StandardReadable): | ||
class UndulatorPhaseMotor(Motor): |
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.
Could: Inherit from motor here mean we will have stopable which is something we are told not to do with our id. Furthermore, movable/locatable will not function correctly, So it probably better if we not make this motor but instead change the name and call it UndulatorPhaseIO(Device)?
self.user_setpoint = epics_signal_w(str, fullPV + "SET") | ||
self.user_setpoint_demand_readback = epics_signal_r(float, fullPV + "DMD") | ||
|
||
fullPV = fullPV + "MTR" | ||
motor_PV = fullPV + "MTR" | ||
with self.add_children_as_readables(StandardReadableFormat.HINTED_SIGNAL): | ||
self.user_setpoint_readback = epics_signal_r(float, fullPV + ".RBV") | ||
self.user_setpoint_readback = epics_signal_r(float, motor_PV + ".RBV") |
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.
Must: If we were to use motor, I think this
super().__init__(motor_PV, name)
need to goes before:
self.user_setpoint = epics_signal_w(str, fullPV + "SET")
self.user_setpoint_demand_readback = epics_signal_r(float, fullPV + "DMD")
Otherwise it get override by Motor.
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.
Isn't super().init() what automatically names the children after connecting: would the children still get named in this order?
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.
Isn't super().init() what automatically names the children after connecting: would the children still get named in this order?
I am not sure now that you question this...... but last time I try inherit motor and change the signal inside Motor something like this would happens, I definite
self.user_setpoint = epics_signal_w(str, fullPV + "SET")
and call super().init() and user_setpoint get replace by:
Motor.user_setpoint = epics_signal_rw(float, prefix + ".VAL")
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.
Yes, it would make sense that the call to super replaces it. I will work out the exact behaviour and may make a ophyd-async
issue about it.
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.
looks good thanks.
Sorry @DiamondJoseph, need a Bluesky Reviewer and you already commented on here... |
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.
Some nits around typing, I need to know about how the jaw_phase set signal works before I'll approve, and I'm not completely happy about passing both strings and signals around.
Basically looks there though.
async def estimate_motor_timeout( | ||
setpoint: SignalR, curr_pos: SignalR, velocity: SignalR | ||
): | ||
vel = await velocity.get_value() | ||
cur_pos = await curr_pos.get_value() | ||
target_pos = float(await setpoint.get_value()) | ||
return abs((target_pos - cur_pos) * 2.0 / vel) + 1 |
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.
I presume this is duplicated for motor- can we have a ticket for the behaviour that we want out of Motor to be isolated in ophyd-async, to at least document why this has ended up here for the future, with the ticket linked as a comment here?
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.
I think this comes back to the discussion of whether we inherit from Motor etc. I will make a new issue
Co-authored-by: Joseph Ware <53935796+DiamondJoseph@users.noreply.github.com>
Fixes #999
This didn't end up removing as much code as I expected but I do think it's more maintainable as it contains less repetition.
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}