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:
11
frappy/io.py
11
frappy/io.py
@ -33,7 +33,7 @@ from frappy.datatypes import ArrayOf, BLOBType, BoolType, FloatRange, IntRange,
|
||||
StringType, TupleOf, ValueType
|
||||
from frappy.errors import CommunicationFailedError, ConfigError, ProgrammingError
|
||||
from frappy.modules import Attached, Command, \
|
||||
Communicator, Done, Module, Parameter, Property
|
||||
Communicator, Module, Parameter, Property
|
||||
from frappy.lib import generalConfig
|
||||
|
||||
generalConfig.set_default('legacy_hasiodev', False)
|
||||
@ -110,7 +110,8 @@ class IOBase(Communicator):
|
||||
""", datatype=StringType())
|
||||
timeout = Parameter('timeout', datatype=FloatRange(0), default=2)
|
||||
wait_before = Parameter('wait time before sending', datatype=FloatRange(), default=0)
|
||||
is_connected = Parameter('connection state', datatype=BoolType(), readonly=False, default=False)
|
||||
is_connected = Parameter('connection state', datatype=BoolType(), readonly=False, default=False,
|
||||
update_unchanged='never')
|
||||
pollinterval = Parameter('reconnect interval', datatype=FloatRange(0), readonly=False, default=10)
|
||||
#: a dict of default settings for a device, e.g. for a LakeShore 336:
|
||||
#:
|
||||
@ -151,20 +152,20 @@ class IOBase(Communicator):
|
||||
self.is_connected is changed only by self.connectStart or self.closeConnection
|
||||
"""
|
||||
if self.is_connected:
|
||||
return Done # no need for intermediate updates
|
||||
return True
|
||||
try:
|
||||
self.connectStart()
|
||||
if self._last_error:
|
||||
self.log.info('connected')
|
||||
self._last_error = 'connected'
|
||||
self.callCallbacks()
|
||||
return Done
|
||||
return self.is_connected
|
||||
except Exception as e:
|
||||
if str(e) != self._last_error:
|
||||
self._last_error = str(e)
|
||||
self.log.error(self._last_error)
|
||||
raise SilentError(repr(e)) from e
|
||||
return Done
|
||||
return self.is_connected
|
||||
|
||||
def write_is_connected(self, value):
|
||||
"""value = True: connect if not yet done
|
||||
|
Reference in New Issue
Block a user