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
|
||||
"""
|
||||
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 = {}
|
||||
regulationset = set()
|
||||
for nodedev in nodedevs:
|
||||
secnode = nodedev._secnode
|
||||
if not secnode:
|
||||
@ -513,6 +516,9 @@ class FrappyConfig(Device):
|
||||
except KeyError:
|
||||
meaning = None
|
||||
if meaning:
|
||||
head, _, tail = meaning.partition('_')
|
||||
if tail == 'regulation':
|
||||
regulationset.add(head)
|
||||
meaning_name, importance = meaning
|
||||
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)
|
||||
continue
|
||||
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)
|
||||
session.log.debug('%s: %r', meaning, importance_list)
|
||||
for _, devname, in importance_list:
|
||||
|
@ -19,32 +19,32 @@ devices = dict(
|
||||
# given by the SECoP standard (10: instrument, 20: cryostat, 30: insert)
|
||||
temperature = { # the SECoP meaning
|
||||
'alias': 'Ts', # the name(s) to be given to the alias
|
||||
'targets': # possible devices in addition with importance
|
||||
{'se_ts': 20, 'se_tt': 19, 'se_tm': 18},
|
||||
'targets': # possible devices in addition with importance (numbers assume its on the cryo)
|
||||
{'se_ts': 19, 'se_tt': 18, 'se_tm': 17},
|
||||
},
|
||||
temperature_regulation = {
|
||||
'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,
|
||||
},
|
||||
magneticfield = {
|
||||
'alias': 'B',
|
||||
'targets': {'se_mf': 20},
|
||||
'targets': {'se_mf': 19},
|
||||
},
|
||||
pressure = {
|
||||
'alias': 'p',
|
||||
'targets': {'se_pressure': 20},
|
||||
'targets': {'se_pressure': 19},
|
||||
},
|
||||
rotation_z={
|
||||
# possible names of the instruments main omega alias
|
||||
# only one of these must be an alias, and this is then used
|
||||
'predefined_alias': ['a3', 'om'],
|
||||
'targets': {'se_om': 20},
|
||||
'targets': {'se_om': 19},
|
||||
'envlist': False,
|
||||
},
|
||||
stick_rotation={
|
||||
'alias': 'dom',
|
||||
'targets': {'se_om': 20, 'se_stickrot': 19},
|
||||
'targets': {'se_om': 19, 'se_stickrot': 18},
|
||||
'envlist': False,
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user