result from merge with gerrit
secop subdir only Change-Id: I65ab7049719b374ae3ec0259483e7e7d16aafcd1
This commit is contained in:
@ -26,12 +26,11 @@
|
||||
import inspect
|
||||
|
||||
from secop.datatypes import BoolType, CommandType, DataType, \
|
||||
DataTypeType, EnumType, IntRange, NoneOr, OrType, FloatRange, \
|
||||
StringType, StructOf, TextType, TupleOf, ValueType, ArrayOf
|
||||
DataTypeType, EnumType, NoneOr, OrType, \
|
||||
StringType, StructOf, TextType, TupleOf, ValueType
|
||||
from secop.errors import BadValueError, ProgrammingError
|
||||
from secop.properties import HasProperties, Property
|
||||
|
||||
UNSET = object() # an argument not given, not even None
|
||||
from secop.lib import generalConfig
|
||||
|
||||
|
||||
class Accessible(HasProperties):
|
||||
@ -94,11 +93,6 @@ class Accessible(HasProperties):
|
||||
return '%s(%s)' % (self.__class__.__name__, ', '.join(props))
|
||||
|
||||
|
||||
historyStruct = StructOf(category=StringType(), label=StringType(), group=StringType(),
|
||||
stepped=OrType(BoolType(), StringType()), timestep=FloatRange(0, 1),
|
||||
record_unchanged=BoolType())
|
||||
|
||||
|
||||
class Parameter(Accessible):
|
||||
"""defines a parameter
|
||||
|
||||
@ -139,24 +133,9 @@ class Parameter(Accessible):
|
||||
* True: exported, name automatic.
|
||||
* a string: exported with custom name''', OrType(BoolType(), StringType()),
|
||||
export=False, default=True)
|
||||
poll = Property(
|
||||
'''[internal] polling indicator
|
||||
|
||||
may be:
|
||||
|
||||
* None (omitted): will be converted to True/False if handler is/is not None
|
||||
* False or 0 (never poll this parameter)
|
||||
* True or 1 (AUTO), converted to SLOW (readonly=False)
|
||||
DYNAMIC (*status* and *value*) or REGULAR (else)
|
||||
* 2 (SLOW), polled with lower priority and a multiple of pollinterval
|
||||
* 3 (REGULAR), polled with pollperiod
|
||||
* 4 (DYNAMIC), if BUSY, with a fraction of pollinterval,
|
||||
else polled with pollperiod
|
||||
''', NoneOr(IntRange()),
|
||||
export=False, default=None)
|
||||
needscfg = Property(
|
||||
'[internal] needs value in config', NoneOr(BoolType()),
|
||||
export=False, default=None)
|
||||
export=False, default=False)
|
||||
optional = Property(
|
||||
'[internal] is this parameter optional?', BoolType(),
|
||||
export=False, settable=False, default=False)
|
||||
@ -168,35 +147,6 @@ class Parameter(Accessible):
|
||||
|
||||
default None: write if given in config''', NoneOr(BoolType()),
|
||||
export=False, default=None, settable=False)
|
||||
history = Property(
|
||||
'''[custom] options for history
|
||||
|
||||
for structured types, this is an array of options, to be applied in the order
|
||||
of the created elements.
|
||||
|
||||
list of options:
|
||||
|
||||
category
|
||||
- major: should be shown by default in a history chart, default for value and target
|
||||
- minor: to be shown optionally in a history chart, default for other parameters
|
||||
- no: history is not saved. default for TextType and ArrayOf
|
||||
|
||||
category is ignored (forced to no) for BlobType
|
||||
|
||||
label
|
||||
default: <modname>:<parname> or <modname> for main value
|
||||
|
||||
group:
|
||||
default: unit
|
||||
|
||||
stepped:
|
||||
whether a curve has to be drawn stepped or connected.
|
||||
default: True when readonly=False, else False
|
||||
|
||||
timestep:
|
||||
the desired time step for the curve storage. maximum and default value is 1 sec
|
||||
''',
|
||||
OrType(historyStruct, ArrayOf(historyStruct)), export=True, default={}, settable=False)
|
||||
|
||||
# used on the instance copy only
|
||||
value = None
|
||||
@ -205,6 +155,8 @@ class Parameter(Accessible):
|
||||
|
||||
def __init__(self, description=None, datatype=None, inherit=True, **kwds):
|
||||
super().__init__()
|
||||
if 'poll' in kwds and generalConfig.tolerate_poll_property:
|
||||
kwds.pop('poll')
|
||||
if datatype is None:
|
||||
# collect datatype properties. these are not applied, as we have no datatype
|
||||
self.ownProperties = {k: kwds.pop(k) for k in list(kwds) if k not in self.propertyDict}
|
||||
@ -232,7 +184,6 @@ class Parameter(Accessible):
|
||||
self.ownProperties = {k: getattr(self, k) for k in self.propertyDict}
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
# not used yet
|
||||
if instance is None:
|
||||
return self
|
||||
return instance.parameters[self.name].value
|
||||
@ -253,6 +204,9 @@ class Parameter(Accessible):
|
||||
self.export = '_' + self.name
|
||||
else:
|
||||
raise ProgrammingError('can not use %r as name of a Parameter' % self.name)
|
||||
if 'export' in self.ownProperties:
|
||||
# avoid export=True overrides export=<name>
|
||||
self.ownProperties['export'] = self.export
|
||||
|
||||
def copy(self):
|
||||
"""return a (deep) copy of ourselfs"""
|
||||
@ -418,6 +372,9 @@ class Command(Accessible):
|
||||
self.export = '_' + name
|
||||
else:
|
||||
raise ProgrammingError('can not use %r as name of a Command' % name) from None
|
||||
if 'export' in self.ownProperties:
|
||||
# avoid export=True overrides export=<name>
|
||||
self.ownProperties['export'] = self.export
|
||||
if not self._inherit:
|
||||
for key, pobj in self.properties.items():
|
||||
if key not in self.propertyValues:
|
||||
|
Reference in New Issue
Block a user