fix a3 alias assignment
rotation_z and stick_rotation need seperate entries in frappy_config
This commit is contained in:
@ -96,7 +96,7 @@ def frappy_start(**services):
|
|||||||
all_cfg = {}
|
all_cfg = {}
|
||||||
new_cfg = []
|
new_cfg = []
|
||||||
remove_cfg = []
|
remove_cfg = []
|
||||||
for service in SERVICES:
|
for service in reversed(SERVICES):
|
||||||
secnode = session.devices.get('se_' + service)
|
secnode = session.devices.get('se_' + service)
|
||||||
cfginfo = services.get(service)
|
cfginfo = services.get(service)
|
||||||
if cfginfo is None:
|
if cfginfo is None:
|
||||||
|
44
devices.py
44
devices.py
@ -78,9 +78,14 @@ class FrappyConfig(Device):
|
|||||||
'magneticfield': Param(
|
'magneticfield': Param(
|
||||||
'config for magnetic field', type=anytype, default={}),
|
'config for magnetic field', type=anytype, default={}),
|
||||||
'rotation_z': Param(
|
'rotation_z': Param(
|
||||||
'config for sample rotation', type=anytype, default={}),
|
'config for sample rotation (to be used as a3)',
|
||||||
|
type=anytype, default={}),
|
||||||
|
'stick_rotation': Param(
|
||||||
|
'config for stick rotation (not necessarily to be used as a3)',
|
||||||
|
type=anytype, default={}),
|
||||||
'nodes': Param(
|
'nodes': Param(
|
||||||
'list of names of potential SEC nodes', type=listof(str), default=[]),
|
'list of names of potential SEC nodes',
|
||||||
|
type=listof(str), default=[]),
|
||||||
}
|
}
|
||||||
|
|
||||||
meanings = list(parameters)
|
meanings = list(parameters)
|
||||||
@ -89,7 +94,7 @@ 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)
|
||||||
aliasnames = info['alias']
|
aliasnames = info.get('alias', [])
|
||||||
if isinstance(aliasnames, str):
|
if isinstance(aliasnames, str):
|
||||||
aliasnames = [aliasnames]
|
aliasnames = [aliasnames]
|
||||||
for aliasname in aliasnames:
|
for aliasname in aliasnames:
|
||||||
@ -103,7 +108,7 @@ class FrappyConfig(Device):
|
|||||||
result = {}
|
result = {}
|
||||||
for meaning in self.meanings:
|
for meaning in self.meanings:
|
||||||
info = getattr(self, meaning)
|
info = getattr(self, meaning)
|
||||||
aliasnames = info['alias']
|
aliasnames = info.get('alias', [])
|
||||||
if isinstance(aliasnames, str):
|
if isinstance(aliasnames, str):
|
||||||
aliasnames = [aliasnames]
|
aliasnames = [aliasnames]
|
||||||
for aliasname in aliasnames:
|
for aliasname in aliasnames:
|
||||||
@ -139,19 +144,22 @@ class FrappyConfig(Device):
|
|||||||
info = getattr(self, meaning)
|
info = getattr(self, meaning)
|
||||||
aliasnames = info.get('alias')
|
aliasnames = info.get('alias')
|
||||||
if aliasnames is None:
|
if aliasnames is None:
|
||||||
continue
|
aliasnames = []
|
||||||
if isinstance(aliasnames, str):
|
elif isinstance(aliasnames, str):
|
||||||
aliasnames = [aliasnames]
|
aliasnames = [aliasnames]
|
||||||
aliascfg = info.get('targets', {})
|
aliascfg = info.get('targets', {})
|
||||||
unique = info.get('unique')
|
predefined_alias = info.get('predefined_alias')
|
||||||
if unique:
|
if predefined_alias:
|
||||||
aliases = [a for a in unique
|
aliases = [a for a in predefined_alias
|
||||||
if isinstance(session.devices.get(a), DeviceAlias)]
|
if isinstance(session.devices.get(a), DeviceAlias)]
|
||||||
if aliases:
|
if aliases:
|
||||||
if len(aliases) > 1:
|
if len(aliases) > 1:
|
||||||
raise TypeError(f'do know to which of {aliases} {meaning} to assign to')
|
raise TypeError(f'do know to which of {aliases} {meaning} to assign to')
|
||||||
alias_config = session.alias_config.setdefault(aliases[0], [])
|
alias_config = session.alias_config.setdefault(aliases[0], [])
|
||||||
alias_config.extend(list(aliascfg.items()))
|
alias_config.extend(list(aliascfg.items()))
|
||||||
|
elif not aliasnames:
|
||||||
|
session.log.warn("neither 'predefined_alias' nor 'alias' configured. skip %s", meaning)
|
||||||
|
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])
|
importance_list.extend([(nr, nam) for nam, nr in aliascfg.items() if nam in session.devices])
|
||||||
importance_list = sorted(importance_list, reverse=True)
|
importance_list = sorted(importance_list, reverse=True)
|
||||||
@ -172,14 +180,15 @@ class FrappyConfig(Device):
|
|||||||
session.log.debug('create alias %r -> %r', aliasname, devname)
|
session.log.debug('create alias %r -> %r', aliasname, devname)
|
||||||
aliasdev = session.createDevice(aliasname, recreate=True, explicit=True)
|
aliasdev = session.createDevice(aliasname, recreate=True, explicit=True)
|
||||||
aliasdev.alias = devname
|
aliasdev.alias = devname
|
||||||
# only the first item of aliasnames is added to the envlist
|
if aliasnames:
|
||||||
aliasname = aliasnames[0]
|
# only the first item of aliasnames is added to the envlist
|
||||||
to_remove.add(devname)
|
aliasname = aliasnames[0]
|
||||||
to_remove.add(aliasname)
|
to_remove.add(devname)
|
||||||
if devname not in newenv and info.get('envlist', True):
|
to_remove.add(aliasname)
|
||||||
# example: when 'temperature' and 'temperature_regulation' are the
|
if devname not in newenv and info.get('envlist', True):
|
||||||
# same device, the first one is kept
|
# example: when 'temperature' and 'temperature_regulation' are the
|
||||||
newenv[devname] = aliasname
|
# same device, the first one is kept
|
||||||
|
newenv[devname] = aliasname
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
to_remove.union(aliasnames)
|
to_remove.union(aliasnames)
|
||||||
@ -299,6 +308,7 @@ class FrappyNode(SecNodeDevice, Moveable):
|
|||||||
else:
|
else:
|
||||||
self.disable()
|
self.disable()
|
||||||
if running_cfg:
|
if running_cfg:
|
||||||
|
self._disconnect()
|
||||||
self._service_manager.do_stop(ins, self.service)
|
self._service_manager.do_stop(ins, self.service)
|
||||||
is_cfg = cfg and ':' not in cfg
|
is_cfg = cfg and ':' not in cfg
|
||||||
if is_cfg:
|
if is_cfg:
|
||||||
|
@ -33,15 +33,19 @@ devices = dict(
|
|||||||
'alias': ['B', 'magfield'],
|
'alias': ['B', 'magfield'],
|
||||||
'targets': {'se_mf': 20},
|
'targets': {'se_mf': 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
|
||||||
'unique': ['a3', 'om'],
|
'predefined_alias': ['a3', 'om'],
|
||||||
|
'targets': {'se_om': 20},
|
||||||
|
'envlist': False,
|
||||||
|
},
|
||||||
|
stick_rotation={
|
||||||
'alias': 'dom',
|
'alias': 'dom',
|
||||||
'targets': {'se_om': 20, 'se_stickrot': 19},
|
'targets': {'se_om': 20, 'se_stickrot': 19},
|
||||||
'envlist': False,
|
'envlist': False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
startupcode = '''
|
startupcode = '''
|
||||||
|
Reference in New Issue
Block a user