Adding an adjustable instance which combines a set of normal pvadjustables to a new adjustable class PVCombiAdjustable
This commit is contained in:
@ -2,3 +2,4 @@ from .magnet import Magnet
|
||||
from .camacquisition import CamAcquisition
|
||||
from .counteradjustable import CounterAdjustable
|
||||
from .bscacquisition import BSCAcquisition
|
||||
from .pvcombiadjustable import PVCombiAdjustable
|
||||
|
52
ext/pvcombiadjustable.py
Normal file
52
ext/pvcombiadjustable.py
Normal file
@ -0,0 +1,52 @@
|
||||
from slic.core.adjustable import Adjustable
|
||||
|
||||
class PVCombiAdjustable(Adjustable):
|
||||
def __init__(self, adjustables,values):
|
||||
self.adjustables = adjustables
|
||||
self.values = values # array or indiviual array values
|
||||
self.process_time = np.max(np.array([adj.process_time for adj in self.adjustables]))
|
||||
|
||||
def set_target_value(self, value):
|
||||
intval = int(value)
|
||||
if intval < 0 or intval >= len(self.values[0]):
|
||||
tname = typename(self)
|
||||
raise AdjustableError(f"Outside of array bounds for {tname} \"{self.name}\" to set target values")
|
||||
|
||||
for adj in self.adjustables:
|
||||
adj._wait_for_ready()
|
||||
|
||||
for i,adj in enumerate(self.adjustables):
|
||||
val=self.values[i,intval]
|
||||
ret = adj.pvs.setvalue.put(val, wait=True, use_complete=True) # use_complete=True enables status in PV.put_complete
|
||||
error = handle_put_return_value(ret)
|
||||
if error is not None:
|
||||
tname = typename(adj)
|
||||
raise AdjustableError(f"changing {tname} \"{adj.name}\" to {val} {adj.units} failed due to {error}")
|
||||
|
||||
sleep(self.process_time)
|
||||
|
||||
for adj in self.adjustables:
|
||||
adj._wait_for_done()
|
||||
|
||||
@property
|
||||
def units(self):
|
||||
[adj.units() for adj in self.adjustables]
|
||||
|
||||
|
||||
def get_current_value(self, readback=True):
|
||||
return [adj.get_current_value(readback) for adj in self.adjustables]
|
||||
|
||||
def stop(self):
|
||||
for adj in self.adjustbale:
|
||||
adj.stop()
|
||||
|
||||
def is_moving(self):
|
||||
return any([adj.is_moving() for adj in self.adjustables])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user