1
1
import functools
2
2
import logging
3
3
import time
4
+ from abc import ABCMeta , abstractmethod
4
5
from collections import OrderedDict
5
6
from typing import Any , Callable
6
7
13
14
logger = logging .getLogger (__name__ )
14
15
15
16
16
- class PositionerBase (OphydObject ):
17
+ class PositionerBase (OphydObject , metaclass = ABCMeta ):
17
18
"""The positioner base class
18
19
19
20
Subclass from this to implement your own positioners.
20
21
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
-
28
22
"""
29
23
30
24
SUB_START = "start_moving"
@@ -136,9 +130,10 @@ def report(self):
136
130
return rep
137
131
138
132
@property
133
+ @abstractmethod
139
134
def egu (self ):
140
135
"""The engineering units (EGU) for positions"""
141
- raise NotImplementedError ( "Subclass must implement egu" )
136
+ pass
142
137
143
138
@property
144
139
def limits (self ):
@@ -152,7 +147,8 @@ def low_limit(self):
152
147
def high_limit (self ):
153
148
return self .limits [1 ]
154
149
155
- def move (self , position , moved_cb = None , timeout = None ):
150
+ @abstractmethod
151
+ def move (self , position , wait = False , moved_cb = None , timeout = None ):
156
152
"""Move to a specified position, optionally waiting for motion to
157
153
complete.
158
154
@@ -175,6 +171,8 @@ def move(self, position, moved_cb=None, timeout=None):
175
171
timeout : float, optional
176
172
Maximum time to wait for the motion. If None, the default timeout
177
173
for this positioner is used.
174
+ wait : bool, optional
175
+ Wait for the Status object to be complete (False by default)
178
176
179
177
Returns
180
178
-------
@@ -208,6 +206,9 @@ def move(self, position, moved_cb=None, timeout=None):
208
206
209
207
self .subscribe (status ._finished , event_type = self ._SUB_REQ_DONE , run = False )
210
208
209
+ if wait :
210
+ status .wait ()
211
+
211
212
return status
212
213
213
214
def _done_moving (self , success = True , timestamp = None , value = None , ** kwargs ):
0 commit comments