improve mechanism to determine aliases
- meanings from name guessing has sligthly lower importance then given meanings - then temperature meaning is missing, take temperature_regulation
This commit is contained in:
16
devices.py
16
devices.py
@ -501,7 +501,10 @@ class FrappyConfig(Device):
|
|||||||
depending on their meaning
|
depending on their meaning
|
||||||
"""
|
"""
|
||||||
nodedevs = filter(None, [session.devices.get(devname) for devname in self.nodes])
|
nodedevs = filter(None, [session.devices.get(devname) for devname in self.nodes])
|
||||||
|
# value to add to the importance given in meanings targets list
|
||||||
|
add_importance = {k: 10 * i for i, k in enumerate(self.nodes)}
|
||||||
sample_devices = {}
|
sample_devices = {}
|
||||||
|
regulationset = set()
|
||||||
for nodedev in nodedevs:
|
for nodedev in nodedevs:
|
||||||
secnode = nodedev._secnode
|
secnode = nodedev._secnode
|
||||||
if not secnode:
|
if not secnode:
|
||||||
@ -513,6 +516,9 @@ class FrappyConfig(Device):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
meaning = None
|
meaning = None
|
||||||
if meaning:
|
if meaning:
|
||||||
|
head, _, tail = meaning.partition('_')
|
||||||
|
if tail == 'regulation':
|
||||||
|
regulationset.add(head)
|
||||||
meaning_name, importance = meaning
|
meaning_name, importance = meaning
|
||||||
sample_devices.setdefault(meaning_name, []).append((importance, devname))
|
sample_devices.setdefault(meaning_name, []).append((importance, devname))
|
||||||
|
|
||||||
@ -541,7 +547,15 @@ class FrappyConfig(Device):
|
|||||||
session.log.warn("neither 'predefined_alias' nor 'alias' configured. skip %s", meaning)
|
session.log.warn("neither 'predefined_alias' nor 'alias' configured. skip %s", meaning)
|
||||||
continue
|
continue
|
||||||
importance_list = sample_devices.get(meaning, [])
|
importance_list = sample_devices.get(meaning, [])
|
||||||
importance_list.extend([(nr, nam) for nam, nr in aliascfg.items() if nam in session.devices])
|
for devname, nr in aliascfg.items():
|
||||||
|
dev = session.devices.get(devname)
|
||||||
|
if dev:
|
||||||
|
# increase importance by 10 for stick or 20 for addons, in case the device is
|
||||||
|
# living on the stick/addons node
|
||||||
|
nr += add_importance.get(str(getattr(dev, 'secnode', '')), 0)
|
||||||
|
importance_list.append((nr, devname))
|
||||||
|
if meaning in regulationset: # take temperature_regulation when temperature is not available
|
||||||
|
importance_list.extend(sample_devices.get(f'{meaning}_regulation', []))
|
||||||
importance_list = sorted(importance_list, reverse=True)
|
importance_list = sorted(importance_list, reverse=True)
|
||||||
session.log.debug('%s: %r', meaning, importance_list)
|
session.log.debug('%s: %r', meaning, importance_list)
|
||||||
for _, devname, in importance_list:
|
for _, devname, in importance_list:
|
||||||
|
@ -19,32 +19,32 @@ devices = dict(
|
|||||||
# 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(s) to be given to the alias
|
'alias': 'Ts', # the name(s) to be given to the alias
|
||||||
'targets': # possible devices in addition with importance
|
'targets': # possible devices in addition with importance (numbers assume its on the cryo)
|
||||||
{'se_ts': 20, 'se_tt': 19, 'se_tm': 18},
|
{'se_ts': 19, 'se_tt': 18, 'se_tm': 17},
|
||||||
},
|
},
|
||||||
temperature_regulation = {
|
temperature_regulation = {
|
||||||
'alias': 'T',
|
'alias': 'T',
|
||||||
'targets': {'se_ts': 20, 'se_tt': 19, 'se_tm': 18, 'se_T_stat': 17},
|
'targets': {'se_ts': 19, 'se_tt': 18, 'se_tm': 17, 'se_T_stat': 16},
|
||||||
'drivable_only': True,
|
'drivable_only': True,
|
||||||
},
|
},
|
||||||
magneticfield = {
|
magneticfield = {
|
||||||
'alias': 'B',
|
'alias': 'B',
|
||||||
'targets': {'se_mf': 20},
|
'targets': {'se_mf': 19},
|
||||||
},
|
},
|
||||||
pressure = {
|
pressure = {
|
||||||
'alias': 'p',
|
'alias': 'p',
|
||||||
'targets': {'se_pressure': 20},
|
'targets': {'se_pressure': 19},
|
||||||
},
|
},
|
||||||
rotation_z={
|
rotation_z={
|
||||||
# possible names of the instruments main omega alias
|
# possible names of the instruments main omega alias
|
||||||
# only one of these must be an alias, and this is then used
|
# only one of these must be an alias, and this is then used
|
||||||
'predefined_alias': ['a3', 'om'],
|
'predefined_alias': ['a3', 'om'],
|
||||||
'targets': {'se_om': 20},
|
'targets': {'se_om': 19},
|
||||||
'envlist': False,
|
'envlist': False,
|
||||||
},
|
},
|
||||||
stick_rotation={
|
stick_rotation={
|
||||||
'alias': 'dom',
|
'alias': 'dom',
|
||||||
'targets': {'se_om': 20, 'se_stickrot': 19},
|
'targets': {'se_om': 19, 'se_stickrot': 18},
|
||||||
'envlist': False,
|
'envlist': False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user