Open ambarb opened 7 years ago
Some more useful information while the actuator is out (ssh_open()
)??
In [8]: ssh_in.done_val
Out[8]: 0
In [9]: ssh_in.done_value
Out[9]: 1
In [10]: ssh_in.done
Out[10]: EpicsSignalRO(read_pv='XF:23IDA-EPS{DP:1-Sh:1}Sw:InLim-Sts', name='ssh_in_done', parent='ssh_in', value=0, timestamp=1498081435.707882, pv_kw={}, auto_monitor=False, string=False)
In [11]: ssh_out.done_val
Out[11]: 0
In [12]: ssh_out.done_value
Out[12]: 1
In [13]: ssh_out.done
Out[13]: EpicsSignalRO(read_pv='XF:23IDA-EPS{DP:1-Sh:1}Sw:OutLim-Sts', name='ssh_out_done', parent='ssh_out', value=1, timestamp=1498081435.707885, pv_kw={}, auto_monitor=False, string=False)
Acturator not powered and left in the out position (open), with msg_hook
.
In [16]: RE(ssh_open())
set: (EpicsSignal(read_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:Out-Cmd', name='ssh_out_setpoint', parent='ssh_out', value=0, timestamp=1498081549.8369, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:Out-Cmd', limits=False, put_complete=False)), (1,), {'group': 'a0da8727-f529-4fc8-a1ac-59fa8ff37995'}
wait: (None), (), {'group': 'a0da8727-f529-4fc8-a1ac-59fa8ff37995'}
Out[16]: []
In [17]: RE(ssh_close())
set: (EpicsSignal(read_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:In-Cmd', name='ssh_in_setpoint', parent='ssh_in', value=0, timestamp=1498081546.241438, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:In-Cmd', limits=False, put_complete=False)), (1,), {'group': '460e6172-e20b-425d-87fc-eab5830bf365'}
wait: (None), (), {'group': '460e6172-e20b-425d-87fc-eab5830bf365'}
Out[17]: []
In [18]: RE(ssh_open())
set: (EpicsSignal(read_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:Out-Cmd', name='ssh_out_setpoint', parent='ssh_out', value=0, timestamp=1498082420.577823, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:Out-Cmd', limits=False, put_complete=False)), (1,), {'group': 'e6a0ebb7-7e2f-4b77-a47f-f595585366ea'}
wait: (None), (), {'group': 'e6a0ebb7-7e2f-4b77-a47f-f595585366ea'}
Out[18]: []
Here is the work around using the same PVs, but not making more ophyd devices/signals.
def ssh_close():
yield from bp.mv(ssh_in.setpoint,1)
##all of the below should not be needed if ophyd functioned as it should.
n=1
while n is 1:
print('Waiting for the slow shutter to close.')
n=caget('XF:23IDA-EPS{DP:1-Sh:1}Sw:OutLim-Sts')
yield from bp.sleep(0.3)
def ssh_open():
yield from bp.mv(ssh_out.setpoint,1)
n=1
while n is 1:
print('Waiting for the slow shutter to open.')
n=caget('XF:23IDA-EPS{DP:1-Sh:1}Sw:InLim-Sts')
yield from bp.sleep(0.3)
In [29]: RE(ssh_close())
set: (EpicsSignal(read_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:In-Cmd', name='ssh_in_setpoint', parent='ssh_in', value=0, timestamp=1498083024.5683, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:In-Cmd', limits=False, put_complete=False)), (1,), {'group': '1f24a88d-3446-4fc7-827d-c9f3e2e55124'}
wait: (None), (), {'group': '1f24a88d-3446-4fc7-827d-c9f3e2e55124'}
sleep: (None), (0.3,), {}
Waiting for the slow shutter to close.
sleep: (None), (0.3,), {}
Waiting for the slow shutter to close.
sleep: (None), (0.3,), {}
Waiting for the slow shutter to close.
sleep: (None), (0.3,), {}
Waiting for the slow shutter to close.
sleep: (None), (0.3,), {}
Out[29]: []
In [30]: RE(ssh_open())
set: (EpicsSignal(read_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:Out-Cmd', name='ssh_out_setpoint', parent='ssh_out', value=0, timestamp=1498083018.988245, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23IDA-EPS{DP:1-Sh:1}Cmd:Out-Cmd', limits=False, put_complete=False)), (1,), {'group': '22fac985-a583-4bda-b4b9-dd62ed784e1e'}
wait: (None), (), {'group': '22fac985-a583-4bda-b4b9-dd62ed784e1e'}
Waiting for the slow shutter to open.
sleep: (None), (0.3,), {}
Waiting for the slow shutter to open.
sleep: (None), (0.3,), {}
Waiting for the slow shutter to open.
sleep: (None), (0.3,), {}
Waiting for the slow shutter to open.
sleep: (None), (0.3,), {}
Waiting for the slow shutter to open.
sleep: (None), (0.3,), {}
Out[30]: []
In [31]:
Found that the following works better, which is probably what is intended. However, the run engine does not return if the you ask for the actuator to go in and it is already in. Please advise on how to fix this part.
RE(mv(ssh_in,1)) RE(mv(ssh_out,1))
Right, with the PVPositioner, you want to be moving the whole positioner, if you move just the setpoint then the higher logic is not triggered and you just change that PV value and reports when it is done changing).
The reason it does not work twice in a row is that there in never a message output by epics (because the limit switch value does not change values) so we wait forever for a message that will never come. Something like will short-circuit set
logic in the case when we know it will be redundant.
class LinearActOut(PVPositioner):
readback = Cpt(EpicsSignalRO, 'Pos-Sts')
setpoint = Cpt(EpicsSignal, 'Cmd:Out-Cmd')
done = Cpt(EpicsSignalRO, 'Sw:OutLim-Sts')
done_val = 0
def set(self, val):
if self.done.get() == self.done_val:
return DeviceStatus(self, done=True, success=True)
return super().set(val)
It is probably better to use a class like https://github.com/NSLS-II-XFP/profile_collection/blob/master/startup/10-motors.py#L8 which lets you do
yield from bp.mv(ssh, 'Open')
yield from bp.mv(sh, 'Close')
ps
This is a very clever class :+1:
That is a neat trick with the twobuttonshutter class. I would have never found that on my own. I was going to get some help to make a universal open/close PV, but now I don’t have to!
We use the same structured PV for putting diodes and YAGs in the beam (not shutters), so I image multiple beam lines would benefit but might not find this because they aren’t looking for shutters but have something driven by the EPS.
Thanks a bunch!
From: Thomas A Caswell notifications@github.com<mailto:notifications@github.com> Reply-To: NSLS-II/ophyd reply@reply.github.com<mailto:reply@reply.github.com> Date: Wednesday, June 21, 2017 at 10:59 PM To: NSLS-II/ophyd ophyd@noreply.github.com<mailto:ophyd@noreply.github.com> Cc: Andi Barbour abarbour@bnl.gov<mailto:abarbour@bnl.gov>, Author author@noreply.github.com<mailto:author@noreply.github.com> Subject: Re: [NSLS-II/ophyd] Potential issue with PVpositioner class not stopping/pausing the RE with failure of mechanical positioner (#402)
Right, with the PVPositioner, you want to be moving the whole positioner, if you move just the setpoint then the higher logic is not triggered and you just change that PV value and reports when it is done changing).
The reason it does not work twice in a row is that there in never a message output by epics (because the limit switch value does not change values) so we wait forever for a message that will never come. Something like will short-circuit set logic in the case when we know it will be redundant.
class LinearActOut(PVPositioner): readback = Cpt(EpicsSignalRO, 'Pos-Sts') setpoint = Cpt(EpicsSignal, 'Cmd:Out-Cmd') done = Cpt(EpicsSignalRO, 'Sw:OutLim-Sts') done_val = 0
def set(self, val):
if self.done.get() == self.done_val:
return DeviceStatus(self, done=True, success=True)
return super().set(val)
It is probably better to use a class like https://github.com/NSLS-II-XFP/profile_collection/blob/master/startup/10-motors.py#L8 which lets you do
yield from bp.mv(ssh, 'Open') yield from bp.mv(sh, 'Close')
ps
This is a very clever class 👍
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/NSLS-II/ophyd/issues/402#issuecomment-310262028, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AM_7GaPGd07mhTENNARyUJFMeEsxLh_jks5sGdivgaJpZM4OBkSH.
As far as we know CSX is getting actual motor records so that EpicsMotor can be used instead of PVPositioners, as of tonight. If so this problem should go away. Is that right @ambarb?
@danielballan
These things are not epics motor records and never will be. They are essentially a positioner that is in and out. The PV logic lives inside the EPS ioc so an EpicsMotor record is serious overkill. The way the EPS group programs these sorts of devices is to have a seperate PVs to insert or remove. For instance, it is not possible to use caput XF23{SomeEPSactuator:1}Cmd-In 0
to move the position to the out state. It looks like the same ioc model was exactly used for the shutter in the example @tacaswell shared from XFP. It could be modeled directly after the photons hutter. It looks like a PPS photon shutter, but I am not sure since I am not at XFP.
CSX-1 has 3 of these devices that were made by various people. I did ask Ruslan to change it so that all the suffixes (the bit after {}) are all the same so I could make a CSS template. I do not know if the EPS group has a standard in place now or not. Harman is probably the best person to ask.
You are right in that we have some other things that are PVpositioner (sy and sz) that need to be made into full EpicsMotor records.
Defined the following classes. Two classes were chosen for the actuator in and out because there exists no single PV for global control of the positioner.
The reasoning for picking the limit switch as the done signal was so that the plan would only continue once the positioner is in place.
The device was defined as:
And plans were created that did not include a while loop for checking the limits because it was thought bluesky and ophyd would check this for me:
However, I wanted to test that I defined things correctly. Everything works when I do not create a failure condition. That is, with the actuator powered,
'ssh_close()
will put the actuator in. If howerver, I leave the limit switches connected but remove the power source from the actuator only, it is impoosible to put the actuator in.Below is a plan output with timestamps and a CSS plot of the pertinent PVs. The normal condition was tested first (2x) and then the failure operating condition was tested (3x). During the failure condition, the RE completed without incident. Please advise.
Normal operating condition
See that the green PV (limit associated with the out position) does change to 0 as expected, as well as the orange PV (0 when actuator is in)..
Failure condition
See that the green PV (limit associated with the out position) does not change to 0 as expected.