Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
73f9017e
Commit
73f9017e
authored
Jun 29, 2021
by
Perceval Guillou
Browse files
wrking on bliss plugin emulation
parent
a14b481b
Changes
3
Hide whitespace changes
Inline
Side-by-side
bliss/config/plugins/bliss_controller.py
View file @
73f9017e
...
...
@@ -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
):
...
...
bliss/config/static.py
View file @
73f9017e
...
...
@@ -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
])
...
...
bliss/controllers/bliss_controller_mockup.py
View file @
73f9017e
...
...
@@ -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"
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment