From 8b2c5f6144626f80c0a74de06415fce82fd7a696 Mon Sep 17 00:00:00 2001 From: SANS Date: Mon, 26 Apr 2021 11:56:48 +0200 Subject: [PATCH] fix issues with sea is_running --- secop_psi/sea.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/secop_psi/sea.py b/secop_psi/sea.py index 24eb07d..3cdf240 100644 --- a/secop_psi/sea.py +++ b/secop_psi/sea.py @@ -318,7 +318,7 @@ class SeaClient(ProxyClient, Module): elif reply is None: reply = line.strip() else: - raise HardwareError('SEA: superfluous reply %r to %r' % (reply, cmd)) + self.log.info('SEA: superfluous reply %r to %r', reply, cmd) if errors: raise HardwareError('; '.join(errors)) return reply @@ -401,9 +401,12 @@ class SeaModule(Module): include = True for paramdesc in descr['params']: path = paramdesc['path'] + if path.endswith('is_running'): + # take this always + result.append(paramdesc) + continue if paramdesc.get('visibility', 1) > visibility_level: - if not path.endswith('is_running'): - continue + continue sub = path.split('/', 1) if rpath == '.': # take all except subpaths with readonly node at top if len(sub) == 1: @@ -413,9 +416,12 @@ class SeaModule(Module): elif sub[0] == rpath: result.append(paramdesc) descr['params'] = result - if result[0]['path'] != '': - pass # TODO: check these cases - result[0]['key'] = 'value' + for valuedesc in result: + if valuedesc['path'] == '': + valuedesc['key'] = 'value' + break + else: + logger.error('%s: no value found', name) # logger.info('PARAMS %s %r', name, result) base = descr['base'] params = descr['params'] @@ -441,7 +447,7 @@ class SeaModule(Module): if kwds['datatype'] is None: kwds.update(visibility=3, default='', datatype=StringType()) pathlist = path.split('/') if path else [] - key = paramdesc.get('key') # will be None, 'value' or 'target' + key = paramdesc.get('key') # None, 'value' or 'target' if key is None: if len(pathlist) > 0: if len(pathlist) == 1: @@ -449,7 +455,6 @@ class SeaModule(Module): else: kwds['group'] = pathlist[-2] # flatten path to parameter name - key = None for i in reversed(range(len(pathlist))): key = '_'.join(pathlist[i:]) if not key in cls.accessibles: @@ -469,15 +474,12 @@ class SeaModule(Module): extra_modules[name + '.' + key] = sea_object, base, paramdesc continue # skip this parameter path2param[hdbpath] = (name, key) - # logger.info('PARAM %s %s %s', hdbpath, name, key) attributes[key] = pobj # if hasattr(cls, 'read_' + key): # print('override %s.read_%s' % (cls.__name__, key)) - def rfunc(self, cmd='hval /sics/%s/%s' % (sea_object, path)): - print('READ', cmd) + def rfunc(self, cmd='hval %s/%s' % (base, path)): reply = self._iodev.query(cmd) - print('REPLY', reply) try: reply = float(reply) except ValueError: @@ -488,8 +490,8 @@ class SeaModule(Module): attributes['read_' + key] = rfunc if not readonly: - if hasattr(cls, 'write_' + key): - print('override %s.write_%s' % (cls.__name__, key)) + # if hasattr(cls, 'write_' + key): + # print('override %s.write_%s' % (cls.__name__, key)) def wfunc(self, value, datatype=datatype, command=paramdesc['cmd']): value = datatype.export_value(value) @@ -498,7 +500,6 @@ class SeaModule(Module): # TODO: check if more has to be done for valid tcl data (strings?) cmd = "%s %s" % (command, value) self._iodev.query(cmd) - print('WRITE %s' % cmd) return Done attributes['write_' + key] = wfunc