diff --git a/secop_psi/sea.py b/secop_psi/sea.py index 749207c..d16bfad 100644 --- a/secop_psi/sea.py +++ b/secop_psi/sea.py @@ -121,7 +121,7 @@ class SeaClient(ProxyClient, Module): if port is None: raise ConfigError('missing sea port for %s' % instance) opts['uri'] = 'tcp://localhost:%s' % port - self.objects = [] + self.objects = set() self.shutdown = False self.path2param = {} self._write_lock = threading.Lock() @@ -134,8 +134,9 @@ class SeaClient(ProxyClient, Module): Module.__init__(self, name, log, opts, srv) def register_obj(self, module, obj): - self.objects.append(obj) - self.path2param.update(module.path2param) + self.objects.add(obj) + for k, v in module.path2param.items(): + self.path2param.setdefault(k, []).extend(v) self.register_callback(module.name, module.updateEvent) def startModule(self, start_events): @@ -272,9 +273,8 @@ class SeaClient(ProxyClient, Module): readerror = HardwareError(value) path = path.rsplit('.', 1)[0] value = None - try: - module, param = self.path2param[path] - except KeyError: + mplist = self.path2param.get(path) + if mplist is None: if path.startswith('/device'): if path == '/device/changetime': result = self.request('check_config %s %s' % (self.service, self.config)) @@ -284,15 +284,14 @@ class SeaClient(ProxyClient, Module): self.DISPATCHER.shutdown() elif path.startswith('/device/frappy_%s' % self.service) and value == '': self.DISPATCHER.shutdown() - # print('UNUSED', msg) - continue # unused parameter - oldv, oldt, oldr = self.cache.get((module, param), [None, None, None]) - if value is None: - value = oldv - if value != oldv or str(readerror) != str(oldr) or abs(now - oldt) > 60: - # do not update unchanged values within 60 sec - self.updateValue(module, param, value, now, readerror) - + else: + for module, param in mplist: + oldv, oldt, oldr = self.cache.get((module, param), [None, None, None]) + if value is None: + value = oldv + if value != oldv or str(readerror) != str(oldr) or abs(now - oldt) > 60: + # do not update unchanged values within 60 sec + self.updateValue(module, param, value, now, readerror) @Command(StringType(), result=StringType()) def communicate(self, command): @@ -453,8 +452,8 @@ class SeaModule(Module): include = True for paramdesc in descr['params']: path = paramdesc['path'] - if path.endswith('is_running'): - # take this always + if path.endswith('is_running') and issubclass(cls, Drivable): + # take this independent of visibility is_running = paramdesc continue if paramdesc.get('visibility', 1) > visibility_level: @@ -550,7 +549,7 @@ class SeaModule(Module): if key in extra_module_set: extra_modules[name + '.' + key] = sea_object, base, paramdesc continue # skip this parameter - path2param[hdbpath] = (name, key) + path2param.setdefault(hdbpath, []).append((name, key)) attributes[key] = pobj # if hasattr(cls, 'read_' + key): # print('override %s.read_%s' % (cls.__name__, key))