From 6b28b178237aac60ca7827a90c36b5dc8de91475 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Fri, 27 Sep 2024 16:13:11 +0200 Subject: [PATCH] improve mechanism to determine aliases - meanings from name guessing has sligthly lower importance then given meanings - then temperature meaning is missing, take temperature_regulation --- devices.py | 16 +++++++++++++++- setups/frappy.py | 14 +++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/devices.py b/devices.py index 83c9532..085300e 100644 --- a/devices.py +++ b/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: diff --git a/setups/frappy.py b/setups/frappy.py index 37c85c7..2095425 100644 --- a/setups/frappy.py +++ b/setups/frappy.py @@ -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, } )