introduce FrozenParam
For the case when the readback of a parameter does not reflect the change immediately. May also be used on Writable.target or Drivable.target with a short BUSY period. + bug fix in an error message in frappy.datatypes.IntRange Change-Id: I5e1c871629f9e3940ae80f35cb6307f404202b4a Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31981 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -26,6 +26,7 @@ from frappy.datatypes import EnumType, FloatRange, StringType
|
||||
from frappy.lib.enum import Enum
|
||||
from frappy_psi.mercury import MercuryChannel, Mapped, off_on, HasInput
|
||||
from frappy_psi import mercury
|
||||
from frappy_psi.frozenparam import FrozenParam
|
||||
|
||||
actions = Enum(none=0, condense=1, circulate=2, collect=3)
|
||||
open_close = Mapped(CLOSE=0, OPEN=1)
|
||||
@ -39,22 +40,23 @@ class Action(MercuryChannel, Writable):
|
||||
mix_channel = Property('mix channel', StringType(), 'T5')
|
||||
still_channel = Property('cool down channel', StringType(), 'T4')
|
||||
value = Parameter('running action', EnumType(actions))
|
||||
target = Parameter('action to do', EnumType(none=0, condense=1, collect=3), readonly=False)
|
||||
target = FrozenParam('action to do', EnumType(none=0, condense=1, collect=3), readonly=False)
|
||||
_target = 0
|
||||
|
||||
def read_value(self):
|
||||
return self.query('SYS:DR:ACTN', actions_map)
|
||||
|
||||
def read_target(self):
|
||||
return self._target
|
||||
# as target is a FrozenParam, value might be still lag behind target
|
||||
# but will be updated when changed from an other source
|
||||
read_target = read_value
|
||||
|
||||
def write_target(self, value):
|
||||
self._target = value
|
||||
self.change('SYS:DR:CHAN:COOL', self.cooldown_channel, str)
|
||||
self.change('SYS:DR:CHAN:STIL', self.still_channel, str)
|
||||
self.change('SYS:DR:CHAN:MC', self.mix_channel, str)
|
||||
self.change('DEV:T5:TEMP:MEAS:ENAB', 'ON', str)
|
||||
return self.change('SYS:DR:ACTN', value, actions_map)
|
||||
self.change('SYS:DR:ACTN', value, actions_map)
|
||||
return value
|
||||
|
||||
# actions:
|
||||
# NONE (no action)
|
||||
@ -74,7 +76,7 @@ class Action(MercuryChannel, Writable):
|
||||
class Valve(MercuryChannel, Drivable):
|
||||
kind = 'VALV'
|
||||
value = Parameter('valve state', EnumType(closed=0, opened=1))
|
||||
target = Parameter('valve target', EnumType(close=0, open=1))
|
||||
target = FrozenParam('valve target', EnumType(close=0, open=1))
|
||||
|
||||
_try_count = None
|
||||
|
||||
@ -108,6 +110,10 @@ class Valve(MercuryChannel, Drivable):
|
||||
self.change('DEV::VALV:SIG:STATE', self.target, open_close)
|
||||
return BUSY, 'waiting'
|
||||
|
||||
# as target is a FrozenParam, value might be still lag behind target
|
||||
# but will be updated when changed from an other source
|
||||
read_target = read_value
|
||||
|
||||
def write_target(self, value):
|
||||
if value != self.read_value():
|
||||
self._try_count = 0
|
||||
@ -120,13 +126,18 @@ class Valve(MercuryChannel, Drivable):
|
||||
class Pump(MercuryChannel, Writable):
|
||||
kind = 'PUMP'
|
||||
value = Parameter('pump state', EnumType(off=0, on=1))
|
||||
target = Parameter('pump target', EnumType(off=0, on=1))
|
||||
target = FrozenParam('pump target', EnumType(off=0, on=1))
|
||||
|
||||
def read_value(self):
|
||||
return self.query('DEV::PUMP:SIG:STATE', off_on)
|
||||
|
||||
# as target is a FrozenParam, value might be still lag behind target
|
||||
# but will be updated when changed from an other source
|
||||
read_target = read_value
|
||||
|
||||
def write_target(self, value):
|
||||
return self.change('DEV::PUMP:SIG:STATE', value, off_on)
|
||||
self.change('DEV::PUMP:SIG:STATE', value, off_on)
|
||||
return value
|
||||
|
||||
def read_status(self):
|
||||
return IDLE, ''
|
||||
|
Reference in New Issue
Block a user