Commit 6bf952bd authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

map: removed file

As motors and temperature object are insert into the map only once,
no need to update.
parent d878da99
from bliss.common.axis import Axis
from bliss.common.temperature import Input, Output, Loop
from bliss import global_map
from bliss.controllers.motor import CalcController
def register_axis(global_map, axis, add_to_axes=False):
parents_list = [axis.controller]
if add_to_axes:
parents_list.append("axes")
global_map.register(axis, parents_list=parents_list)
def register_temperature_object(global_map, obj, add_to_counters=False):
parents_list = [obj.controller]
if isinstance(obj, Loop):
children_list = [obj.input, obj.output]
else:
if add_to_counters:
parents_list.append("counters")
children_list = []
global_map.register(obj, parents_list=parents_list, children_list=children_list)
def update_map_for_object(instance_object):
if isinstance(instance_object, Axis):
build_motor_controller_map(instance_object.controller)
register_axis(global_map, instance_object, add_to_axes=True)
elif isinstance(instance_object, (Input, Output, Loop)):
build_temperature_controller_map(instance_object.controller)
register_temperature_object(global_map, instance_object, add_to_counters=True)
def build_motor_controller_map(controller):
if isinstance(controller, CalcController):
global_map.register(
controller, children_list=list(controller.reals) + list(controller.pseudos)
)
else:
for axis in controller.axes.values():
register_axis(global_map, axis)
for hook in axis.motion_hooks:
global_map.register(hook, parents_list=["motion_hooks"])
def build_temperature_controller_map(controller):
for obj in controller._objects.values():
register_temperature_object(global_map, obj)
......@@ -52,7 +52,7 @@ def _checkref(config, item_cfg_node, referenced_objects, name, value, placeholde
if placeholder:
obj = placeholder(value)
else:
obj = config.get(value, add_axes_counters=False)
obj = config.get(value)
item_cfg_node[name] = obj
referenced_objects[name] = obj
return True
......@@ -113,7 +113,7 @@ class Reference:
return self.__name
def __call__(self, *args, **kwargs):
return get_config().get(self.name, add_axes_counters=False)
return get_config().get(self.name)
def __str__(self):
return f"${self.name}"
......
......@@ -57,7 +57,6 @@ from yaml.loader import Reader, Scanner, Parser, Composer, SafeConstructor, Reso
from bliss.config.conductor import client
from bliss.config import channels
from bliss.config.map import update_map_for_object
CONFIG = None
......@@ -716,7 +715,7 @@ class Config:
"""
return set(self._usertag2node.get(tag_name, ()))
def get(self, name, add_axes_counters=True):
def get(self, name):
"""
Returns an object instance from its configuration name
......@@ -771,11 +770,8 @@ class Config:
else:
name2items = name2itemsAndname2itemcache
self._name2instance.update(name2items)
instance_object = self._name2instance.get(name)
if add_axes_counters:
update_map_for_object(instance_object)
return instance_object
return self._name2instance.get(name)
def _create_index(self, node):
name = node.get(self.NAME_KEY)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment