Skip to content
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

resolve EpicsMotor stalls sometimes at end of move #783

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ophyd/epics_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,17 @@ def move(self, position, wait=True, **kwargs):
'''
self._started_moving = False

def dmov_callback(old_value, value, **kwargs):
self.log.debug('dmov_callback(): new=%d old=%d', value, old_value)
if self._started_moving and value == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is setting self._started_moving to True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This is tangly code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the _move_changed() method:

        if not self._started_moving:
            started = self._started_moving = (not was_moving and self._moving)


self.motor_done_move.clear_sub(dmov_callback)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one of these should be required.

self.motor_done_move.unsubscribe(cbid)
status._finished(success=True)

cbid = self.motor_done_move.subscribe(dmov_callback, run=False)
status = super().move(position, **kwargs)

self.user_setpoint.put(position, wait=False)
try:
if wait:
Expand Down Expand Up @@ -240,7 +250,10 @@ def _move_changed(self, timestamp=None, value=None, sub_type=None,
self._run_subs(sub_type=self.SUB_START, timestamp=timestamp,
value=value, **kwargs)

if was_moving and not self._moving:
self.log.debug('_move_changed(): %d moving: %d',
self._started_moving, self._moving)

if self._started_moving and not self._moving:
success = True
# Check if we are moving towards the low limit switch
if self.direction_of_travel.get() == 0:
Expand All @@ -267,6 +280,11 @@ def _move_changed(self, timestamp=None, value=None, sub_type=None,
self.log.warning('Motor %s raised an alarm during motion '
'status=%s severity %s',
self.name, status, severity)

self.log.debug('detected moving DONE=%s, .DMOV=%s, success=%s',
self._started_moving,
self.motor_done_move.get(),
success)
self._done_moving(success=success, timestamp=timestamp,
value=value)

Expand Down