added dummy adjustable that keeps a history of target values

This commit is contained in:
2022-04-16 16:43:33 +02:00
parent 3c36a5685a
commit cbbd4d5613

View File

@ -177,7 +177,7 @@ class Wavelength(Adjustable):
def __init__(self, energy):
self.energy = energy
assert self.energy.units == "keV" # otherwise conversion is wrong
# assert self.energy.units == "keV" # otherwise conversion is wrong
super().__init__(energy.ID + "_WL", name=energy.name + " as Wavelength", units="nm")
def get_current_value(self):
@ -193,6 +193,34 @@ class Wavelength(Adjustable):
class HistoryDummy(Adjustable):
def __init__(self, ID, initial_value=None, **kwargs):
super().__init__(ID, **kwargs)
self.history = [] if initial_value is None else [initial_value]
@classmethod
def init_from(cls, adj):
ID = "HD:" + adj.ID
initial_value = adj.get_current_value()
name = cls.__name__ + " for " + adj.name
units = adj.units
return cls(ID, initial_value=initial_value, name=name, units=units)
def get_current_value(self):
try:
return self.history[-1]
except IndexError:
return None
def set_target_value(self, value):
self.history.append(value)
def is_moving(self):
return False
# these point to the different motors
mu = Motor("SATES30-RIXS:MOT_SRY.VAL")
chi = Motor("SATES30-RIXS:MOT_SRZ.VAL")