allow multiple names for SE aliases
This commit is contained in:
36
devices.py
36
devices.py
@ -97,12 +97,15 @@ class FrappyConfig(Device):
|
|||||||
def remove_aliases(self):
|
def remove_aliases(self):
|
||||||
for meaning in self.meanings:
|
for meaning in self.meanings:
|
||||||
info = getattr(self, meaning)
|
info = getattr(self, meaning)
|
||||||
aliasname = info['alias']
|
aliasnames = info['alias']
|
||||||
aliasdev = session.devices.get(aliasname)
|
if isinstance(aliasname, str):
|
||||||
if aliasdev:
|
aliasnames = [aliasnames]
|
||||||
session.destroyDevice(aliasname)
|
for aliasname in aliasnames:
|
||||||
session.configured_devices.pop(aliasname, None)
|
aliasdev = session.devices.get(aliasname)
|
||||||
session.dynamic_devices.pop(aliasname, None)
|
if aliasdev:
|
||||||
|
session.destroyDevice(aliasname)
|
||||||
|
session.configured_devices.pop(aliasname, None)
|
||||||
|
session.dynamic_devices.pop(aliasname, None)
|
||||||
|
|
||||||
def set_envlist(self):
|
def set_envlist(self):
|
||||||
"""create aliases for SECoP devices
|
"""create aliases for SECoP devices
|
||||||
@ -129,7 +132,9 @@ class FrappyConfig(Device):
|
|||||||
drivables = {}
|
drivables = {}
|
||||||
for meaning in self.meanings:
|
for meaning in self.meanings:
|
||||||
info = getattr(self, meaning)
|
info = getattr(self, meaning)
|
||||||
aliasname = info['alias']
|
aliasnames = info['alias']
|
||||||
|
if isinstance(aliasnames, str):
|
||||||
|
aliasnames = [aliasnames]
|
||||||
envlistflag = info.get('envlist', True)
|
envlistflag = info.get('envlist', True)
|
||||||
aliascfg = info.get('targets', {})
|
aliascfg = info.get('targets', {})
|
||||||
importance_list = sample_devices.get(meaning, [])
|
importance_list = sample_devices.get(meaning, [])
|
||||||
@ -151,12 +156,14 @@ class FrappyConfig(Device):
|
|||||||
# marked as xxx_drivable, but not really drivable: skip
|
# marked as xxx_drivable, but not really drivable: skip
|
||||||
continue
|
continue
|
||||||
if dev:
|
if dev:
|
||||||
session.log.debug('create alias %r pointing to %r', aliasname, devname)
|
for aliasname in aliasnames:
|
||||||
devcfg = ('nicos.core.DeviceAlias', {})
|
session.log.debug('create alias %r pointing to %r', aliasname, devname)
|
||||||
session.configured_devices[aliasname] = devcfg
|
devcfg = ('nicos.core.DeviceAlias', {})
|
||||||
session.dynamic_devices[aliasname] = 'frappy'
|
session.configured_devices[aliasname] = devcfg
|
||||||
aliasdev = session.createDevice(aliasname, recreate=True, explicit=True)
|
session.dynamic_devices[aliasname] = 'frappy'
|
||||||
aliasdev.alias = devname
|
aliasdev = session.createDevice(aliasname, recreate=True, explicit=True)
|
||||||
|
aliasdev.alias = devname
|
||||||
|
aliasname = aliasnames[0]
|
||||||
if devname not in devset and envlistflag:
|
if devname not in devset and envlistflag:
|
||||||
# take only the first one
|
# take only the first one
|
||||||
devset.add(devname)
|
devset.add(devname)
|
||||||
@ -165,7 +172,8 @@ class FrappyConfig(Device):
|
|||||||
newenv.pop(aliasname, None)
|
newenv.pop(aliasname, None)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
newenv.pop(aliasname, None)
|
for aliasname in aliasnames:
|
||||||
|
newenv.pop(aliasname, None)
|
||||||
|
|
||||||
applyAliasConfig() # for other aliases
|
applyAliasConfig() # for other aliases
|
||||||
if set(newenv) != set(session.experiment.envlist):
|
if set(newenv) != set(session.experiment.envlist):
|
||||||
|
@ -20,7 +20,7 @@ devices = dict(
|
|||||||
# device, using the given importance number, with similar values as
|
# device, using the given importance number, with similar values as
|
||||||
# given by the SECoP standard (10: instrument, 20: cryostat, 30: insert)
|
# given by the SECoP standard (10: instrument, 20: cryostat, 30: insert)
|
||||||
temperature = { # the SECoP meaning
|
temperature = { # the SECoP meaning
|
||||||
'alias': 'Ts', # the name to be given to the alias
|
'alias': ['Ts', 'temperature'], # the name(s) to be given to the alias
|
||||||
'targets': # possible devices in addition with importance
|
'targets': # possible devices in addition with importance
|
||||||
{'se_ts': 20, 'se_tt': 19, 'se_tm': 18},
|
{'se_ts': 20, 'se_tt': 19, 'se_tm': 18},
|
||||||
},
|
},
|
||||||
@ -33,7 +33,7 @@ devices = dict(
|
|||||||
'envlist': False,
|
'envlist': False,
|
||||||
},
|
},
|
||||||
magneticfield = {
|
magneticfield = {
|
||||||
'alias': 'B',
|
'alias': ['B', 'magfield'],
|
||||||
'targets': {'se_mf': 20},
|
'targets': {'se_mf': 20},
|
||||||
},
|
},
|
||||||
rotation_z = {
|
rotation_z = {
|
||||||
|
Reference in New Issue
Block a user