SEA: let tt.value be the sample temperature when dblctrl is on
for this tt has to be a frappy_psi.sea.LscDrivable Change-Id: Ic452b39237d31a7765bc8b2f22a12c2f454fe7da
This commit is contained in:
@ -667,6 +667,11 @@ class SeaModule(Module):
|
|||||||
path2param.setdefault(hdbpath, []).append((name, key))
|
path2param.setdefault(hdbpath, []).append((name, key))
|
||||||
attributes[key] = pobj
|
attributes[key] = pobj
|
||||||
|
|
||||||
|
if key != 'status' and key is not None:
|
||||||
|
rfunc = getattr(cls, f'read_{key}', None)
|
||||||
|
# do not override existing read method
|
||||||
|
if rfunc is None:
|
||||||
|
|
||||||
def rfunc(self, cmd=f'hval {base}/{path}'):
|
def rfunc(self, cmd=f'hval {base}/{path}'):
|
||||||
reply = self.io.query(cmd, True)
|
reply = self.io.query(cmd, True)
|
||||||
try:
|
try:
|
||||||
@ -677,7 +682,6 @@ class SeaModule(Module):
|
|||||||
return reply
|
return reply
|
||||||
|
|
||||||
rfunc.poll = False
|
rfunc.poll = False
|
||||||
if key != 'status' and key is not None:
|
|
||||||
attributes['read_' + key] = rfunc
|
attributes['read_' + key] = rfunc
|
||||||
|
|
||||||
if not readonly and key:
|
if not readonly and key:
|
||||||
@ -724,7 +728,7 @@ class SeaModule(Module):
|
|||||||
if len(sub) > 1 or 'kids' in paramdesc:
|
if len(sub) > 1 or 'kids' in paramdesc:
|
||||||
# avoid params from subtrees
|
# avoid params from subtrees
|
||||||
return False
|
return False
|
||||||
# this is a top paramerter without kids
|
# this is a top parameter without kids
|
||||||
sublist.append(paramdesc)
|
sublist.append(paramdesc)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -856,9 +860,20 @@ class SeaDrivable(SeaReadable, Drivable):
|
|||||||
|
|
||||||
class LscDrivable(SeaDrivable):
|
class LscDrivable(SeaDrivable):
|
||||||
def __new__(cls, name, logger, cfgdict, srv):
|
def __new__(cls, name, logger, cfgdict, srv):
|
||||||
cfgdict['rel_paths'] = [pop_cfg(cfgdict, 'sensor_path', 'tm'), '.',
|
sensor_path = pop_cfg(cfgdict, 'sensor_path', 'tm')
|
||||||
pop_cfg(cfgdict, 'set_path', 'set'), 'dblctrl']
|
set_path = pop_cfg(cfgdict, 'set_path', 'set')
|
||||||
return super().__new__(cls, name, logger, cfgdict, srv)
|
cfgdict['rel_paths'] = ['.', sensor_path, set_path , 'dblctrl']
|
||||||
|
mobj = super().__new__(cls, name, logger, cfgdict, srv)
|
||||||
|
mobj._sensor_path = sensor_path
|
||||||
|
|
||||||
|
def ufunc(value, timestamp, readerror, self=mobj):
|
||||||
|
if not self.dblctrl:
|
||||||
|
self.update_value(value, timestamp, readerror)
|
||||||
|
self.announceUpdate(self._sensor_path, value, readerror, timestamp)
|
||||||
|
|
||||||
|
setattr(mobj, f'update_{sensor_path}', ufunc)
|
||||||
|
mobj._read_value_error = False
|
||||||
|
return mobj
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def paramFilter(cls, result, paramdesc):
|
def paramFilter(cls, result, paramdesc):
|
||||||
@ -869,3 +884,21 @@ class LscDrivable(SeaDrivable):
|
|||||||
result['.'].append(paramdesc)
|
result['.'].append(paramdesc)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def update_value(self, value, timestamp, readerror):
|
||||||
|
self._read_value_error = readerror
|
||||||
|
if self.dblctrl and not readerror:
|
||||||
|
super().update_value(value, timestamp, readerror)
|
||||||
|
|
||||||
|
def read_value(self):
|
||||||
|
if self.io.syncio:
|
||||||
|
try:
|
||||||
|
if self.dblctrl and not self._read_value_error:
|
||||||
|
reply = self.io.query('hval tt', True)
|
||||||
|
else:
|
||||||
|
reply = self.io.query(f'hval tt/{self.rel_paths[1]}', True)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
# an updateEvent will be handled before above returns
|
||||||
|
return float(reply)
|
||||||
|
return self.value
|
||||||
|
Reference in New Issue
Block a user