enhance documentation
- flatten hierarchy (some links do not work when using folders) + fix a bug with the redorder flag in Override + allow removal of parameters + clean description using inspect.cleandoc Change-Id: I3dde4f4cb29c46e8a21014f1fad7aa3ad610a1bf
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
|
||||
from collections import OrderedDict
|
||||
from inspect import cleandoc
|
||||
|
||||
from secop.datatypes import CommandType, DataType, StringType, BoolType, EnumType, DataTypeType, ValueType, OrType, \
|
||||
NoneOr, TextType, IntRange
|
||||
@@ -88,18 +89,30 @@ class Parameter(Accessible):
|
||||
extname='visibility', default=1),
|
||||
'constant': Property('optional constant value for constant parameters', ValueType(),
|
||||
extname='constant', default=None, mandatory=False),
|
||||
'default': Property('default (startup) value of this parameter if it can not be read from the hardware.',
|
||||
ValueType(), export=False, default=None, mandatory=False),
|
||||
'export': Property('[internal] is this parameter accessible via SECoP? (vs. internal parameter)',
|
||||
OrType(BoolType(), StringType()), export=False, default=True),
|
||||
'poll': Property('[internal] polling indicator, may be:\n' + '\n '.join(['',
|
||||
'* 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']),
|
||||
'default': Property('[internal] default (startup) value of this parameter '
|
||||
'if it can not be read from the hardware.',
|
||||
ValueType(), export=False, default=None, mandatory=False),
|
||||
'export': Property('''
|
||||
[internal] export settings
|
||||
|
||||
* False: not accessible via SECoP.
|
||||
* 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),
|
||||
'optional': Property('[internal] is this parameter optional?', BoolType(), export=False,
|
||||
@@ -124,7 +137,7 @@ class Parameter(Accessible):
|
||||
raise ProgrammingError(
|
||||
'datatype MUST be derived from class DataType!')
|
||||
|
||||
kwds['description'] = description
|
||||
kwds['description'] = cleandoc(description)
|
||||
kwds['datatype'] = datatype
|
||||
kwds['readonly'] = kwds.get('readonly', True) # for frappy optional, for SECoP mandatory
|
||||
if unit is not None: # for legacy code only
|
||||
@@ -213,7 +226,7 @@ class Commands(Parameters):
|
||||
|
||||
|
||||
class Override(CountedObj):
|
||||
"""Stores the overrides to be applied to a Parameter
|
||||
"""Stores the overrides to be applied to a Parameter or Command
|
||||
|
||||
note: overrides are applied by the metaclass during class creating
|
||||
reorder=True: use position of Override instead of inherited for the order
|
||||
@@ -224,7 +237,7 @@ class Override(CountedObj):
|
||||
self.reorder = reorder
|
||||
# allow to override description and datatype without keyword
|
||||
if description:
|
||||
self.kwds['description'] = description
|
||||
self.kwds['description'] = cleandoc(description)
|
||||
if datatype is not None:
|
||||
self.kwds['datatype'] = datatype
|
||||
# for now, do not use the Override ctr
|
||||
@@ -252,12 +265,10 @@ class Override(CountedObj):
|
||||
props.update(self.kwds)
|
||||
|
||||
if self.reorder:
|
||||
#props['ctr'] = self.ctr
|
||||
return type(obj)(ctr=self.ctr, **props)
|
||||
return type(obj)(**props)
|
||||
return type(obj)(**props)
|
||||
return type(obj)(ctr=self.ctr, **props)
|
||||
raise ProgrammingError(
|
||||
"Overrides can only be applied to Accessibles, %r is none!" %
|
||||
obj)
|
||||
"Overrides can only be applied to Accessibles, %r is none!" % obj)
|
||||
|
||||
|
||||
class Command(Accessible):
|
||||
@@ -270,8 +281,13 @@ class Command(Accessible):
|
||||
extname='group', export=True, default=''),
|
||||
'visibility': Property('optional visibility hint', EnumType('visibility', user=1, advanced=2, expert=3),
|
||||
extname='visibility', export=True, default=1),
|
||||
'export': Property('[internal] flag: is the command accessible via SECoP? (vs. pure internal use)',
|
||||
OrType(BoolType(), StringType()), export=False, default=True),
|
||||
'export': Property('''
|
||||
[internal] export settings
|
||||
|
||||
- False: not accessible via SECoP.
|
||||
- True: exported, name automatic.
|
||||
- a string: exported with custom name''',
|
||||
OrType(BoolType(), StringType()), export=False, default=True),
|
||||
'optional': Property('[internal] is the command optional to implement? (vs. mandatory)',
|
||||
BoolType(), export=False, default=False, settable=False),
|
||||
'datatype': Property('[internal] datatype of the command, auto generated from \'argument\' and \'result\'',
|
||||
@@ -283,7 +299,7 @@ class Command(Accessible):
|
||||
}
|
||||
|
||||
def __init__(self, description, ctr=None, **kwds):
|
||||
kwds['description'] = description
|
||||
kwds['description'] = cleandoc(description)
|
||||
kwds['datatype'] = CommandType(kwds.get('argument', None), kwds.get('result', None))
|
||||
super(Command, self).__init__(**kwds)
|
||||
if ctr is not None:
|
||||
|
||||
Reference in New Issue
Block a user