added Collection adjustable
This commit is contained in:
@@ -8,6 +8,7 @@ from .pvadjustable import PVAdjustable
|
||||
from .pvenumadjustable import PVEnumAdjustable
|
||||
|
||||
from .combined import Combined
|
||||
from .collection import Collection
|
||||
from .converted import Converted
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
from .adjustable import Adjustable
|
||||
|
||||
|
||||
class Collection(Adjustable):
|
||||
|
||||
def __init__(self, ID, adjs, **kwargs):
|
||||
super().__init__(ID, **kwargs)
|
||||
self.adjs = adjs
|
||||
|
||||
def get_current_value(self):
|
||||
return tuple(a.get_current_value() for a in self.adjs)
|
||||
|
||||
def set_target_value(self, *vals):
|
||||
adjs = self.adjs
|
||||
_check_sizes(vals, adjs)
|
||||
tasks = [a.set_target_value(v) for a, v in zip(adjs, vals)]
|
||||
for t in tasks:
|
||||
t.wait()
|
||||
|
||||
def is_moving(self):
|
||||
return any(a.is_moving() for a in self.adjs)
|
||||
|
||||
def __repr__(self):
|
||||
return "\n".join(repr(a) for a in self.adjs)
|
||||
|
||||
|
||||
|
||||
def _check_sizes(vals, adjs):
|
||||
nvals = len(vals)
|
||||
nadjs = len(adjs)
|
||||
if nvals != nadjs:
|
||||
raise ValueError(f"number of values ({nvals}) is not equal to number of adjustables ({nadjs})")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user