fix issues with sea is_running

This commit is contained in:
zolliker 2021-04-26 11:56:48 +02:00
parent 99eb600d90
commit 8b2c5f6144

View File

@ -318,7 +318,7 @@ class SeaClient(ProxyClient, Module):
elif reply is None: elif reply is None:
reply = line.strip() reply = line.strip()
else: else:
raise HardwareError('SEA: superfluous reply %r to %r' % (reply, cmd)) self.log.info('SEA: superfluous reply %r to %r', reply, cmd)
if errors: if errors:
raise HardwareError('; '.join(errors)) raise HardwareError('; '.join(errors))
return reply return reply
@ -401,9 +401,12 @@ class SeaModule(Module):
include = True include = True
for paramdesc in descr['params']: for paramdesc in descr['params']:
path = paramdesc['path'] path = paramdesc['path']
if path.endswith('is_running'):
# take this always
result.append(paramdesc)
continue
if paramdesc.get('visibility', 1) > visibility_level: if paramdesc.get('visibility', 1) > visibility_level:
if not path.endswith('is_running'): continue
continue
sub = path.split('/', 1) sub = path.split('/', 1)
if rpath == '.': # take all except subpaths with readonly node at top if rpath == '.': # take all except subpaths with readonly node at top
if len(sub) == 1: if len(sub) == 1:
@ -413,9 +416,12 @@ class SeaModule(Module):
elif sub[0] == rpath: elif sub[0] == rpath:
result.append(paramdesc) result.append(paramdesc)
descr['params'] = result descr['params'] = result
if result[0]['path'] != '': for valuedesc in result:
pass # TODO: check these cases if valuedesc['path'] == '':
result[0]['key'] = 'value' valuedesc['key'] = 'value'
break
else:
logger.error('%s: no value found', name)
# logger.info('PARAMS %s %r', name, result) # logger.info('PARAMS %s %r', name, result)
base = descr['base'] base = descr['base']
params = descr['params'] params = descr['params']
@ -441,7 +447,7 @@ class SeaModule(Module):
if kwds['datatype'] is None: if kwds['datatype'] is None:
kwds.update(visibility=3, default='', datatype=StringType()) kwds.update(visibility=3, default='', datatype=StringType())
pathlist = path.split('/') if path else [] 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 key is None:
if len(pathlist) > 0: if len(pathlist) > 0:
if len(pathlist) == 1: if len(pathlist) == 1:
@ -449,7 +455,6 @@ class SeaModule(Module):
else: else:
kwds['group'] = pathlist[-2] kwds['group'] = pathlist[-2]
# flatten path to parameter name # flatten path to parameter name
key = None
for i in reversed(range(len(pathlist))): for i in reversed(range(len(pathlist))):
key = '_'.join(pathlist[i:]) key = '_'.join(pathlist[i:])
if not key in cls.accessibles: if not key in cls.accessibles:
@ -469,15 +474,12 @@ class SeaModule(Module):
extra_modules[name + '.' + key] = sea_object, base, paramdesc extra_modules[name + '.' + key] = sea_object, base, paramdesc
continue # skip this parameter continue # skip this parameter
path2param[hdbpath] = (name, key) path2param[hdbpath] = (name, key)
# logger.info('PARAM %s %s %s', hdbpath, name, key)
attributes[key] = pobj attributes[key] = pobj
# if hasattr(cls, 'read_' + key): # if hasattr(cls, 'read_' + key):
# print('override %s.read_%s' % (cls.__name__, key)) # print('override %s.read_%s' % (cls.__name__, key))
def rfunc(self, cmd='hval /sics/%s/%s' % (sea_object, path)): def rfunc(self, cmd='hval %s/%s' % (base, path)):
print('READ', cmd)
reply = self._iodev.query(cmd) reply = self._iodev.query(cmd)
print('REPLY', reply)
try: try:
reply = float(reply) reply = float(reply)
except ValueError: except ValueError:
@ -488,8 +490,8 @@ class SeaModule(Module):
attributes['read_' + key] = rfunc attributes['read_' + key] = rfunc
if not readonly: if not readonly:
if hasattr(cls, 'write_' + key): # if hasattr(cls, 'write_' + key):
print('override %s.write_%s' % (cls.__name__, key)) # print('override %s.write_%s' % (cls.__name__, key))
def wfunc(self, value, datatype=datatype, command=paramdesc['cmd']): def wfunc(self, value, datatype=datatype, command=paramdesc['cmd']):
value = datatype.export_value(value) 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?) # TODO: check if more has to be done for valid tcl data (strings?)
cmd = "%s %s" % (command, value) cmd = "%s %s" % (command, value)
self._iodev.query(cmd) self._iodev.query(cmd)
print('WRITE %s' % cmd)
return Done return Done
attributes['write_' + key] = wfunc attributes['write_' + key] = wfunc