From af28511403e58b4eb2810d9aea03fe14023e3937 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Thu, 29 Feb 2024 14:55:42 +0100 Subject: [PATCH] fixes for proxy modules - for the case when the remote module name does not match, 'read', 'change' and 'do' does not work - a proxy to an IO class has enablePoll == False, but it needs a triggerPoll for modules relying on it to work - a proxy on a communicator module has a status even when the remote does not - this needs 2 fixes Change-Id: Icd44da4c2984f27ce7147dec633739f9176012ec Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/33168 Tested-by: Jenkins Automated Tests Reviewed-by: Markus Zolliker --- frappy/modulebase.py | 4 ++++ frappy/proxy.py | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/frappy/modulebase.py b/frappy/modulebase.py index 4f5e2ad..4b30fa3 100644 --- a/frappy/modulebase.py +++ b/frappy/modulebase.py @@ -614,6 +614,10 @@ class Module(HasAccessibles): # enablePoll == False: we still need the poll thread for writing values from writeDict if hasattr(self, 'io'): self.io.polledModules.append(self) + if not self.io.triggerPoll: + # when self.io.enablePoll is False, triggerPoll is not + # created for self.io in the else clause below + self.triggerPoll = threading.Event() else: self.triggerPoll = threading.Event() self.polledModules.append(self) diff --git a/frappy/proxy.py b/frappy/proxy.py index c40a01a..7440323 100644 --- a/frappy/proxy.py +++ b/frappy/proxy.py @@ -71,7 +71,7 @@ class ProxyModule(HasIO, Module): pname, pobj = params.popitem() props = remoteparams.get(pname, None) if props is None: - if pobj.export: + if pobj.export and pname != 'status': self.log.warning('remote parameter %s:%s does not exist', self.module, pname) continue dt = props['datatype'] @@ -108,17 +108,19 @@ class ProxyModule(HasIO, Module): # for now, the error message must be enough def nodeStateChange(self, online, state): + disconnected = Readable.Status.ERROR, 'disconnected' if online: if not self._consistency_check_done: self._check_descriptive_data() self._consistency_check_done = True + if self.status == disconnected: + self.status = Readable.Status.IDLE, 'connected' else: - newstatus = Readable.Status.ERROR, 'disconnected' readerror = CommunicationFailedError('disconnected') - if self.status != newstatus: + if self.status != disconnected: for pname in set(self.parameters) - set(('module', 'status')): self.announceUpdate(pname, None, readerror) - self.announceUpdate('status', newstatus) + self.status = disconnected def checkProperties(self): pass # skip @@ -193,7 +195,7 @@ def proxy_class(remote_class, name=None): attrs[aname] = pobj def rfunc(self, pname=aname): - value, _, readerror = self._secnode.getParameter(self.name, pname, True) + value, _, readerror = self._secnode.getParameter(self.module, pname, True) if readerror: raise readerror return value @@ -203,7 +205,7 @@ def proxy_class(remote_class, name=None): if not pobj.readonly: def wfunc(self, value, pname=aname): - value, _, readerror = self._secnode.setParameter(self.name, pname, value) + value, _, readerror = self._secnode.setParameter(self.module, pname, value) if readerror: raise readerror return value @@ -214,7 +216,7 @@ def proxy_class(remote_class, name=None): cobj = aobj.copy() def cfunc(self, arg=None, cname=aname): - return self._secnode.execCommand(self.name, cname, arg)[0] + return self._secnode.execCommand(self.module, cname, arg)[0] attrs[aname] = cobj(cfunc)