make return value 'Done' unneccessary

'Done' was introduced in order to suppress unneccessary
duplicate updates. However, since super calls on access methods are
allowed, it is not nice when such a method returns Done, as this
is not automagically replaced by the current parameter value.
As a consequence:

- using Done is discouraged, but not (yet) removed in all code
- the 'omit_unchanged_within' property is moved from Module to an
  internal Parameter property 'update_unchanged'
- its default is moved from a SEC node property to generalConfig
- the 'update_unchanged' parameter property may be set to
  'never' for parameters where duplicate updates make no sense
- this property might be set to 'always', for measurements, where
  even unchanged values taken from HW should be transmitted

Change-Id: I2847c983ca09c2c4098e402edd08d0c96c3913f4
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30672
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2023-03-13 17:16:07 +01:00
parent c41eefba51
commit b80d39773b
22 changed files with 177 additions and 119 deletions

View File

@@ -58,7 +58,6 @@ Example 2: addressable HW parameters
"""
import functools
from frappy.modules import Done
from frappy.errors import ProgrammingError
@@ -134,8 +133,6 @@ class ReadHandler(Handler):
def method(module, pname=key, func=self.func):
with module.accessLock:
value = func(module, pname)
if value is Done:
return getattr(module, pname)
setattr(module, pname, value)
return value
@@ -156,7 +153,7 @@ class CommonReadHandler(ReadHandler):
def method(module, pname=key, func=self.func):
with module.accessLock:
ret = func(module)
if ret not in (None, Done):
if ret is not None:
raise ProgrammingError('a method wrapped with CommonReadHandler must not return any value')
return getattr(module, pname)
@@ -174,8 +171,7 @@ class WriteHandler(Handler):
def method(module, value, pname=key, func=self.func):
with module.accessLock:
value = func(module, pname, value)
if value is not Done:
setattr(module, pname, value)
setattr(module, pname, value)
return value
return method
@@ -217,7 +213,7 @@ class CommonWriteHandler(WriteHandler):
values = WriteParameters(module)
values[pname] = value
ret = func(module, values)
if ret not in (None, Done):
if ret is not None:
raise ProgrammingError('a method wrapped with CommonWriteHandler must not return any value')
# remove pname from writeDict. this was not removed in WriteParameters, as it was not missing
module.writeDict.pop(pname, None)