add parmod.Par

the reasonly class frappy_psi.parmod.Par represents a parameter
or a component of a tuple parameter

Change-Id: I47208c9d7a6fc377cd56b82cc6a9e8cdb433fe8e
This commit is contained in:
zolliker 2023-09-14 09:05:00 +02:00
parent 4c6c7c7950
commit 2110f8d83b

View File

@ -23,12 +23,36 @@
"""modules to access parameters""" """modules to access parameters"""
from frappy.core import Drivable, IDLE, Attached, StringType, Property, \ from frappy.core import Drivable, IDLE, Attached, StringType, Property, \
Parameter, FloatRange Parameter, FloatRange, Readable
from frappy.errors import ConfigError from frappy.errors import ConfigError
from frappy_psi.convergence import HasConvergence from frappy_psi.convergence import HasConvergence
from frappy_psi.mixins import HasRamp from frappy_psi.mixins import HasRamp
class Par(Readable):
value = Parameter(datatype=FloatRange(unit='$'))
read = Attached(description='<module>.<parameter> for read')
unit = Property('main unit', StringType())
def setProperty(self, key, value):
if key == 'read':
value, param = value.split('.')
setattr(self, f'{key}_param', param)
super().setProperty(key, value)
def checkProperties(self):
self.applyMainUnit(self.unit)
if self.read == self.name :
raise ConfigError('illegal recursive read/write module')
super().checkProperties()
def read_value(self):
return getattr(self.read, f'{self.read_param}')
def read_status(self):
return IDLE, ''
class Driv(Drivable): class Driv(Drivable):
value = Parameter(datatype=FloatRange(unit='$')) value = Parameter(datatype=FloatRange(unit='$'))
target = Parameter(datatype=FloatRange(unit='$')) target = Parameter(datatype=FloatRange(unit='$'))