diff --git a/slic/devices/general/motor.py b/slic/devices/general/motor.py index 4c3202f9d..a1cf06758 100644 --- a/slic/devices/general/motor.py +++ b/slic/devices/general/motor.py @@ -78,7 +78,7 @@ class Motor(Adjustable, SpecConvenienceProgress): return self._motor.set_position(value, **kwargs) - def set_target_value(self, value, hold=False, check_limits=True, show_progress=False): + def set_target_value(self, value, check_limits=True, show_progress=False): ignore_limits = not check_limits low, high = self.get_limits() @@ -86,22 +86,18 @@ class Motor(Adjustable, SpecConvenienceProgress): ignore_limits = True if not show_progress: - def change(): - self._move(value, ignore_limits=ignore_limits, wait=True) + self._move(value, ignore_limits=ignore_limits, wait=True) else: - def change(): - start = self.get_current_value() - stop = value + start = self.get_current_value() + stop = value - with RangeBar(start, stop) as rbar: - def on_change(value=None, **kw): - rbar.show(value) + with RangeBar(start, stop) as rbar: + def on_change(value=None, **kw): + rbar.show(value) - with self.use_callback(on_change): - self._move(stop, ignore_limits=ignore_limits, wait=True) - - return self._as_task(change, hold=hold, stopper=self._motor.stop) + with self.use_callback(on_change): + self._move(stop, ignore_limits=ignore_limits, wait=True) def _move(self, *args, **kwargs): @@ -118,10 +114,7 @@ class Motor(Adjustable, SpecConvenienceProgress): def stop(self): - try: - return super().stop() - except: - self._motor.stop() + self._motor.stop() def get_limits(self, pos_type="user"): diff --git a/slic/devices/general/smaract.py b/slic/devices/general/smaract.py index d118ced86..bfd561d4a 100644 --- a/slic/devices/general/smaract.py +++ b/slic/devices/general/smaract.py @@ -53,6 +53,8 @@ class SmarActAxis(Adjustable): def __init__(self, ID, name=None, units=None, internal=False): super().__init__(ID, name=name, units=units, internal=internal) + self.wait_time = 0.1 + self.timeout = 60 self._move_requested = False self.pvs = SimpleNamespace( @@ -90,13 +92,9 @@ class SmarActAxis(Adjustable): def reset_current_value_to(self, value): return self.pvs.set_pos.put(value) - def set_target_value(self, value, hold=False): - change = lambda: self._move(value) - return self._as_task(change, stopper=self._stop, hold=hold) - - - def _move(self, value, wait_time=0.1, timeout=60): - timeout += time.time() + def set_target_value(self, value): + wait_time = self.wait_time + timeout = self.timeout + time.time() self._move_requested = True self.pvs.drive.put(value, wait=True) @@ -106,7 +104,7 @@ class SmarActAxis(Adjustable): time.sleep(wait_time) if time.time() >= timeout: tname = typename(self) - self._stop() + self.stop() raise SmarActError(f"starting to move {tname} \"{self.name}\" to {value} {self.units} timed out") # wait for move done @@ -118,7 +116,7 @@ class SmarActAxis(Adjustable): self._move_requested = False - def _stop(self): + def stop(self): self._move_requested = False self.pvs.stop.put(1, wait=True) @@ -134,13 +132,6 @@ class SmarActAxis(Adjustable): return self.pvs.status.get() - def stop(self): - try: - return super().stop() - except: - self._stop() - - def within_limits(self, val): low, high = self.get_limits() return low <= val <= high