fix initwrite behaviour

with handlers, a parameter from the cfg file which is not the
first of parameters with the same handler were not written.
fix: write_<param> method is called for all parameters in
<module>.writeDict even if there is no poll entry.

with this fix, when a parameter has the property initwrite=True,
the write_<param> method is called even when <param>
is not polled and even when <module>.pollerClass is None

Change-Id: I9b397deb5b20709fc4fa7c860c85b251a204c7f6
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/23995
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2020-09-25 12:05:16 +02:00
parent 7af4d572ab
commit d2c3370a40
4 changed files with 38 additions and 35 deletions

View File

@ -118,8 +118,10 @@ class Poller(PollerBase):
self._stopped = False
self.maxwait = 3600
self.name = name
self.modules = [] # used for writeInitParams only
def add_to_poller(self, module):
self.modules.append(module)
factors = self.DEFAULT_FACTORS.copy()
try:
factors[DYNAMIC] = module.fast_pollfactor
@ -227,11 +229,13 @@ class Poller(PollerBase):
# nothing to do (else we might call time.sleep(float('inf')) below
started_callback()
return
for module in self.modules:
module.writeInitParams()
# do all polls once and, at the same time, insert due info
for _, queue in sorted(self.queues.items()): # do SLOW polls first
for idx, (_, _, (_, module, pobj, pname, factor)) in enumerate(queue):
lastdue = time.time()
module.writeOrPoll(pname)
module.pollOneParam(pname)
due = lastdue + min(self.maxwait, module.pollinterval * factor)
# in python 3 comparing tuples need some care, as not all objects
# are comparable. Inserting a unique idx solves the problem.