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 <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
zolliker 2024-02-29 14:55:42 +01:00
parent 9d9d31693b
commit af28511403
2 changed files with 13 additions and 7 deletions

View File

@ -614,6 +614,10 @@ class Module(HasAccessibles):
# enablePoll == False: we still need the poll thread for writing values from writeDict # enablePoll == False: we still need the poll thread for writing values from writeDict
if hasattr(self, 'io'): if hasattr(self, 'io'):
self.io.polledModules.append(self) 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: else:
self.triggerPoll = threading.Event() self.triggerPoll = threading.Event()
self.polledModules.append(self) self.polledModules.append(self)

View File

@ -71,7 +71,7 @@ class ProxyModule(HasIO, Module):
pname, pobj = params.popitem() pname, pobj = params.popitem()
props = remoteparams.get(pname, None) props = remoteparams.get(pname, None)
if props is 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) self.log.warning('remote parameter %s:%s does not exist', self.module, pname)
continue continue
dt = props['datatype'] dt = props['datatype']
@ -108,17 +108,19 @@ class ProxyModule(HasIO, Module):
# for now, the error message must be enough # for now, the error message must be enough
def nodeStateChange(self, online, state): def nodeStateChange(self, online, state):
disconnected = Readable.Status.ERROR, 'disconnected'
if online: if online:
if not self._consistency_check_done: if not self._consistency_check_done:
self._check_descriptive_data() self._check_descriptive_data()
self._consistency_check_done = True self._consistency_check_done = True
if self.status == disconnected:
self.status = Readable.Status.IDLE, 'connected'
else: else:
newstatus = Readable.Status.ERROR, 'disconnected'
readerror = CommunicationFailedError('disconnected') readerror = CommunicationFailedError('disconnected')
if self.status != newstatus: 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.announceUpdate('status', newstatus) self.status = disconnected
def checkProperties(self): def checkProperties(self):
pass # skip pass # skip
@ -193,7 +195,7 @@ def proxy_class(remote_class, name=None):
attrs[aname] = pobj attrs[aname] = pobj
def rfunc(self, pname=aname): 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: if readerror:
raise readerror raise readerror
return value return value
@ -203,7 +205,7 @@ def proxy_class(remote_class, name=None):
if not pobj.readonly: if not pobj.readonly:
def wfunc(self, value, pname=aname): 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: if readerror:
raise readerror raise readerror
return value return value
@ -214,7 +216,7 @@ def proxy_class(remote_class, name=None):
cobj = aobj.copy() cobj = aobj.copy()
def cfunc(self, arg=None, cname=aname): 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) attrs[aname] = cobj(cfunc)