-
Notifications
You must be signed in to change notification settings - Fork 9
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
PVPositionerSoftDone gets stuck if target position is the same as current position #725
Comments
Maybe we can remove this subscription:
But always call the def _setup_move(self, position):
"""Move and do not wait until motion is complete (asynchronous)"""
self.log.debug("%s.setpoint = %s", self.name, position)
if self.update_target:
kwargs = {}
if issubclass(self.target.__class__, EpicsSignalBase):
kwargs["wait"] = True # Signal.put() warns if kwargs are given
self.target.put(position, **kwargs)
self.setpoint.put(position, wait=True)
if self.actuate is not None:
self.log.debug("%s.actuate = %s", self.name, self.actuate_value)
self.actuate.put(self.actuate_value, wait=False)
self.cb_setpoint() # Forces done to be false.
self.cb_readback() # This is needed to force the first check. Or just switch done to false: def _setup_move(self, position):
"""Move and do not wait until motion is complete (asynchronous)"""
self.log.debug("%s.setpoint = %s", self.name, position)
if self.update_target:
kwargs = {}
if issubclass(self.target.__class__, EpicsSignalBase):
kwargs["wait"] = True # Signal.put() warns if kwargs are given
self.target.put(position, **kwargs)
self.setpoint.put(position, wait=True)
if self.actuate is not None:
self.log.debug("%s.actuate = %s", self.name, self.actuate_value)
self.actuate.put(self.actuate_value, wait=False)
self.done.put(not self.done_value) # Forces done to be false.
self.cb_readback() # This is needed to force the first check. |
@gfabbris Thanks for reporting. I'll also add unit test(s) for this. |
Perhaps we see the same problem with this existing unit test code:
It was succeeding locally but failing in GitHub Actions, so it was localized (
|
Now, local runs fail randomly. There's a problem lurking. Investigating... |
@gfabbris Here's my test code. It's not failing for me locally. Suggestions? Meanwhile, I'll start a PR so GHA will run the tests. apstools/apstools/devices/tests/test_issue725.py Lines 7 to 30 in e089f3f
|
GHA ran. This is the same error you saw @gfabbris ? def test_same_position_725(target, calcpos):
# Before anything is changed.
confirm_in_position(calcpos)
# Confirm the initial position is as expected.
if calcpos.position == target:
# First, move away from the target.
status = calcpos.move(-target or 0.1 * (1 + random.random()))
assert status.done
assert status.elapsed > 0, str(status)
> confirm_in_position(calcpos)
/home/runner/work/apstools/apstools/apstools/devices/tests/test_positioner_soft_done.py:384:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
positioner = PVPositionerSoftDoneWithStop(prefix='', name='calcpos', settle_time=0.0, timeout=None, read_attrs=['readback', 'setpoint'], configuration_attrs=['done', 'tolerance', 'target'], limits=None, egu='')
def confirm_in_position(positioner):
"""Apply the 'inposition' property code."""
reading = positioner.read()
p = reading[positioner.setpoint.name]["value"]
r = reading[positioner.readback.name]["value"]
t = positioner.actual_tolerance
> assert abs(r - p) <= t, f"target={p}, readback={r}, tolerance={t}"
E AssertionError: target=0.1548780125648433, readback=0.0, tolerance=1e-05
E assert 0.1548780125648433 <= 1e-05
E + where 0.1548780125648433 = abs((0.0 - 0.1548780125648433))
/home/runner/work/apstools/apstools/apstools/devices/tests/test_positioner_soft_done.py:261: AssertionError
=============================== warnings summary =============================== |
I think I understand this bug. The issue seems to be when the apstools/apstools/devices/lakeshore_controllers.py Lines 46 to 48 in fddc972
In [25]: lakeshore336.loop2.setpoint._write_pv
Out[25]: <PV '4idd:LS336:TC3:OUT2:SP', count=1, type=time_double, access=read/write>
In [26]: lakeshore336.loop2.setpoint._read_pv
Out[26]: <PV '4idd:LS336:TC3:OUT2:SP_RBV', count=1, type=time_double, access=read/write> Then, the |
What would be the consequence if the |
Yes, this solves the problem in the lakeshore. But it is a more general problem, I had another device that used For apstools, I would prefer to add a |
Can you add code proposing that? |
Here it is: e91fa01. Should we bring this up with the Bluesky team? We could double check this before, but I think this is not the expected behavior for |
Yes |
I ran into this problem with a couple of devices that use
PVPositionerSoftDone
. I think this is because if theposition
is the same as the current value in:apstools/apstools/devices/positioner_soft_done.py
Line 191 in c52de89
Then
cb_setpoint
is not called, anddone
is never switched toFalse
.The text was updated successfully, but these errors were encountered: