sea: allow multiple parameters being updated with one hdb path
This commit is contained in:
parent
268ebbe00e
commit
2cd66c2e08
@ -121,7 +121,7 @@ class SeaClient(ProxyClient, Module):
|
|||||||
if port is None:
|
if port is None:
|
||||||
raise ConfigError('missing sea port for %s' % instance)
|
raise ConfigError('missing sea port for %s' % instance)
|
||||||
opts['uri'] = 'tcp://localhost:%s' % port
|
opts['uri'] = 'tcp://localhost:%s' % port
|
||||||
self.objects = []
|
self.objects = set()
|
||||||
self.shutdown = False
|
self.shutdown = False
|
||||||
self.path2param = {}
|
self.path2param = {}
|
||||||
self._write_lock = threading.Lock()
|
self._write_lock = threading.Lock()
|
||||||
@ -134,8 +134,9 @@ class SeaClient(ProxyClient, Module):
|
|||||||
Module.__init__(self, name, log, opts, srv)
|
Module.__init__(self, name, log, opts, srv)
|
||||||
|
|
||||||
def register_obj(self, module, obj):
|
def register_obj(self, module, obj):
|
||||||
self.objects.append(obj)
|
self.objects.add(obj)
|
||||||
self.path2param.update(module.path2param)
|
for k, v in module.path2param.items():
|
||||||
|
self.path2param.setdefault(k, []).extend(v)
|
||||||
self.register_callback(module.name, module.updateEvent)
|
self.register_callback(module.name, module.updateEvent)
|
||||||
|
|
||||||
def startModule(self, start_events):
|
def startModule(self, start_events):
|
||||||
@ -272,9 +273,8 @@ class SeaClient(ProxyClient, Module):
|
|||||||
readerror = HardwareError(value)
|
readerror = HardwareError(value)
|
||||||
path = path.rsplit('.', 1)[0]
|
path = path.rsplit('.', 1)[0]
|
||||||
value = None
|
value = None
|
||||||
try:
|
mplist = self.path2param.get(path)
|
||||||
module, param = self.path2param[path]
|
if mplist is None:
|
||||||
except KeyError:
|
|
||||||
if path.startswith('/device'):
|
if path.startswith('/device'):
|
||||||
if path == '/device/changetime':
|
if path == '/device/changetime':
|
||||||
result = self.request('check_config %s %s' % (self.service, self.config))
|
result = self.request('check_config %s %s' % (self.service, self.config))
|
||||||
@ -284,8 +284,8 @@ class SeaClient(ProxyClient, Module):
|
|||||||
self.DISPATCHER.shutdown()
|
self.DISPATCHER.shutdown()
|
||||||
elif path.startswith('/device/frappy_%s' % self.service) and value == '':
|
elif path.startswith('/device/frappy_%s' % self.service) and value == '':
|
||||||
self.DISPATCHER.shutdown()
|
self.DISPATCHER.shutdown()
|
||||||
# print('UNUSED', msg)
|
else:
|
||||||
continue # unused parameter
|
for module, param in mplist:
|
||||||
oldv, oldt, oldr = self.cache.get((module, param), [None, None, None])
|
oldv, oldt, oldr = self.cache.get((module, param), [None, None, None])
|
||||||
if value is None:
|
if value is None:
|
||||||
value = oldv
|
value = oldv
|
||||||
@ -293,7 +293,6 @@ class SeaClient(ProxyClient, Module):
|
|||||||
# do not update unchanged values within 60 sec
|
# do not update unchanged values within 60 sec
|
||||||
self.updateValue(module, param, value, now, readerror)
|
self.updateValue(module, param, value, now, readerror)
|
||||||
|
|
||||||
|
|
||||||
@Command(StringType(), result=StringType())
|
@Command(StringType(), result=StringType())
|
||||||
def communicate(self, command):
|
def communicate(self, command):
|
||||||
"""send a command to SEA"""
|
"""send a command to SEA"""
|
||||||
@ -453,8 +452,8 @@ 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'):
|
if path.endswith('is_running') and issubclass(cls, Drivable):
|
||||||
# take this always
|
# take this independent of visibility
|
||||||
is_running = paramdesc
|
is_running = paramdesc
|
||||||
continue
|
continue
|
||||||
if paramdesc.get('visibility', 1) > visibility_level:
|
if paramdesc.get('visibility', 1) > visibility_level:
|
||||||
@ -550,7 +549,7 @@ class SeaModule(Module):
|
|||||||
if key in extra_module_set:
|
if key in extra_module_set:
|
||||||
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.setdefault(hdbpath, []).append((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))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user