frappy.modulebase: fix missing update after error on parameter
This commit is contained in:
parent
5a54503fe7
commit
a44f3fae50
@ -260,7 +260,6 @@ class ProxyClient:
|
|||||||
cblist = self.callbacks[cbname].get(key, [])
|
cblist = self.callbacks[cbname].get(key, [])
|
||||||
for cbfunc in list(cblist):
|
for cbfunc in list(cblist):
|
||||||
try:
|
try:
|
||||||
# print("CALLBACK", cbname, repr(key), *args)
|
|
||||||
cbfunc(*args)
|
cbfunc(*args)
|
||||||
except UnregisterCallback:
|
except UnregisterCallback:
|
||||||
cblist.remove(cbfunc)
|
cblist.remove(cbfunc)
|
||||||
@ -495,8 +494,6 @@ class SecopClient(ProxyClient):
|
|||||||
return
|
return
|
||||||
if self.activate:
|
if self.activate:
|
||||||
self.log.info('try to reconnect to %s', self.uri)
|
self.log.info('try to reconnect to %s', self.uri)
|
||||||
if self._connthread:
|
|
||||||
print('WARN connthread is still there')
|
|
||||||
self._connthread = mkthread(self._reconnect)
|
self._connthread = mkthread(self._reconnect)
|
||||||
else:
|
else:
|
||||||
self.log.warning('%s disconnected', self.uri)
|
self.log.warning('%s disconnected', self.uri)
|
||||||
@ -513,15 +510,11 @@ class SecopClient(ProxyClient):
|
|||||||
def _reconnect(self, connected_callback=None):
|
def _reconnect(self, connected_callback=None):
|
||||||
while not self._shutdown.is_set():
|
while not self._shutdown.is_set():
|
||||||
try:
|
try:
|
||||||
# print('_reconnect_connect')
|
|
||||||
self.connect()
|
self.connect()
|
||||||
# print('_reconnect_success')
|
|
||||||
if connected_callback:
|
if connected_callback:
|
||||||
connected_callback()
|
connected_callback()
|
||||||
# print('_reconnect_break')
|
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# print('_reconnect_exc', e)
|
|
||||||
txt = str(e).split('\n', 1)[0]
|
txt = str(e).split('\n', 1)[0]
|
||||||
if txt != self._last_error:
|
if txt != self._last_error:
|
||||||
self._last_error = txt
|
self._last_error = txt
|
||||||
|
@ -524,7 +524,7 @@ class Module(HasAccessibles):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
err = e
|
err = e
|
||||||
else:
|
else:
|
||||||
changed = pobj.value != value
|
changed = pobj.value != value or pobj.readerror
|
||||||
# store the value even in case of error
|
# store the value even in case of error
|
||||||
pobj.value = value
|
pobj.value = value
|
||||||
if err:
|
if err:
|
||||||
|
@ -31,9 +31,6 @@ from frappy.io import HasIO
|
|||||||
|
|
||||||
|
|
||||||
DISCONNECTED = Readable.Status.ERROR, 'disconnected'
|
DISCONNECTED = Readable.Status.ERROR, 'disconnected'
|
||||||
ACTIVATING = Readable.Status.IDLE, 'activating'
|
|
||||||
CONNECTED = Readable.Status.IDLE, 'connected'
|
|
||||||
CONN_STATI = {DISCONNECTED, ACTIVATING, CONNECTED}
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyModule(HasIO, Module):
|
class ProxyModule(HasIO, Module):
|
||||||
@ -41,6 +38,7 @@ class ProxyModule(HasIO, Module):
|
|||||||
status = Parameter('connection status', Readable.status.datatype) # add status even when not a Readable
|
status = Parameter('connection status', Readable.status.datatype) # add status even when not a Readable
|
||||||
|
|
||||||
_consistency_check_done = False
|
_consistency_check_done = False
|
||||||
|
_connection_status = None # status when not connected
|
||||||
_secnode = None
|
_secnode = None
|
||||||
enablePoll = False
|
enablePoll = False
|
||||||
|
|
||||||
@ -51,6 +49,8 @@ class ProxyModule(HasIO, Module):
|
|||||||
def updateEvent(self, module, parameter, value, timestamp, readerror):
|
def updateEvent(self, module, parameter, value, timestamp, readerror):
|
||||||
if parameter not in self.parameters:
|
if parameter not in self.parameters:
|
||||||
return # ignore unknown parameters
|
return # ignore unknown parameters
|
||||||
|
if parameter == 'status' and not readerror:
|
||||||
|
self._connection_status = None
|
||||||
# should be done here: deal with clock differences
|
# should be done here: deal with clock differences
|
||||||
self.announceUpdate(parameter, value, readerror, timestamp)
|
self.announceUpdate(parameter, value, readerror, timestamp)
|
||||||
|
|
||||||
@ -115,21 +115,17 @@ class ProxyModule(HasIO, Module):
|
|||||||
|
|
||||||
def nodeStateChange(self, online, state):
|
def nodeStateChange(self, online, state):
|
||||||
if online:
|
if online:
|
||||||
if state == 'activating':
|
if not self._consistency_check_done:
|
||||||
self.status = ACTIVATING
|
self._check_descriptive_data()
|
||||||
else:
|
self._consistency_check_done = True
|
||||||
if not self._consistency_check_done:
|
if self._connection_status:
|
||||||
self._check_descriptive_data()
|
self.status = Readable.Status.IDLE, state
|
||||||
self._consistency_check_done = True
|
|
||||||
if self.status[0] in CONN_STATI:
|
|
||||||
# avoid overriding remote status
|
|
||||||
self.status = CONNECTED
|
|
||||||
else:
|
else:
|
||||||
readerror = CommunicationFailedError('disconnected')
|
readerror = CommunicationFailedError('disconnected')
|
||||||
if self.status != DISCONNECTED:
|
if self.status != DISCONNECTED:
|
||||||
for pname in set(self.parameters) - set(('module', 'status')):
|
for pname in set(self.parameters) - set(('module', 'status')):
|
||||||
self.announceUpdate(pname, None, readerror)
|
self.announceUpdate(pname, None, readerror)
|
||||||
self.status = DISCONNECTED
|
self.status = self._connection_status = DISCONNECTED
|
||||||
|
|
||||||
def checkProperties(self):
|
def checkProperties(self):
|
||||||
pass # skip
|
pass # skip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user