secop/modules: make polling thread more robust
Change-Id: I530088d56e31dc2d415cc1c79b1db9d446c0b391 Reviewed-on: https://forge.frm2.tum.de/review/18259 Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de> Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
This commit is contained in:
parent
fb1939d5c8
commit
75e31714b8
@ -231,13 +231,14 @@ class Readable(Module):
|
||||
mkthread(self.__pollThread, started_callback)
|
||||
|
||||
def __pollThread(self, started_callback):
|
||||
try:
|
||||
self.__pollThread_inner(started_callback)
|
||||
except Exception as e:
|
||||
self.log.exception(e)
|
||||
self.status = (self.Status.ERROR, 'polling thread could not start')
|
||||
started_callback(self)
|
||||
print(formatExtendedStack())
|
||||
while True:
|
||||
try:
|
||||
self.__pollThread_inner(started_callback)
|
||||
except Exception as e:
|
||||
self.log.exception(e)
|
||||
self.status = (self.Status.ERROR, 'polling thread could not start')
|
||||
started_callback(self)
|
||||
print(formatExtendedStack())
|
||||
|
||||
def __pollThread_inner(self, started_callback):
|
||||
"""super simple and super stupid per-module polling thread"""
|
||||
|
@ -379,8 +379,8 @@ class AnalogInput(PyTangoDevice, Readable):
|
||||
The AnalogInput handles all devices only delivering an analogue value.
|
||||
"""
|
||||
|
||||
def late_init(self):
|
||||
super(AnalogInput, self).late_init()
|
||||
def late_init(self, started_callback):
|
||||
super(AnalogInput, self).late_init(started_callback)
|
||||
# query unit from tango and update value property
|
||||
attrInfo = self._dev.attribute_query('value')
|
||||
# prefer configured unit if nothing is set on the Tango device, else
|
||||
@ -459,8 +459,8 @@ class AnalogOutput(PyTangoDevice, Drivable):
|
||||
self._history = [] # will keep (timestamp, value) tuple
|
||||
self._timeout = None # keeps the time at which we will timeout, or None
|
||||
|
||||
def late_init(self):
|
||||
super(AnalogOutput, self).late_init()
|
||||
def late_init(self, started_callback):
|
||||
super(AnalogOutput, self).late_init(started_callback)
|
||||
# query unit from tango and update value property
|
||||
attrInfo = self._dev.attribute_query('value')
|
||||
# prefer configured unit if nothing is set on the Tango device, else
|
||||
@ -497,6 +497,8 @@ class AnalogOutput(PyTangoDevice, Drivable):
|
||||
hist = self._history[:]
|
||||
window_start = currenttime() - self.window
|
||||
hist_in_window = [v for (t, v) in hist if t >= window_start]
|
||||
if not hist_in_window:
|
||||
return False # no relevant history -> no knowledge
|
||||
|
||||
max_in_hist = max(hist_in_window)
|
||||
min_in_hist = min(hist_in_window)
|
||||
|
Loading…
x
Reference in New Issue
Block a user