added features

This commit is contained in:
2022-05-30 12:07:33 +02:00
parent 7fc030191d
commit 3e6f1bebf7
3 changed files with 106 additions and 24 deletions

View File

@ -228,6 +228,14 @@ class HasAccessibles(HasProperties):
cls.configurables = res
class Feature(HasAccessibles):
"""all things belonging to a small, predefined functionality influencing the working of a module
a mixin with Feature as a direct base class is recognized as a SECoP feature
and reported in the module property 'features'
"""
class PollInfo:
def __init__(self, pollinterval, trigger_event):
self.interval = pollinterval
@ -292,6 +300,7 @@ class Module(HasAccessibles):
extname='implementation')
interface_classes = Property('offical highest interface-class of the module', ArrayOf(StringType()),
extname='interface_classes')
features = Property('list of features', ArrayOf(StringType()), extname='features')
pollinterval = Property('poll interval for parameters handled by doPoll', FloatRange(0.1, 120), default=5)
slowinterval = Property('poll interval for other parameters', FloatRange(0.1, 120), default=15)
enablePoll = True
@ -350,10 +359,10 @@ class Module(HasAccessibles):
# b.__name__ for b in mycls.__mro__ if b.__module__.startswith('secop.modules')]
# list of only the 'highest' secop module class
self.interface_classes = [
b.__name__ for b in mycls.__mro__ if b.__module__.startswith('secop.modules')][0:1]
b.__name__ for b in mycls.__mro__ if issubclass(Drivable, b)][0:1]
# handle Features
# XXX: todo
self.features = [b.__name__ for b in mycls.__mro__ if Feature in b.__bases__]
# handle accessibles
# 1) make local copies of parameter objects
@ -500,10 +509,11 @@ class Module(HasAccessibles):
# TODO: remove readerror 'property' and replace value with exception
pobj = self.parameters[pname]
timestamp = timestamp or time.time()
changed = pobj.value != value
try:
value = pobj.datatype(value)
changed = pobj.value != value
# store the value even in case of error
pobj.value = pobj.datatype(value)
pobj.value = value
except Exception as e:
if isinstance(e, DiscouragedConversion):
if DiscouragedConversion.log_message:
@ -597,7 +607,7 @@ class Module(HasAccessibles):
self.io.polledModules.append(self)
else:
self.triggerPoll = threading.Event()
self.polledModules = [self]
self.polledModules.append(self)
def startModule(self, start_events):
"""runs after init of all modules