From 22645b449b4d3e8a22aa69913fdeb57b02464248 Mon Sep 17 00:00:00 2001 From: Enrico Faulhaber Date: Tue, 19 Jun 2018 13:53:04 +0200 Subject: [PATCH] rename Param -> Parameter Change-Id: Idcbc440b76219282a888172890673a4d74935dfd Reviewed-on: https://forge.frm2.tum.de/review/18210 Tested-by: JenkinsCodeReview Reviewed-by: Enrico Faulhaber --- secop/gui/paramview.py | 4 +-- secop/modules.py | 64 ++++++++++++++++++---------------- secop/protocol/dispatcher.py | 16 ++++----- secop/protocol/errors.py | 4 +-- secop/simulation.py | 4 +-- secop_demo/cryo.py | 40 +++++++++++----------- secop_demo/modules.py | 52 ++++++++++++++-------------- secop_demo/test.py | 8 ++--- secop_ess/epics.py | 28 +++++++-------- secop_mlz/amagnet.py | 22 ++++++------ secop_mlz/entangle.py | 66 ++++++++++++++++++------------------ 11 files changed, 157 insertions(+), 151 deletions(-) diff --git a/secop/gui/paramview.py b/secop/gui/paramview.py index 872de76..d5cdfdb 100644 --- a/secop/gui/paramview.py +++ b/secop/gui/paramview.py @@ -45,11 +45,11 @@ class ParameterView(QWidget): self._propWidgets = {} # widget cache do avoid garbage collection self.paramNameLabel.setText("%s:%s" % (module, parameter)) - self._initParamWidgets() + self._initParameterWidgets() # self._node.newData.connect(self._updateValue) - def _initParamWidgets(self): + def _initParameterWidgets(self): # initValues = self._node.queryCache(self._module) #? mix live data? row = 0 diff --git a/secop/modules.py b/secop/modules.py index b71912d..d78b51a 100644 --- a/secop/modules.py +++ b/secop/modules.py @@ -59,7 +59,7 @@ from secop.datatypes import DataType, EnumType, TupleOf, StringType, FloatRange, EVENT_ONLY_ON_CHANGED_VALUES = False -class Param(object): +class Parameter(object): """storage for Parameter settings + value + qualifiers if readonly is False, the value can be changed (by code, or remote) @@ -85,7 +85,9 @@ class Param(object): group='', poll=False, value=unset_value, - timestamp=0): + timestamp=0, + optional=False, + ctr=None): if not isinstance(datatype, DataType): if issubclass(datatype, DataType): # goodie: make an instance from a class (forgotten ()???) @@ -100,6 +102,7 @@ class Param(object): self.readonly = readonly self.export = export self.group = group + self.optional = optional # note: auto-converts True/False to 1/0 which yield the expected # behaviour... @@ -114,7 +117,7 @@ class Param(object): def copy(self): # return a copy of ourselfs - return Param(**self.__dict__) + return Parameter(**self.__dict__) def for_export(self): # used for serialisation only @@ -134,7 +137,7 @@ class Param(object): class Override(object): - """Stores the overrides to ba applied to a Param + """Stores the overrides to ba applied to a Parameter note: overrides are applied by the metaclass during class creating """ @@ -142,7 +145,7 @@ class Override(object): self.kwds = kwds def apply(self, paramobj): - if isinstance(paramobj, Param): + if isinstance(paramobj, Parameter): for k, v in self.kwds.items(): if hasattr(paramobj, k): setattr(paramobj, k, v) @@ -153,20 +156,22 @@ class Override(object): (k, v, paramobj)) else: raise ProgrammingError( - "Overrides can only be applied to Param's, %r is none!" % + "Overrides can only be applied to Parameter's, %r is none!" % paramobj) class Command(object): """storage for Commands settings (description + call signature...) """ - def __init__(self, description, arguments=None, result=None): + def __init__(self, description, arguments=None, result=None, optional=False): # descriptive text for humans self.description = description # list of datatypes for arguments self.arguments = arguments or [] # datatype for result self.resulttype = result + # whether implementation is optional + self.optional = optional def __repr__(self): return '%s(%s)' % (self.__class__.__name__, ', '.join( @@ -198,7 +203,7 @@ class ModuleMeta(type): if '__constructed__' in attrs: return newtype - # merge properties, Param and commands from all sub-classes + # merge properties, Parameter and commands from all sub-classes for entry in ['properties', 'parameters', 'commands']: newentry = {} for base in reversed(bases): @@ -221,12 +226,12 @@ class ModuleMeta(type): if isinstance(v.datatype, EnumType) and not v.datatype._enum.name: v.datatype._enum.name = k - # check validity of Param entries + # check validity of Parameter entries for pname, pobj in newtype.parameters.items(): # XXX: allow dicts for overriding certain aspects only. - if not isinstance(pobj, Param): - raise ProgrammingError('%r: Params entry %r should be a ' - 'Param object!' % (name, pname)) + if not isinstance(pobj, Parameter): + raise ProgrammingError('%r: Parameters entry %r should be a ' + 'Parameter object!' % (name, pname)) # XXX: create getters for the units of params ?? @@ -409,7 +414,7 @@ class Module(object): 'not unterstood! (use one of %s)' % (self.name, k, ', '.join(self.parameters))) - # complain if a Param entry has no default value and + # complain if a Parameter entry has no default value and # is not specified in cfgdict for k, v in self.parameters.items(): if k not in cfgdict: @@ -421,7 +426,7 @@ class Module(object): # assume default value was given cfgdict[k] = v.default - # replace CLASS level Param objects with INSTANCE level ones + # replace CLASS level Parameter objects with INSTANCE level ones # self.parameters[k] = self.parameters[k].copy() # already done above... # now 'apply' config: @@ -468,14 +473,19 @@ class Readable(Module): UNKNOWN = 900, ) parameters = { - 'value': Param('current value of the Module', readonly=True, default=0., - datatype=FloatRange(), unit='', poll=True), - 'pollinterval': Param('sleeptime between polls', default=5, - readonly=False, datatype=FloatRange(0.1, 120), ), - 'status': Param('current status of the Module', - default=(Status.IDLE, ''), - datatype=TupleOf(EnumType(Status), StringType()), - readonly=True, poll=True), + 'value': Parameter('current value of the Module', readonly=True, + default=0., datatype=FloatRange(), + unit='', poll=True, + ), + 'pollinterval': Parameter('sleeptime between polls', default=5, + readonly=False, + datatype=FloatRange(0.1, 120), + ), + 'status': Parameter('current status of the Module', + default=(Status.IDLE, ''), + datatype=TupleOf(EnumType(Status), StringType()), + readonly=True, poll=True, + ), } def init(self): @@ -522,14 +532,10 @@ class Writable(Readable): providing a settable 'target' parameter to those of a Readable """ parameters = { - 'target': Param( - 'target value of the Module', - default=0., - readonly=False, - datatype=FloatRange(), - ), + 'target': Parameter('target value of the Module', + default=0., readonly=False, datatype=FloatRange(), + ), } - # XXX: commands ???? auto deriving working well enough? class Drivable(Writable): diff --git a/secop/protocol/dispatcher.py b/secop/protocol/dispatcher.py index d02bd45..4d2295b 100644 --- a/secop/protocol/dispatcher.py +++ b/secop/protocol/dispatcher.py @@ -43,7 +43,7 @@ import threading from secop.protocol.messages import Message, EVENTREPLY, IDENTREQUEST from secop.protocol.errors import SECOPError, NoSuchModuleError, \ - NoSuchCommandError, NoSuchParamError, BadValueError, ReadonlyError + NoSuchCommandError, NoSuchParameterError, BadValueError, ReadonlyError from secop.lib import formatExtendedStack, formatException try: @@ -223,14 +223,14 @@ class Dispatcher(object): res = func(*arguments) return res, dict(t=currenttime()) - def _setParamValue(self, modulename, pname, value): + def _setParameterValue(self, modulename, pname, value): moduleobj = self.get_module(modulename) if moduleobj is None: raise NoSuchModuleError(module=modulename) pobj = moduleobj.parameters.get(pname, None) if pobj is None: - raise NoSuchParamError(module=modulename, parameter=pname) + raise NoSuchParameterError(module=modulename, parameter=pname) if pobj.readonly: raise ReadonlyError(module=modulename, parameter=pname) @@ -244,14 +244,14 @@ class Dispatcher(object): return pobj.export_value(), dict(t=pobj.timestamp) return pobj.export_value(), {} - def _getParamValue(self, modulename, pname): + def _getParameterValue(self, modulename, pname): moduleobj = self.get_module(modulename) if moduleobj is None: raise NoSuchModuleError(module=modulename) pobj = moduleobj.parameters.get(pname, None) if pobj is None: - raise NoSuchParamError(module=modulename, parameter=pname) + raise NoSuchParameterError(module=modulename, parameter=pname) readfunc = getattr(moduleobj, u'read_%s' % pname, None) if readfunc: @@ -335,7 +335,7 @@ class Dispatcher(object): # XXX: trigger polling and force sending event if not msg.parameter: msg.parameter = u'value' - msg.set_result(*self._getParamValue(msg.module, msg.parameter)) + msg.set_result(*self._getParameterValue(msg.module, msg.parameter)) #if conn in self._active_connections: # return None # already send to myself @@ -349,7 +349,7 @@ class Dispatcher(object): # just return the reply in that case if not msg.parameter: msg.parameter = u'target' - msg.set_result(*self._setParamValue(msg.module, msg.parameter, msg.data)) + msg.set_result(*self._setParameterValue(msg.module, msg.parameter, msg.data)) #if conn in self._active_connections: # return None # already send to myself @@ -403,7 +403,7 @@ class Dispatcher(object): # XXX: should we send the cached values instead? (pbj.value) # also: ignore errors here. try: - res = self._getParamValue(modulename, pname) + res = self._getParameterValue(modulename, pname) if res[0] == Ellipsis: # means we do not have a value at all so skip this self.log.error( u'activate: got no value for %s:%s!' % diff --git a/secop/protocol/errors.py b/secop/protocol/errors.py index 1e3a8f7..c6afabc 100644 --- a/secop/protocol/errors.py +++ b/secop/protocol/errors.py @@ -57,7 +57,7 @@ class NoSuchModuleError(SECOPError): pass -class NoSuchParamError(SECOPError): +class NoSuchParameterError(SECOPError): pass @@ -100,7 +100,7 @@ class DisabledError(SECOPError): EXCEPTIONS = dict( NoSuchModule=NoSuchModuleError, - NoSuchParam=NoSuchParamError, + NoSuchParameter=NoSuchParameterError, NoSuchCommand=NoSuchCommandError, CommandFailed=CommandFailedError, CommandRunning=CommandRunningError, diff --git a/secop/simulation.py b/secop/simulation.py index 46b6f5f..f643ad4 100644 --- a/secop/simulation.py +++ b/secop/simulation.py @@ -24,7 +24,7 @@ import random from time import sleep -from secop.modules import Module, Readable, Writable, Drivable, Param +from secop.modules import Module, Readable, Writable, Drivable, Parameter from secop.lib import mkthread from secop.datatypes import FloatRange @@ -42,7 +42,7 @@ class SimBase(object): self.parameters = dict((k, v.copy()) for k, v in self.parameters.items()) for k in extra_params.split(','): k = k.strip() - self.parameters[k] = Param('extra_param: %s' % k.strip(), + self.parameters[k] = Parameter('extra_param: %s' % k.strip(), datatype=FloatRange(), default=0.0) def reader(maxage=0, pname=k): diff --git a/secop_demo/cryo.py b/secop_demo/cryo.py index b912d57..77a30af 100644 --- a/secop_demo/cryo.py +++ b/secop_demo/cryo.py @@ -24,7 +24,7 @@ from math import atan import time import random -from secop.modules import Drivable, Command, Param +from secop.modules import Drivable, Command, Parameter from secop.datatypes import FloatRange, EnumType, TupleOf from secop.lib import clamp, mkthread @@ -41,82 +41,82 @@ class Cryostat(CryoBase): - thermal transfer between regulation and samplen """ parameters = dict( - jitter=Param("amount of random noise on readout values", + jitter=Parameter("amount of random noise on readout values", datatype=FloatRange(0, 1), unit="K", default=0.1, readonly=False, export=False, ), - T_start=Param("starting temperature for simulation", + T_start=Parameter("starting temperature for simulation", datatype=FloatRange(0), default=10, export=False, ), - looptime=Param("timestep for simulation", + looptime=Parameter("timestep for simulation", datatype=FloatRange(0.01, 10), unit="s", default=1, readonly=False, export=False, ), - ramp=Param("ramping speed of the setpoint", + ramp=Parameter("ramping speed of the setpoint", datatype=FloatRange(0, 1e3), unit="K/min", default=1, readonly=False, ), - setpoint=Param("current setpoint during ramping else target", + setpoint=Parameter("current setpoint during ramping else target", datatype=FloatRange(), default=1, unit='K', ), - maxpower=Param("Maximum heater power", + maxpower=Parameter("Maximum heater power", datatype=FloatRange(0), default=1, unit="W", readonly=False, group='heater_settings', ), - heater=Param("current heater setting", + heater=Parameter("current heater setting", datatype=FloatRange(0, 100), default=0, unit="%", group='heater_settings', ), - heaterpower=Param("current heater power", + heaterpower=Parameter("current heater power", datatype=FloatRange(0), default=0, unit="W", group='heater_settings', ), - target=Param("target temperature", + target=Parameter("target temperature", datatype=FloatRange(0), default=0, unit="K", readonly=False, ), - value=Param("regulation temperature", + value=Parameter("regulation temperature", datatype=FloatRange(0), default=0, unit="K", ), - pid=Param("regulation coefficients", + pid=Parameter("regulation coefficients", datatype=TupleOf(FloatRange(0), FloatRange(0, 100), FloatRange(0, 100)), default=(40, 10, 2), readonly=False, group='pid', ), - p=Param("regulation coefficient 'p'", + p=Parameter("regulation coefficient 'p'", datatype=FloatRange(0), default=40, unit="%/K", readonly=False, group='pid', ), - i=Param("regulation coefficient 'i'", + i=Parameter("regulation coefficient 'i'", datatype=FloatRange(0, 100), default=10, readonly=False, group='pid', ), - d=Param("regulation coefficient 'd'", + d=Parameter("regulation coefficient 'd'", datatype=FloatRange(0, 100), default=2, readonly=False, group='pid', ), - mode=Param("mode of regulation", + mode=Parameter("mode of regulation", datatype=EnumType('mode', ramp=None, pid=None, openloop=None), default='ramp', readonly=False, ), - pollinterval=Param("polling interval", + pollinterval=Parameter("polling interval", datatype=FloatRange(0), default=5, ), - tolerance=Param("temperature range for stability checking", + tolerance=Parameter("temperature range for stability checking", datatype=FloatRange(0, 100), default=0.1, unit='K', readonly=False, group='stability', ), - window=Param("time window for stability checking", + window=Parameter("time window for stability checking", datatype=FloatRange(1, 900), default=30, unit='s', readonly=False, group='stability', ), - timeout=Param("max waiting time for stabilisation check", + timeout=Parameter("max waiting time for stabilisation check", datatype=FloatRange(1, 36000), default=900, unit='s', readonly=False, group='stability', diff --git a/secop_demo/modules.py b/secop_demo/modules.py index 6b13b03..28d9350 100644 --- a/secop_demo/modules.py +++ b/secop_demo/modules.py @@ -25,7 +25,7 @@ import random import threading from secop.lib.enum import Enum -from secop.modules import Readable, Drivable, Param +from secop.modules import Readable, Drivable, Parameter from secop.datatypes import EnumType, FloatRange, IntRange, ArrayOf, StringType, TupleOf, StructOf, BoolType @@ -33,18 +33,18 @@ class Switch(Drivable): """switch it on or off.... """ parameters = { - 'value': Param('current state (on or off)', + 'value': Parameter('current state (on or off)', datatype=EnumType(on=1, off=0), default=0, ), - 'target': Param('wanted state (on or off)', + 'target': Parameter('wanted state (on or off)', datatype=EnumType(on=1, off=0), default=0, readonly=False, ), - 'switch_on_time': Param('seconds to wait after activating the switch', + 'switch_on_time': Parameter('seconds to wait after activating the switch', datatype=FloatRange(0, 60), unit='s', default=10, export=False, ), - 'switch_off_time': Param('cool-down time in seconds', + 'switch_off_time': Parameter('cool-down time in seconds', datatype=FloatRange(0, 60), unit='s', default=10, export=False, ), @@ -95,22 +95,22 @@ class MagneticField(Drivable): """a liquid magnet """ parameters = { - 'value': Param('current field in T', + 'value': Parameter('current field in T', unit='T', datatype=FloatRange(-15, 15), default=0, ), - 'target': Param('target field in T', + 'target': Parameter('target field in T', unit='T', datatype=FloatRange(-15, 15), default=0, readonly=False, ), - 'ramp': Param('ramping speed', + 'ramp': Parameter('ramping speed', unit='T/min', datatype=FloatRange(0, 1), default=0.1, readonly=False, ), - 'mode': Param('what to do after changing field', + 'mode': Parameter('what to do after changing field', default=1, datatype=EnumType(persistent=1, hold=0), readonly=False, ), - 'heatswitch': Param('name of heat switch device', + 'heatswitch': Parameter('name of heat switch device', datatype=StringType(), export=False, ), } @@ -183,10 +183,10 @@ class CoilTemp(Readable): """a coil temperature """ parameters = { - 'value': Param('Coil temperatur', + 'value': Parameter('Coil temperatur', unit='K', datatype=FloatRange(), default=0, ), - 'sensor': Param("Sensor number or calibration id", + 'sensor': Parameter("Sensor number or calibration id", datatype=StringType(), readonly=True, ), } @@ -199,13 +199,13 @@ class SampleTemp(Drivable): """a sample temperature """ parameters = { - 'value': Param('Sample temperature', + 'value': Parameter('Sample temperature', unit='K', datatype=FloatRange(), default=10, ), - 'sensor': Param("Sensor number or calibration id", + 'sensor': Parameter("Sensor number or calibration id", datatype=StringType(), readonly=True, ), - 'ramp': Param('moving speed in K/min', + 'ramp': Parameter('moving speed in K/min', datatype=FloatRange(0, 100), unit='K/min', default=0.1, readonly=False, ), @@ -246,16 +246,16 @@ class Label(Readable): modules. """ parameters = { - 'system': Param("Name of the magnet system", + 'system': Parameter("Name of the magnet system", datatype=StringType, export=False, ), - 'subdev_mf': Param("name of subdevice for magnet status", + 'subdev_mf': Parameter("name of subdevice for magnet status", datatype=StringType, export=False, ), - 'subdev_ts': Param("name of subdevice for sample temp", + 'subdev_ts': Parameter("name of subdevice for sample temp", datatype=StringType, export=False, ), - 'value': Param("final value of label string", + 'value': Parameter("final value of label string", datatype=StringType, ), } @@ -291,20 +291,20 @@ class DatatypesTest(Readable): """for demoing all datatypes """ parameters = { - 'enum': Param('enum', datatype=EnumType(boo=None, faar=None, z=9), + 'enum': Parameter('enum', datatype=EnumType(boo=None, faar=None, z=9), readonly=False, default=1), - 'tupleof': Param('tuple of int, float and str', + 'tupleof': Parameter('tuple of int, float and str', datatype=TupleOf(IntRange(), FloatRange(), StringType()), readonly=False, default=(1, 2.3, 'a')), - 'arrayof': Param('array: 2..3 times bool', + 'arrayof': Parameter('array: 2..3 times bool', datatype=ArrayOf(BoolType(), 2, 3), readonly=False, default=[1, 0, 1]), - 'intrange': Param('intrange', datatype=IntRange(2, 9), + 'intrange': Parameter('intrange', datatype=IntRange(2, 9), readonly=False, default=4), - 'floatrange': Param('floatrange', datatype=FloatRange(-1, 1), + 'floatrange': Parameter('floatrange', datatype=FloatRange(-1, 1), readonly=False, default=0, ), - 'struct': Param('struct(a=str, b=int, c=bool)', + 'struct': Parameter('struct(a=str, b=int, c=bool)', datatype=StructOf(a=StringType(), b=IntRange(), c=BoolType()), ), @@ -313,6 +313,6 @@ class DatatypesTest(Readable): class ArrayTest(Readable): parameters = { - "x": Param('value', datatype=ArrayOf(FloatRange(), 100000, 100000), + "x": Parameter('value', datatype=ArrayOf(FloatRange(), 100000, 100000), default = 100000 * [0]), } diff --git a/secop_demo/test.py b/secop_demo/test.py index 0a7fd6d..5d26073 100644 --- a/secop_demo/test.py +++ b/secop_demo/test.py @@ -22,7 +22,7 @@ import random -from secop.modules import Readable, Drivable, Communicator, Param +from secop.modules import Readable, Drivable, Communicator, Parameter from secop.datatypes import FloatRange, StringType @@ -44,7 +44,7 @@ class Heater(Drivable): but the implementation may do anything """ parameters = { - 'maxheaterpower': Param('maximum allowed heater power', + 'maxheaterpower': Parameter('maximum allowed heater power', datatype=FloatRange(0, 100), unit='W', ), } @@ -63,14 +63,14 @@ class Temp(Drivable): but the implementation may do anything """ parameters = { - 'sensor': Param( + 'sensor': Parameter( "Sensor number or calibration id", datatype=StringType( 8, 16), readonly=True, ), - 'target': Param( + 'target': Parameter( "Target temperature", default=300.0, datatype=FloatRange(0), diff --git a/secop_ess/epics.py b/secop_ess/epics.py index c98fc37..8ad0ed1 100644 --- a/secop_ess/epics.py +++ b/secop_ess/epics.py @@ -23,7 +23,7 @@ from __future__ import absolute_import from secop.datatypes import EnumType, FloatRange, StringType -from secop.modules import Readable, Drivable, Param +from secop.modules import Readable, Drivable, Parameter try: from pvaccess import Channel # import EPIVSv4 functionallity, PV access @@ -60,16 +60,16 @@ class EpicsReadable(Readable): """EpicsDrivable handles a Drivable interfacing to EPICS v4""" # Commmon parameter for all EPICS devices parameters = { - 'value': Param('EPICS generic value', + 'value': Parameter('EPICS generic value', datatype=FloatRange(), default=300.0,), - 'epics_version': Param("EPICS version used, v3 or v4", + 'epics_version': Parameter("EPICS version used, v3 or v4", datatype=EnumType(v3=3, v4=4),), # 'private' parameters: not remotely accessible - 'value_pv': Param('EPICS pv_name of value', + 'value_pv': Parameter('EPICS pv_name of value', datatype=StringType(), default="unset", export=False), - 'status_pv': Param('EPICS pv_name of status', + 'status_pv': Parameter('EPICS pv_name of status', datatype=StringType(), default="unset", export=False), } @@ -120,18 +120,18 @@ class EpicsDrivable(Drivable): """EpicsDrivable handles a Drivable interfacing to EPICS v4""" # Commmon parameter for all EPICS devices parameters = { - 'target': Param('EPICS generic target', datatype=FloatRange(), + 'target': Parameter('EPICS generic target', datatype=FloatRange(), default=300.0, readonly=False), - 'value': Param('EPICS generic value', datatype=FloatRange(), + 'value': Parameter('EPICS generic value', datatype=FloatRange(), default=300.0,), - 'epics_version': Param("EPICS version used, v3 or v4", + 'epics_version': Parameter("EPICS version used, v3 or v4", datatype=StringType(),), # 'private' parameters: not remotely accessible - 'target_pv': Param('EPICS pv_name of target', datatype=StringType(), + 'target_pv': Parameter('EPICS pv_name of target', datatype=StringType(), default="unset", export=False), - 'value_pv': Param('EPICS pv_name of value', datatype=StringType(), + 'value_pv': Parameter('EPICS pv_name of value', datatype=StringType(), default="unset", export=False), - 'status_pv': Param('EPICS pv_name of status', datatype=StringType(), + 'status_pv': Parameter('EPICS pv_name of status', datatype=StringType(), default="unset", export=False), } @@ -194,13 +194,13 @@ class EpicsTempCtrl(EpicsDrivable): parameters = { # TODO: restrict possible values with oneof datatype - 'heaterrange': Param('Heater range', datatype=StringType(), + 'heaterrange': Parameter('Heater range', datatype=StringType(), default='Off', readonly=False,), - 'tolerance': Param('allowed deviation between value and target', + 'tolerance': Parameter('allowed deviation between value and target', datatype=FloatRange(1e-6, 1e6), default=0.1, readonly=False,), # 'private' parameters: not remotely accessible - 'heaterrange_pv': Param('EPICS pv_name of heater range', + 'heaterrange_pv': Parameter('EPICS pv_name of heater range', datatype=StringType(), default="unset", export=False,), } diff --git a/secop_mlz/amagnet.py b/secop_mlz/amagnet.py index 2d945dc..49dacdf 100644 --- a/secop_mlz/amagnet.py +++ b/secop_mlz/amagnet.py @@ -30,7 +30,7 @@ import math from secop.lib.sequence import SequencerMixin, Step from secop.datatypes import StringType, TupleOf, FloatRange, ArrayOf, StructOf from secop.errors import DisabledError, ConfigError -from secop.modules import Param, Drivable +from secop.modules import Parameter, Drivable class GarfieldMagnet(SequencerMixin, Drivable): @@ -47,30 +47,30 @@ class GarfieldMagnet(SequencerMixin, Drivable): """ parameters = { - 'subdev_currentsource': Param('(bipolar) Powersupply', datatype=StringType(), readonly=True, export=False), - 'subdev_enable': Param('Switch to set for on/off', datatype=StringType(), readonly=True, export=False), - 'subdev_polswitch': Param('Switch to set for polarity', datatype=StringType(), readonly=True, export=False), - 'subdev_symmetry': Param('Switch to read for symmetry', datatype=StringType(), readonly=True, export=False), - 'userlimits': Param('User defined limits of device value', + 'subdev_currentsource': Parameter('(bipolar) Powersupply', datatype=StringType(), readonly=True, export=False), + 'subdev_enable': Parameter('Switch to set for on/off', datatype=StringType(), readonly=True, export=False), + 'subdev_polswitch': Parameter('Switch to set for polarity', datatype=StringType(), readonly=True, export=False), + 'subdev_symmetry': Parameter('Switch to read for symmetry', datatype=StringType(), readonly=True, export=False), + 'userlimits': Parameter('User defined limits of device value', unit='main', datatype=TupleOf(FloatRange(), FloatRange()), default=(float('-Inf'), float('+Inf')), readonly=False, poll=10), - 'abslimits': Param('Absolute limits of device value', + 'abslimits': Parameter('Absolute limits of device value', unit='main', datatype=TupleOf(FloatRange(), FloatRange()), default=(-0.5, 0.5), poll=True, ), - 'precision': Param('Precision of the device value (allowed deviation ' + 'precision': Parameter('Precision of the device value (allowed deviation ' 'of stable values from target)', unit='main', datatype=FloatRange(0.001), default=0.001, readonly=False, ), - 'ramp': Param('Target rate of field change per minute', readonly=False, + 'ramp': Parameter('Target rate of field change per minute', readonly=False, unit='main/min', datatype=FloatRange(), default=1.0), - 'calibration': Param('Coefficients for calibration ' + 'calibration': Parameter('Coefficients for calibration ' 'function: [c0, c1, c2, c3, c4] calculates ' 'B(I) = c0*I + c1*erf(c2*I) + c3*atan(c4*I)' ' in T', poll=1, datatype=ArrayOf(FloatRange(), 5, 5), default=(1.0, 0.0, 0.0, 0.0, 0.0)), - 'calibrationtable': Param('Map of Coefficients for calibration per symmetry setting', + 'calibrationtable': Parameter('Map of Coefficients for calibration per symmetry setting', datatype=StructOf(symmetric=ArrayOf(FloatRange(), 5, 5), short=ArrayOf( FloatRange(), 5, 5), diff --git a/secop_mlz/entangle.py b/secop_mlz/entangle.py index 9da4014..beebea5 100644 --- a/secop_mlz/entangle.py +++ b/secop_mlz/entangle.py @@ -41,7 +41,7 @@ from secop.datatypes import IntRange, FloatRange, StringType, TupleOf, \ ArrayOf, EnumType from secop.errors import ConfigError, ProgrammingError, CommunicationError, \ HardwareError -from secop.modules import Param, Command, Override, Module, Readable, Drivable +from secop.modules import Parameter, Command, Override, Module, Readable, Drivable ##### @@ -159,14 +159,14 @@ class PyTangoDevice(Module): """ parameters = { - 'comtries': Param('Maximum retries for communication', + 'comtries': Parameter('Maximum retries for communication', datatype=IntRange(1, 100), default=3, readonly=False, group='communication'), - 'comdelay': Param('Delay between retries', datatype=FloatRange(0), + 'comdelay': Parameter('Delay between retries', datatype=FloatRange(0), unit='s', default=0.1, readonly=False, group='communication'), - 'tangodevice': Param('Tango device name', + 'tangodevice': Parameter('Tango device name', datatype=StringType(), readonly=True, # export=True, # for testing only export=False, @@ -426,25 +426,25 @@ class AnalogOutput(PyTangoDevice, Drivable): """ parameters = { - 'userlimits': Param('User defined limits of device value', + 'userlimits': Parameter('User defined limits of device value', datatype=TupleOf(FloatRange(), FloatRange()), default=(float('-Inf'), float('+Inf')), unit='main', readonly=False, poll=10, ), - 'abslimits': Param('Absolute limits of device value', + 'abslimits': Parameter('Absolute limits of device value', datatype=TupleOf(FloatRange(), FloatRange()), unit='main', ), - 'precision': Param('Precision of the device value (allowed deviation ' + 'precision': Parameter('Precision of the device value (allowed deviation ' 'of stable values from target)', unit='main', datatype=FloatRange(1e-38), readonly=False, group='stability', ), - 'window': Param('Time window for checking stabilization if > 0', + 'window': Parameter('Time window for checking stabilization if > 0', unit='s', default=60.0, readonly=False, datatype=FloatRange(0, 900), group='stability', ), - 'timeout': Param('Timeout for waiting for a stable value (if > 0)', + 'timeout': Parameter('Timeout for waiting for a stable value (if > 0)', unit='s', default=60.0, readonly=False, datatype=FloatRange(0, 900), group='stability', ), @@ -599,10 +599,10 @@ class Actuator(AnalogOutput): # for secop: support the speed and ramp parameters parameters = { - 'speed': Param('The speed of changing the value', + 'speed': Parameter('The speed of changing the value', unit='main/s', readonly=False, datatype=FloatRange(0), ), - 'ramp': Param('The speed of changing the value', + 'ramp': Parameter('The speed of changing the value', unit='main/min', readonly=False, datatype=FloatRange(0), poll=30, ), @@ -639,13 +639,13 @@ class Motor(Actuator): """ parameters = { - 'refpos': Param('Reference position', + 'refpos': Parameter('Reference position', datatype=FloatRange(), unit='main', ), - 'accel': Param('Acceleration', + 'accel': Parameter('Acceleration', datatype=FloatRange(), readonly=False, unit='main/s^2', ), - 'decel': Param('Deceleration', + 'decel': Parameter('Deceleration', datatype=FloatRange(), readonly=False, unit='main/s^2', ), } @@ -679,24 +679,24 @@ class TemperatureController(Actuator): """ parameters = { - 'p': Param('Proportional control Parameter', datatype=FloatRange(), + 'p': Parameter('Proportional control Parameter', datatype=FloatRange(), readonly=False, group='pid', ), - 'i': Param('Integral control Parameter', datatype=FloatRange(), + 'i': Parameter('Integral control Parameter', datatype=FloatRange(), readonly=False, group='pid', ), - 'd': Param('Derivative control Parameter', datatype=FloatRange(), + 'd': Parameter('Derivative control Parameter', datatype=FloatRange(), readonly=False, group='pid', ), - 'pid': Param('pid control Parameters', + 'pid': Parameter('pid control Parameters', datatype=TupleOf(FloatRange(), FloatRange(), FloatRange()), readonly=False, group='pid', poll=30, ), - 'setpoint': Param('Current setpoint', datatype=FloatRange(), poll=1, + 'setpoint': Parameter('Current setpoint', datatype=FloatRange(), poll=1, ), - 'heateroutput': Param('Heater output', datatype=FloatRange(), poll=1, + 'heateroutput': Parameter('Heater output', datatype=FloatRange(), poll=1, ), - 'ramp': Param('Temperature ramp', unit='main/min', + 'ramp': Parameter('Temperature ramp', unit='main/min', datatype=FloatRange(), readonly=False, poll=30), } @@ -754,11 +754,11 @@ class PowerSupply(Actuator): """ parameters = { - 'ramp': Param('Current/voltage ramp', unit='main/min', + 'ramp': Parameter('Current/voltage ramp', unit='main/min', datatype=FloatRange(), readonly=False, poll=30,), - 'voltage': Param('Actual voltage', unit='V', + 'voltage': Parameter('Actual voltage', unit='V', datatype=FloatRange(), poll=-5), - 'current': Param('Actual current', unit='A', + 'current': Parameter('Actual current', unit='A', datatype=FloatRange(), poll=-5), } @@ -792,7 +792,7 @@ class NamedDigitalInput(DigitalInput): """ parameters = { - 'mapping': Param('A dictionary mapping state names to integers', + 'mapping': Parameter('A dictionary mapping state names to integers', datatype=StringType(), export=False), # XXX:!!! } @@ -815,9 +815,9 @@ class PartialDigitalInput(NamedDigitalInput): """ parameters = { - 'startbit': Param('Number of the first bit', + 'startbit': Parameter('Number of the first bit', datatype=IntRange(0), default=0), - 'bitwidth': Param('Number of bits', + 'bitwidth': Parameter('Number of bits', datatype=IntRange(0), default=1), } @@ -859,7 +859,7 @@ class NamedDigitalOutput(DigitalOutput): """ parameters = { - 'mapping': Param('A dictionary mapping state names to integers', + 'mapping': Parameter('A dictionary mapping state names to integers', datatype=StringType(), export=False), } @@ -885,9 +885,9 @@ class PartialDigitalOutput(NamedDigitalOutput): """ parameters = { - 'startbit': Param('Number of the first bit', + 'startbit': Parameter('Number of the first bit', datatype=IntRange(0), default=0), - 'bitwidth': Param('Number of bits', + 'bitwidth': Parameter('Number of bits', datatype=IntRange(0), default=1), } @@ -916,13 +916,13 @@ class StringIO(PyTangoDevice, Module): """ parameters = { - 'bustimeout': Param('Communication timeout', + 'bustimeout': Parameter('Communication timeout', datatype=FloatRange(), readonly=False, unit='s', group='communication'), - 'endofline': Param('End of line', + 'endofline': Parameter('End of line', datatype=StringType(), readonly=False, group='communication'), - 'startofline': Param('Start of line', + 'startofline': Parameter('Start of line', datatype=StringType(), readonly=False, group='communication'), }