Skip to content

Commit 7687519

Browse files
author
Mathias Guijarro
committed
fix(#1184): PositionerBase as an ABC to ensure .egu and .move() are overwritten in subclasses
1 parent 8243d21 commit 7687519

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

ophyd/positioner.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import logging
33
import time
4+
from abc import ABCMeta, abstractmethod
45
from collections import OrderedDict
56
from typing import Any, Callable
67

@@ -13,18 +14,11 @@
1314
logger = 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

Comments
 (0)