11import functools
22import logging
33import time
4+ from abc import ABCMeta , abstractmethod
45from collections import OrderedDict
56from typing import Any , Callable
67
1314logger = logging .getLogger (__name__ )
1415
1516
16- class PositionerBase (OphydObject ):
17+ class PositionerBase (OphydObject , metaclass = ABCMeta ):
1718 """The positioner base class
1819
1920 Subclass from this to implement your own positioners.
2021
21- .. note ::
22-
23- Subclasses should add an additional 'wait' keyword argument on
24- the move method. The `MoveStatus` object returned from
25- `PositionerBase` can then be waited on after the subclass
26- finishes the motion configuration.
27-
2822 """
2923
3024 SUB_START = "start_moving"
@@ -136,9 +130,10 @@ def report(self):
136130 return rep
137131
138132 @property
133+ @abstractmethod
139134 def egu (self ):
140135 """The engineering units (EGU) for positions"""
141- raise NotImplementedError ( "Subclass must implement egu" )
136+ pass
142137
143138 @property
144139 def limits (self ):
@@ -152,6 +147,7 @@ def low_limit(self):
152147 def high_limit (self ):
153148 return self .limits [1 ]
154149
150+ @abstractmethod
155151 def move (self , position , wait = False , moved_cb = None , timeout = None ):
156152 """Move to a specified position, optionally waiting for motion to
157153 complete.
@@ -210,6 +206,9 @@ def move(self, position, wait=False, moved_cb=None, timeout=None):
210206
211207 self .subscribe (status ._finished , event_type = self ._SUB_REQ_DONE , run = False )
212208
209+ if wait :
210+ status .wait ()
211+
213212 return status
214213
215214 def _done_moving (self , success = True , timestamp = None , value = None , ** kwargs ):
0 commit comments