Commit 73f9017e authored by Perceval Guillou's avatar Perceval Guillou
Browse files

wrking on bliss plugin emulation

parent a14b481b
......@@ -497,37 +497,44 @@ def create_objects_from_config_node(cfg_obj, cfg_node):
f"Object with subitems in config must be a ConfigItemContainer object"
)
else: # act as the older Bliss plugin
# elif cfg_node.plugin == "bliss": # act as the older Bliss plugin
klass, node = find_class_and_node(cfg_node)
# klass, node = find_class_and_node(cfg_node)
if node.get("name") != item_name:
cfg_node = ConfigNode.indexed_nodes[item_name]
else:
cfg_node = node
# if node.get("name") != item_name:
# cfg_node = ConfigNode.indexed_nodes[item_name]
# else:
# cfg_node = node
o = klass(item_name, cfg_node.clone())
# o = klass(item_name, cfg_node.clone())
for key, value in cfg_node.items():
if isinstance(cfg_node.raw_get(key), ConfigReference):
if hasattr(o, key):
continue
else:
setattr(o, key, value)
# for key, value in cfg_node.items():
# if isinstance(cfg_node.raw_get(key), ConfigReference):
# if hasattr(o, key):
# continue
# else:
# setattr(o, key, value)
yield {item_name: o}
return
# yield {item_name: o}
# return
# else:
# bctrl = klass(ctrl_node)
# # print(f"\n=== From config: {item_name} from {bctrl.name}")
# if (
# item_name == ctrl_name
# ): # allow instantiation of top object which is not a ConfigItemContainer
# yield {ctrl_name: bctrl}
# return
# else: # prevent instantiation of an item comming from a top object that is not a ConfigItemContainer
# raise TypeError(f"{bctrl} is not a ConfigItemContainer object!")
# yield {ctrl_name: bctrl}
# return
else:
bctrl = klass(ctrl_node)
# print(f"\n=== From config: {item_name} from {bctrl.name}")
if (
item_name == ctrl_name
): # allow instantiation of top object which is not a ConfigItemContainer
yield {ctrl_name: bctrl}
return
else: # prevent instantiation of an item comming from a top object that is not a ConfigItemContainer
raise TypeError(
"Object with subitems in config must be a ConfigItemContainer object"
)
def create_object_from_cache(config, name, bctrl):
......
......@@ -1026,7 +1026,7 @@ class Config(metaclass=Singleton):
if module_name is None:
module_name = "default"
if module_name in ["emotion", "regulation", "diffractometer"]:
if module_name in ["emotion", "regulation", "diffractometer"]: # , "bliss"
module_name = "bliss_controller"
m = __import__("bliss.config.plugins.%s" % (module_name), fromlist=[None])
......
......@@ -143,7 +143,7 @@ class BCMockup(BlissController):
return cnt
elif parent_key == "operators":
return item_class(name, cfg)
return item_class(cfg)
elif parent_key == "axes":
if item_class is None: # mean it is a referenced axis (i.e external axis)
......@@ -288,7 +288,7 @@ class FakeItem:
class Operator:
def __init__(self, name, cfg):
def __init__(self, cfg):
self.name = cfg["name"]
self.tag = cfg.get("tag")
self.factor = cfg["factor"]
......
Markdown is supported
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