From 33e3d38687152755b28b7437b65a477a65bc5d4b Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Fri, 13 Dec 2019 15:26:36 -0600 Subject: [PATCH 1/4] fixes #782 --- ophyd/epics_motor.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ophyd/epics_motor.py b/ophyd/epics_motor.py index 540e7e4b6..2fee2b0e7 100644 --- a/ophyd/epics_motor.py +++ b/ophyd/epics_motor.py @@ -145,8 +145,18 @@ def move(self, position, wait=True, **kwargs): If motion fails other than timing out ''' self._started_moving = False + status = None + def dmov_callback(old_value, value, **kwargs): + self.log.debug(f'DEBUG: dmov_callback(): new={value} old={old_value}') + if self._started_moving and value == 1: + self.motor_done_move.clear_sub(dmov_callback) + status._finished(success=True) + status.done = True + + self.motor_done_move.subscribe(dmov_callback) status = super().move(position, **kwargs) + self.user_setpoint.put(position, wait=False) try: if wait: From 39a0a43ed797147d6f9a6587c1b8df215d110d29 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Fri, 13 Dec 2019 22:20:39 -0600 Subject: [PATCH 2/4] MNT #782 per review comments --- ophyd/epics_motor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ophyd/epics_motor.py b/ophyd/epics_motor.py index 2fee2b0e7..d9da28371 100644 --- a/ophyd/epics_motor.py +++ b/ophyd/epics_motor.py @@ -145,16 +145,16 @@ def move(self, position, wait=True, **kwargs): If motion fails other than timing out ''' self._started_moving = False - status = None def dmov_callback(old_value, value, **kwargs): - self.log.debug(f'DEBUG: dmov_callback(): new={value} old={old_value}') + self.log.debug('dmov_callback(): new=%d old=%d', value, old_value) if self._started_moving and value == 1: + self.motor_done_move.clear_sub(dmov_callback) + self.motor_done_move.unsubscribe(cbid) status._finished(success=True) - status.done = True - self.motor_done_move.subscribe(dmov_callback) + cbid = self.motor_done_move.subscribe(dmov_callback, run=False) status = super().move(position, **kwargs) self.user_setpoint.put(position, wait=False) From a3aeb2769121965e6a3cadce005bcd25a770b995 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Fri, 13 Dec 2019 23:17:49 -0600 Subject: [PATCH 3/4] MNT #782 per review, finish the status --- ophyd/epics_motor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ophyd/epics_motor.py b/ophyd/epics_motor.py index d9da28371..a25d58d25 100644 --- a/ophyd/epics_motor.py +++ b/ophyd/epics_motor.py @@ -238,6 +238,7 @@ def _move_changed(self, timestamp=None, value=None, sub_type=None, '''Callback from EPICS, indicating that movement status has changed''' was_moving = self._moving self._moving = (value != 1) + # self._moving = not self.motor_done_move.get() started = False if not self._started_moving: @@ -250,7 +251,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: @@ -277,6 +281,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) From e3890c81bd9358b9c772ece1ea97b54876c7e838 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Fri, 13 Dec 2019 23:19:46 -0600 Subject: [PATCH 4/4] MNT #782 remove commented code --- ophyd/epics_motor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ophyd/epics_motor.py b/ophyd/epics_motor.py index a25d58d25..bf918b937 100644 --- a/ophyd/epics_motor.py +++ b/ophyd/epics_motor.py @@ -238,7 +238,6 @@ def _move_changed(self, timestamp=None, value=None, sub_type=None, '''Callback from EPICS, indicating that movement status has changed''' was_moving = self._moving self._moving = (value != 1) - # self._moving = not self.motor_done_move.get() started = False if not self._started_moving: