improve meaning handling
- Moveables with meaning 'temperature' are added to the 'temperature_regulation' target list - Devices with meaning 'temperature_regulation' are added to 'temperature' target list, but with much lower priority (should be considered only when no sample quantity is detected)
This commit is contained in:
20
devices.py
20
devices.py
@ -503,8 +503,7 @@ class FrappyConfig(Device):
|
|||||||
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
|
# value to add to the importance given in meanings targets list
|
||||||
add_importance = {k: 10 * i for i, k in enumerate(self.nodes)}
|
add_importance = {k: 10 * i for i, k in enumerate(self.nodes)}
|
||||||
sample_devices = {}
|
sample_devices = {k: [] for k in self.meanings}
|
||||||
regulationset = set()
|
|
||||||
for nodedev in nodedevs:
|
for nodedev in nodedevs:
|
||||||
secnode = nodedev._secnode
|
secnode = nodedev._secnode
|
||||||
if not secnode:
|
if not secnode:
|
||||||
@ -517,10 +516,19 @@ class FrappyConfig(Device):
|
|||||||
meaning = None
|
meaning = None
|
||||||
if meaning:
|
if meaning:
|
||||||
meaning_name, importance = meaning
|
meaning_name, importance = meaning
|
||||||
|
targetlist = sample_devices.get(meaning_name)
|
||||||
|
if targetlist is None:
|
||||||
|
session.log.warning('%s: meaning %r is unknown', devname, meaning_name)
|
||||||
|
continue
|
||||||
|
sample_devices[meaning_name].append((importance, devname))
|
||||||
head, _, tail = meaning_name.partition('_')
|
head, _, tail = meaning_name.partition('_')
|
||||||
if tail == 'regulation':
|
if tail == 'regulation':
|
||||||
regulationset.add(head)
|
# add temperature_regulation to temperature list, with very low importance
|
||||||
sample_devices.setdefault(meaning_name, []).append((importance, devname))
|
sample_devices[head].append((importance - 100, devname))
|
||||||
|
elif not tail:
|
||||||
|
reg = f'{meaning_name}_regulation'
|
||||||
|
if reg in sample_devices and isinstance(session.devices.get(devname), Moveable):
|
||||||
|
sample_devices[reg].append((importance, devname))
|
||||||
|
|
||||||
previous_aliases = self.get_se_aliases()
|
previous_aliases = self.get_se_aliases()
|
||||||
newenv = {} # to be added to envlist (dict [devname] of aliasname)
|
newenv = {} # to be added to envlist (dict [devname] of aliasname)
|
||||||
@ -534,7 +542,7 @@ class FrappyConfig(Device):
|
|||||||
aliasnames = []
|
aliasnames = []
|
||||||
elif isinstance(aliasnames, str):
|
elif isinstance(aliasnames, str):
|
||||||
aliasnames = [aliasnames]
|
aliasnames = [aliasnames]
|
||||||
aliascfg = info.get('targets', {})
|
aliascfg = {k: v - i * 0.01 for i, (k, v) in enumerate(info.get('targets', {}).items())}
|
||||||
predefined_alias = info.get('predefined_alias')
|
predefined_alias = info.get('predefined_alias')
|
||||||
if predefined_alias:
|
if predefined_alias:
|
||||||
aliases = [a for a in predefined_alias
|
aliases = [a for a in predefined_alias
|
||||||
@ -554,8 +562,6 @@ class FrappyConfig(Device):
|
|||||||
# living on the stick/addons node
|
# living on the stick/addons node
|
||||||
nr += add_importance.get(str(getattr(dev, 'secnode', '')), 0)
|
nr += add_importance.get(str(getattr(dev, 'secnode', '')), 0)
|
||||||
importance_list.append((nr, devname))
|
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:
|
||||||
|
@ -17,34 +17,35 @@ devices = dict(
|
|||||||
# the devices with the names given by key are added to determine the
|
# the devices with the names given by key are added to determine the
|
||||||
# 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)
|
||||||
|
# the given numbers assume it is on the cryo, +10 / +20 is added for stick/addons
|
||||||
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 (numbers assume its on the cryo)
|
'targets': # possible devices in addition with importance (numbers assume its on the cryo)
|
||||||
{'se_ts': 19, 'se_tt': 18, 'se_tm': 17},
|
{'se_ts': 20, 'se_tt': 20, 'se_tm': 20},
|
||||||
},
|
},
|
||||||
temperature_regulation = {
|
temperature_regulation = {
|
||||||
'alias': 'T',
|
'alias': 'T',
|
||||||
'targets': {'se_ts': 19, 'se_tt': 18, 'se_tm': 17, 'se_T_stat': 16},
|
'targets': {'se_ts': 27, 'se_tt': 27, 'se_tm': 27, 'se_T_stat': 27},
|
||||||
'drivable_only': True,
|
'drivable_only': True,
|
||||||
},
|
},
|
||||||
magneticfield = {
|
magneticfield = {
|
||||||
'alias': 'B',
|
'alias': 'B',
|
||||||
'targets': {'se_mf': 19},
|
'targets': {'se_mf': 20},
|
||||||
},
|
},
|
||||||
pressure = {
|
pressure = {
|
||||||
'alias': 'p',
|
'alias': 'p',
|
||||||
'targets': {'se_pressure': 19},
|
'targets': {'se_pressure': 20},
|
||||||
},
|
},
|
||||||
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': 19},
|
'targets': {'se_om': 20},
|
||||||
'envlist': False,
|
'envlist': False,
|
||||||
},
|
},
|
||||||
stick_rotation={
|
stick_rotation={
|
||||||
'alias': 'dom',
|
'alias': 'dom',
|
||||||
'targets': {'se_om': 19, 'se_stickrot': 18},
|
'targets': {'se_om': 20, 'se_stickrot': 20},
|
||||||
'envlist': False,
|
'envlist': False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user