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:
@ -39,7 +39,7 @@ switcher=sw
|
||||
import time
|
||||
|
||||
from frappy.datatypes import IntRange, BoolType, FloatRange
|
||||
from frappy.core import Attached, Property, Drivable, Parameter, Readable, Done
|
||||
from frappy.core import Attached, Property, Drivable, Parameter, Readable
|
||||
|
||||
|
||||
class ChannelSwitcher(Drivable):
|
||||
@ -55,6 +55,7 @@ class ChannelSwitcher(Drivable):
|
||||
"""
|
||||
value = Parameter('the current channel number', IntRange(), needscfg=False)
|
||||
target = Parameter('channel to select', IntRange(), needscfg=False)
|
||||
status = Parameter(update_unchanged='never')
|
||||
autoscan = Parameter('whether to scan automatically',
|
||||
BoolType(), readonly=False, default=True)
|
||||
pollinterval = Parameter(default=1, export=False)
|
||||
@ -108,7 +109,7 @@ class ChannelSwitcher(Drivable):
|
||||
if self.status[0] == 'BUSY':
|
||||
chan = self._channels[self.target]
|
||||
if chan.is_switching(now, self._start_switch, self.switch_delay):
|
||||
return Done
|
||||
return self.status
|
||||
self.setFastPoll(False)
|
||||
self.status = 'IDLE', 'measure'
|
||||
self.value = self.target
|
||||
@ -116,7 +117,7 @@ class ChannelSwitcher(Drivable):
|
||||
chan.read_value()
|
||||
chan.read_status()
|
||||
if self.measure_delay > self._time_tol:
|
||||
return Done
|
||||
return self.status
|
||||
else:
|
||||
chan = self._channels[self.value]
|
||||
self.read_value() # this might modify autoscan or deadline!
|
||||
@ -129,7 +130,7 @@ class ChannelSwitcher(Drivable):
|
||||
chan.read_status()
|
||||
self._last_measure = next_measure
|
||||
if not self.autoscan or now + self._time_tol < self._start_measure + self.measure_delay:
|
||||
return Done
|
||||
return self.status
|
||||
next_channel = self.next_channel(self.value)
|
||||
if next_channel == self.value:
|
||||
return 'IDLE', 'single channel'
|
||||
|
Reference in New Issue
Block a user