fix 2 issues with starting stopping

- secnode devices were not disconnected before stopping
  leading to error messages
- target of secnodes not properly updated
This commit is contained in:
2024-06-07 17:08:31 +02:00
parent e121c3ca8e
commit f8440d38a4

View File

@ -165,8 +165,8 @@ class FrappyConfig(Device):
self._back_to_normal = None self._back_to_normal = None
while not self._shutdown_event.wait(1): while not self._shutdown_event.wait(1):
busy = session.daemon_device._controller.status >= 0 busy = session.daemon_device._controller.status >= 0
if busy and cnt < 10: if self._restarting or (busy and cnt < 10):
# check only every 10 sec when busy # do not check when restarting and check only every 10 sec when busy
cnt += 1 cnt += 1
continue continue
if not busy and self._back_to_normal: if not busy and self._back_to_normal:
@ -308,10 +308,9 @@ class FrappyConfig(Device):
used_cfg[cfg] = service used_cfg[cfg] = service
for service, cfginfo in reversed(list(new_cfg.items())): for service, cfginfo in reversed(list(new_cfg.items())):
if cfginfo != all_cfg.get(service, ''): secnode = secnodes[service]
secnode = secnodes[service] if secnode:
if secnode: secnode('') # stop previous frappy server
secnode('') # stop previous frappy server
if new_cfg: if new_cfg:
for service, cfginfo in new_cfg.items(): for service, cfginfo in new_cfg.items():
@ -735,7 +734,6 @@ class FrappyNode(SecNodeDevice, Moveable):
self.__log_recording = () self.__log_recording = ()
def nodeStateChange(self, online, state): def nodeStateChange(self, online, state):
# self.log.info('NODE %r %r', online, state)
if online: if online:
super().nodeStateChange(online, state) super().nodeStateChange(online, state)
if self._cfgvalue is None: if self._cfgvalue is None:
@ -759,7 +757,7 @@ class FrappyNode(SecNodeDevice, Moveable):
if not running_cfg or running_cfg == self.target: if not running_cfg or running_cfg == self.target:
super().descriptiveDataChange(module, description) super().descriptiveDataChange(module, description)
else: else:
self._disconnect(True) self._disconnect(keeptarget=True)
self._cfgvalue = running_cfg self._cfgvalue = running_cfg
self._set_status(status.ERROR, 'cfg changed') self._set_status(status.ERROR, 'cfg changed')
@ -791,7 +789,7 @@ class FrappyNode(SecNodeDevice, Moveable):
if cfg != running_cfg: if cfg != running_cfg:
self.disable() self.disable()
if running_cfg: if running_cfg:
self._disconnect() self._disconnect(keeptarget=not cfg)
session.log.info('stop frappy_%s %r %r', self.service, running_cfg, cfg) session.log.info('stop frappy_%s %r %r', self.service, running_cfg, cfg)
fm.do_stop(ins, self.service) fm.do_stop(ins, self.service)
self._setROParam('target', cfg) self._setROParam('target', cfg)
@ -815,12 +813,12 @@ class FrappyNode(SecNodeDevice, Moveable):
else: else:
uri = cfg uri = cfg
if uri != self.uri: if uri != self.uri:
self.uri = '' # disconnect self._disconnect(keeptarget=True)
if uri: if uri:
if is_cfg: if is_cfg:
session.log.info('start frappy_%s', self.service) session.log.info('start frappy_%s', self.service)
fm.do_start(ins, self.service, cfg, logger=self.log) fm.do_start(ins, self.service, cfg, logger=self.log)
self.uri = uri # connect self.uri = uri # connect (or disconnect)
self._cfgvalue = cfg self._cfgvalue = cfg
if self._cache: if self._cache:
self._cache.put(self, 'value', cfg) self._cache.put(self, 'value', cfg)