determine environment from alias definitions

secop devices are added automatically to the environment if the
appear in the alias_config. secop devices no longer available
are remove from the envrionment list.

+ fix rename nicos_sinq/frappy to nicos_sinq/frappy_sinq
This commit is contained in:
2022-04-13 09:04:16 +02:00
parent 2450f1b477
commit 80d81d72ae
5 changed files with 15 additions and 17 deletions

View File

@ -37,7 +37,7 @@ if home not in sys.path:
# for newer Frappy installations this should be home (= /home/<instrument>) # for newer Frappy installations this should be home (= /home/<instrument>)
# the following line fixes this in case nicos.conf is not yet updated # the following line fixes this in case nicos.conf is not yet updated
sys.path.append(home) sys.path.append(home)
from nicos_sinq.frappy.devices import FrappyNode from nicos_sinq.frappy_sinq.devices import FrappyNode
from servicemanager import FrappyManager from servicemanager import FrappyManager
@ -68,7 +68,8 @@ def all_info(all_cfg):
def applyAliasConfig(): def applyAliasConfig():
"""Apply the desired aliases from session.alias_config. """Apply the desired aliases from session.alias_config.
in addition, return the targets inheriting from SecopDevice in addition, return the names of targets inheriting from SecopDevice
as a list
""" """
# reimplemented from Session.applyAliasConfig # reimplemented from Session.applyAliasConfig
# apply also when target dev name does not change, as the target device might have # apply also when target dev name does not change, as the target device might have
@ -86,7 +87,7 @@ def applyAliasConfig():
if target in session.devices: if target in session.devices:
try: try:
aliasdev.alias = target aliasdev.alias = target
targets.append(target) targets.append(target.name)
except Exception: except Exception:
session.log.exception("could not set '%s' alias", aliasdev) session.log.exception("could not set '%s' alias", aliasdev)
break break
@ -138,18 +139,15 @@ def frappy_start(service, cfg=None):
cleanup_defunct() cleanup_defunct()
CreateAllDevices() CreateAllDevices()
targets = applyAliasConfig() targets = applyAliasConfig()
target_names = set(t.name for t in targets)
newlist = [] newlist = []
for devname in session.experiment.envlist: for itemname in session.experiment.envlist:
devname, _, stat = devname.partition(':') devname = itemname.split(':')[0]
dev = session.devices.get(devname) dev = session.devices.get(devname)
if dev is not None: if dev is not None and (not isinstance(dev, SecopDevice) or devname in targets):
if isinstance(dev, SecopDevice): newlist.append(itemname)
if devname in target_names: newlist.extend(t for t in targets if t not in newlist)
.... if newlist != session.experiment.envlist:
else: session.experiment.setEnvironment(newlist)
newlist.append(dev.name)
if startnode and cfg == '': if startnode and cfg == '':
startnode.disable() startnode.disable()
return all_cfg return all_cfg

View File

@ -1,7 +1,7 @@
description = 'frappy' description = 'frappy'
group = 'optional' group = 'optional'
modules = ['nicos_sinq.frappy.commands'] modules = ['nicos_sinq.frappy_sinq.commands']
devices = { devices = {
'temperature': device('nicos.devices.generic.DeviceAlias'), 'temperature': device('nicos.devices.generic.DeviceAlias'),

View File

@ -4,7 +4,7 @@ group = 'optional'
devices = { devices = {
'se_addons': 'se_addons':
device('nicos_sinq.frappy.devices.FrappyNode', device('nicos_sinq.frappy_sinq.devices.FrappyNode',
description='SEC node', unit='', description='SEC node', unit='',
prefix='se_', auto_create=True, service='addons', prefix='se_', auto_create=True, service='addons',
), ),

View File

@ -4,7 +4,7 @@ group = 'optional'
devices = { devices = {
'se_main': 'se_main':
device('nicos_sinq.frappy.devices.FrappyNode', device('nicos_sinq.frappy_sinq.devices.FrappyNode',
description='main SEC node', unit='', description='main SEC node', unit='',
prefix='se_', auto_create=True, service='main', prefix='se_', auto_create=True, service='main',
), ),

View File

@ -4,7 +4,7 @@ group = 'optional'
devices = { devices = {
'se_stick': 'se_stick':
device('nicos_sinq.frappy.devices.FrappyNode', device('nicos_sinq.frappy_sinq.devices.FrappyNode',
description='stick SEC node', unit='', description='stick SEC node', unit='',
prefix='se_', auto_create=True, service='stick', prefix='se_', auto_create=True, service='stick',
), ),