Timed/delayed settable
Description
Add a settable that waits until a certain amount of time has expired before setting the value.
A function that wraps around a settalbe to create a new settable with identical properties but that waits until a certain time has expired before setting the next value.
Implementation could be different. Also relates to #128 (closed) and working through the use-cases properly.
class DelayedSettable():
def __init__(self, settable, delay=0):
self.settable = settable
self.previous_value =0
self.delay = delay
def set(self, value):
while time.time()-self.previous_time< self.delay:
# wait
time.sleep(0.01) # wait a bit, could also be a pass
self.previous_time = time.time() # update time before setting next datapoint
self.settable.set(value)
Motivation
Based on feedback from @peendebak: In many 1D and 2D scans for spins we want to add a delay for setting a parameter. This could be achieved through a special settable as above.
Edited by Adriaan