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
4506a660
Commit
4506a660
authored
Jul 01, 2021
by
Perceval Guillou
Browse files
rename plugin generic
parent
b44561dd
Pipeline
#49686
passed with stages
in 131 minutes and 2 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bliss/config/plugins/bliss.py
→
bliss/config/plugins/bliss
_old
.py
View file @
4506a660
File moved
bliss/config/plugins/
bliss_controller
.py
→
bliss/config/plugins/
generic
.py
View file @
4506a660
...
...
@@ -78,7 +78,7 @@ class ConfigItemContainer:
# --- Plugin ---
ConfigItemContainer objects are created from the yml config using the
bliss
plugin.
ConfigItemContainer objects are created from the yml config using the
generic
plugin.
Any subitem with a name can be imported in a Bliss session with config.get('name').
The plugin ensures that the top object and its subitems are only created once.
The ConfigItemContainer itself can have a name (optional) and can be imported in the session.
...
...
@@ -124,7 +124,7 @@ class ConfigItemContainer:
# --- yml config example ---
- plugin:
bliss
<== use the dedicated
bliss
plugin
- plugin:
generic
<== use the dedicated
generic
plugin
module: custom_module <== module of the custom bliss controller
class: BCMockup <== class of the custom bliss controller
name: bcmock <== name of the custom bliss controller (optional)
...
...
bliss/config/static.py
View file @
4506a660
...
...
@@ -1026,13 +1026,8 @@ class Config(metaclass=Singleton):
if
module_name
is
None
:
module_name
=
"default"
if
module_name
in
[
"emotion"
,
"regulation"
,
"diffractometer"
,
"bliss"
,
]:
# , "bliss"
module_name
=
"bliss_controller"
if
module_name
in
[
"emotion"
,
"regulation"
,
"diffractometer"
,
"bliss"
]:
module_name
=
"generic"
m
=
__import__
(
"bliss.config.plugins.%s"
%
(
module_name
),
fromlist
=
[
None
])
if
hasattr
(
m
,
"create_object_from_cache"
):
...
...
bliss/controllers/bliss_controller.py
View file @
4506a660
...
...
@@ -7,7 +7,7 @@
from
bliss.common.protocols
import
CounterContainer
from
bliss.common.utils
import
autocomplete_property
from
bliss.config.plugins.
bliss_controller
import
ConfigItemContainer
from
bliss.config.plugins.
generic
import
ConfigItemContainer
class
BlissController
(
CounterContainer
,
ConfigItemContainer
):
...
...
@@ -25,7 +25,7 @@ class BlissController(CounterContainer, ConfigItemContainer):
# --- Plugin ---
BlissController objects are created from the yml config using the
bliss_controller
plugin.
BlissController objects are created from the yml config using the
generic
plugin.
Any subitem with a name can be imported in a Bliss session with config.get('name').
The plugin ensures that the controller and subitems are only created once.
The bliss controller itself can have a name (optional) and can be imported in the session.
...
...
@@ -71,7 +71,7 @@ class BlissController(CounterContainer, ConfigItemContainer):
# --- yml config example ---
- plugin:
bliss_controller
<== use the dedicated
bliss controller
plugin
- plugin:
generic
<== use the dedicated
generic
plugin
module: custom_module <== module of the custom bliss controller
class: BCMockup <== class of the custom bliss controller
name: bcmock <== name of the custom bliss controller (optional)
...
...
@@ -113,6 +113,12 @@ class BlissController(CounterContainer, ConfigItemContainer):
# ========== ABSTRACT METHODS ====================
def
_get_default_chain_counter_controller
(
self
):
""" return the default counter controller that should be used
when this controller is added to the DEFAULT_CHAIN
"""
raise
NotImplementedError
def
_create_hardware
(
self
):
""" return the low level hardware controller interface """
raise
NotImplementedError
...
...
bliss/controllers/musst.py
View file @
4506a660
...
...
@@ -364,8 +364,6 @@ class musst(BlissController):
self
.
_counter_controllers
[
"scc"
].
max_sampling_frequency
=
max_freq
def
_init
(
self
):
# Called by bliss_controller plugin (just after self._load_config)
"""
Place holder for any action to perform after the configuration has been loaded.
"""
...
...
bliss/tango/servers/axis_ds.py
View file @
4506a660
...
...
@@ -1136,10 +1136,9 @@ def get_server_axis_names(instance_name=None):
result
=
[]
for
item_name
in
cfg
.
names_list
:
item_cfg
=
cfg
.
get_config
(
item_name
)
if
item_cfg
.
plugin
in
[
"bliss_controller"
,
"emotion"
,
]
and
instance_name
in
item_cfg
.
get
(
"tango_server"
,
()):
if
item_cfg
.
plugin
==
"emotion"
and
instance_name
in
item_cfg
.
get
(
"tango_server"
,
()
):
result
.
append
(
item_name
)
return
result
...
...
@@ -1352,7 +1351,7 @@ def initialize_bliss(info, db=None):
# if tango_server is defined it means it is manually added
if
"tango_server"
in
obj_cfg
:
continue
if
obj_cfg
.
plugin
in
[
"bliss_controller"
,
"emotion"
]
:
if
obj_cfg
.
plugin
==
"emotion"
:
try
:
if
name
in
[
x
[
"name"
]
for
x
in
obj_cfg
.
parent
[
"axes"
]]:
axis_names
.
append
(
name
)
...
...
tests/controllers/test_bliss_controller.py
View file @
4506a660
...
...
@@ -11,11 +11,9 @@ from unittest import mock
from
bliss.controllers.bliss_controller
import
BlissController
from
bliss.controllers.bliss_controller_mockup
import
BCMockup
,
Operator
,
FakeItem
from
bliss.config.plugins.bliss_controller
import
create_objects_from_config_node
from
bliss.config.plugins.bliss_controller
import
create_object_from_cache
from
bliss.config.plugins.bliss_controller
import
find_top_class_and_node
# test if no class specified at controller level !
from
bliss.config.plugins.generic
import
create_objects_from_config_node
from
bliss.config.plugins.generic
import
create_object_from_cache
from
bliss.config.plugins.generic
import
find_top_class_and_node
def
test_plugin_get_items_from_config
(
default_session
):
...
...
@@ -184,11 +182,11 @@ def test_plugin_items_loading_order(default_session):
return
create_object_from_cache
(
*
args
,
**
kwargs
)
with
mock
.
patch
(
"bliss.config.plugins.
bliss_controller
.create_objects_from_config_node"
,
"bliss.config.plugins.
generic
.create_objects_from_config_node"
,
wraps
=
wrap_create_objects_from_config_node
,
):
with
mock
.
patch
(
"bliss.config.plugins.
bliss_controller
.create_object_from_cache"
,
"bliss.config.plugins.
generic
.create_object_from_cache"
,
wraps
=
wrap_create_object_from_cache
,
):
...
...
@@ -333,7 +331,7 @@ def test_plugin_items_loading_order(default_session):
def
test_plugin_items_initialized_only_once
(
default_session
):
""" load all test session objects and check that those going through
bliss controller
plugin are never created twice.
the generic
plugin are never created twice.
(see FromConfig for the controllers and FromCache for the subitems)
"""
...
...
@@ -367,11 +365,11 @@ def test_plugin_items_initialized_only_once(default_session):
return
create_object_from_cache
(
config
,
name
,
bctrl
)
with
mock
.
patch
(
"bliss.config.plugins.
bliss_controller
.create_objects_from_config_node"
,
"bliss.config.plugins.
generic
.create_objects_from_config_node"
,
wraps
=
wrap_create_objects_from_config_node
,
):
with
mock
.
patch
(
"bliss.config.plugins.
bliss_controller
.create_object_from_cache"
,
"bliss.config.plugins.
generic
.create_object_from_cache"
,
wraps
=
wrap_create_object_from_cache
,
):
...
...
tests/test_configuration/bliss_controllers.yml
View file @
4506a660
plugin
:
generic
mockup_controller
:
-
name
:
bcmock
# an example of an advanced bliss controller
plugin
:
bliss_controller
module
:
bliss_controller_mockup
class
:
BCMockup
com
:
tcp
:
url
:
bcmock
energy
:
$robz
# an external ref as a ctrl parameter
param1
:
10
# a std type ctrl parameter
counters
:
-
name
:
bctemp
# a sampling cnt item
tag
:
current_temperature
# a tag for this item
mode
:
MEAN
unit
:
°C
convfunc
:
2*x +
2
# using default class (available at ctrl level)
-
name
:
bcintime
# a custom cnt item
tag
:
integration_time
# a tag for this item
unit
:
ms
convfunc
:
x * 1e3
# using default class (available via default module)
axes
:
# external axis subitems
-
name
:
$axis1
# an axis item managed by another ctrl
tag
:
xrot
# a tag for this item
-
name
:
$axis2
# an axis item managed by another ctrl
tag
:
yrot
# a tag for this item
-
name
:
$bccalcmot
# an calc_axis item managed by another ctrl
tag
:
calcmot
# a tag for this item interpreted by this ctrl
calc_controller
:
$calc_mot2.controller
# a reference to another bliss controller via an axis
operators
:
-
name
:
operator1
# a custom type item
input
:
$bctemp
# an internal reference
factor
:
2
# an item parameter
class
:
bliss.controllers.bliss_controller_mockup.Operator
# specify a class for the item as an absolute path
-
name
:
operator2
# a custom type item
input
:
$bcintime
# an internal reference
factor
:
0.5
# an item parameter
class
:
Operator
# specify a class for the item
-
class
:
mockup
# a pure mockup motor controller
plugin
:
bliss_controller
axes
:
-
name
:
axis1
# an axis item managed by this ctrl
backlash
:
2
steps_per_unit
:
10000
velocity
:
2500.0
acceleration
:
1000.0
low_limit
:
-180
high_limit
:
180
default_cust_attr
:
6.28
-
name
:
bcmock
# an example of an advanced bliss controller
module
:
bliss_controller_mockup
class
:
BCMockup
-
name
:
axis2
# an axis item managed by this ctrl
backlash
:
1
steps_per_unit
:
5000
velocity
:
1500.0
acceleration
:
800.0
low_limit
:
-30
high_limit
:
30
default_cust_attr
:
28.12
-
name
:
calcmock
# a pure calc_motor controller
plugin
:
bliss_controller
module
:
mockup
class
:
calc_motor_mockup
axes
:
-
name
:
$roby
# an external axis item
tags
:
real real_mot
-
name
:
bccalcmot
# a calc axis
tags
:
calc_mot
-
name
:
musst
class
:
MusstMock
module
:
musst
plugin
:
bliss_controller
channels
:
-
type
:
cnt
channel
:
timer
label
:
"
lab_musst_timer"
counter_name
:
musst_timer
# declare a counter associated to that channel
-
type
:
encoder
channel
:
1
label
:
"
lab_enc_samy"
counter_name
:
enc_samy
# declare a counter
counter_mode
:
SINGLE
# declare a mode for that counter
com
:
tcp
:
url
:
bcmock
energy
:
$robz
# an external ref as a ctrl parameter
param1
:
10
# a std type ctrl parameter
counters
:
-
name
:
bctemp
# a sampling cnt item
tag
:
current_temperature
# a tag for this item
mode
:
MEAN
unit
:
°C
convfunc
:
2*x +
2
# using default class (available at ctrl level)
-
name
:
bcintime
# a custom cnt item
tag
:
integration_time
# a tag for this item
unit
:
ms
convfunc
:
x * 1e3
# using default class (available via default module)
axes
:
# external axis subitems
-
name
:
$axis1
# an axis item managed by another ctrl
tag
:
xrot
# a tag for this item
-
name
:
$axis2
# an axis item managed by another ctrl
tag
:
yrot
# a tag for this item
-
name
:
$bccalcmot
# an calc_axis item managed by another ctrl
tag
:
calcmot
# a tag for this item interpreted by this ctrl
calc_controller
:
$calc_mot2.controller
# a reference to another bliss controller via an axis
operators
:
-
name
:
operator1
# a custom type item
input
:
$bctemp
# an internal reference
factor
:
2
# an item parameter
class
:
bliss.controllers.bliss_controller_mockup.Operator
# specify a class for the item as an absolute path
-
name
:
operator2
# a custom type item
input
:
$bcintime
# an internal reference
factor
:
0.5
# an item parameter
class
:
Operator
# specify a class for the item
-
class
:
mockup
# a pure mockup motor controller
axes
:
-
name
:
axis1
# an axis item managed by this ctrl
backlash
:
2
steps_per_unit
:
10000
velocity
:
2500.0
acceleration
:
1000.0
low_limit
:
-180
high_limit
:
180
default_cust_attr
:
6.28
-
name
:
axis2
# an axis item managed by this ctrl
backlash
:
1
steps_per_unit
:
5000
velocity
:
1500.0
acceleration
:
800.0
low_limit
:
-30
high_limit
:
30
default_cust_attr
:
28.12
-
name
:
calcmock
# a pure calc_motor controller
module
:
mockup
class
:
calc_motor_mockup
axes
:
-
name
:
$roby
# an external axis item
tags
:
real real_mot
-
name
:
bccalcmot
# a calc axis
tags
:
calc_mot
-
name
:
musst
class
:
MusstMock
module
:
musst
channels
:
-
type
:
cnt
channel
:
timer
label
:
"
lab_musst_timer"
counter_name
:
musst_timer
# declare a counter associated to that channel
-
type
:
encoder
channel
:
1
label
:
"
lab_enc_samy"
counter_name
:
enc_samy
# declare a counter
counter_mode
:
SINGLE
# declare a mode for that counter
foo1
:
-
name
:
bcmock1
plugin
:
bliss_controller
module
:
bliss_controller_mockup
class
:
TestBCMockup
-
name
:
bcmock1
module
:
bliss_controller_mockup
class
:
TestBCMockup
fakeitems
:
-
name
:
item11
class
:
FakeItem
# specify class
-
name
:
item12
# default class
fakeitems
:
-
name
:
item11
class
:
FakeItem
# specify class
-
name
:
item12
# default class
-
name
:
bcmock2
plugin
:
bliss_controller
module
:
bliss_controller_mockup
class
:
TestBCMockup
-
name
:
bcmock2
module
:
bliss_controller_mockup
class
:
TestBCMockup
fakeitems
:
-
name
:
item21
# default class
subsection
:
# possible subsection
-
name
:
item211
class
:
FakeItem
# specify class
fakeitems
:
-
name
:
item21
# default class
subsection
:
# possible subsection
-
name
:
item211
class
:
FakeItem
# specify class
unknownitems
:
-
name
:
item22
#unknown default class
-
name
:
item23
class
:
NotFound
#unknown default module
-
name
:
item24
class
:
FakeItem
#unknown item/parent_key
unknownitems
:
-
name
:
item22
#unknown default class
-
name
:
item23
class
:
NotFound
#unknown default module
-
name
:
item24
class
:
FakeItem
#unknown item/parent_key
foo2
:
-
class
:
TestBCMockup
plugin
:
bliss_controller
module
:
bliss_controller_mockup
-
class
:
TestBCMockup
module
:
bliss_controller_mockup
fakeitems
:
-
name
:
item31
-
name
:
item32
class
:
FakeItem
fakeitems
:
-
name
:
item31
-
name
:
item32
class
:
FakeItem
none-bliss_controller
:
# loading a none-bliss_controller object is allowed by the plugin
# but only if it is the top level object within the config
-
name
:
fakeop1
# can be loaded via the plugin
class
:
Operator
plugin
:
bliss_controller
module
:
bliss_controller_mockup
input
:
noinput
factor
:
0
subitems
:
-
name
:
not_allowed_item
# a subitem of a none-bliss_controller cannot be loaded via the plugin
\ No newline at end of file
-
name
:
fakeop1
# can be loaded via the plugin
class
:
Operator
module
:
bliss_controller_mockup
input
:
noinput
factor
:
0
subitems
:
-
name
:
not_allowed_item
# a subitem of a none-bliss_controller cannot be loaded via the plugin
\ No newline at end of file
tests/test_configuration/diffracto.yml
View file @
4506a660
plugin
:
generic
diffractometers
:
-
name
:
d4ch
plugin
:
bliss_controller
module
:
diffractometers.diff_fourc
class
:
DiffE4CH
geometry
:
E4CH
...
...
@@ -27,8 +29,7 @@ diffractometers:
tags
:
q_q
-
name
:
zaxis
plugin
:
bliss_controller
-
name
:
zaxis
module
:
diffractometers.diff_zaxis
class
:
DiffZAXIS
geometry
:
ZAXIS
...
...
tests/test_configuration/motors/__init__.yml
View file @
4506a660
plugin
:
bliss_controller
#
emotion
plugin
:
emotion
tests/test_configuration/regulation/__init__.yml
View file @
4506a660
plugin
:
bliss_controller
#
regulation
plugin
:
regulation
tests/test_configuration/regulation/test.yml
View file @
4506a660
#============= SOFTWARE REGULATION OBJECTS ==============================================================
-
class
:
MyDevice
# <== any kind of object (usually declared in another YML file)
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
name
:
my_device
-
class
:
MyCustomInput
# <== a custom input defined by the user, inheriting from the ExternalInput class
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
name
:
custom_input
device
:
$my_device
# <== any kind of object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
deg
-
name
:
my_device
class
:
MyDevice
# <== any kind of object (usually declared in another YML file)
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
-
name
:
custom_input
class
:
MyCustomInput
# <== a custom input defined by the user, inheriting from the ExternalInput class
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
device
:
$my_device
# <== any kind of object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
deg
-
class
:
MySensorBindToAxis
# <== a custom input which returns a value modified by the position of an axis ('linked_axis')
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
name
:
bound_input
device
:
$my_device
# <== any kind of object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
deg
linked_axis
:
$robz
-
name
:
bound_input
class
:
MySensorBindToAxis
# <== a custom input which returns a value modified by the position of an axis ('linked_axis')
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
device
:
$my_device
# <== any kind of object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
deg
linked_axis
:
$robz
-
class
:
MyCustomOutput
# <== a custom output defined by the user, inheriting from the ExternalOutput class
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
name
:
custom_output
device
:
$my_device
# <== any kind of object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
W
low_limit
:
0.0
# <== minimum device value [unit]
high_limit
:
100.0
# <== maximum device value [unit]
ramprate
:
0.0
# <== ramprate to reach the output value [unit/s].
-
name
:
custom_output
class
:
MyCustomOutput
# <== a custom output defined by the user, inheriting from the ExternalOutput class
package
:
bliss.controllers.regulation.temperature.mockup
#module: regulation.temperature.mockup
plugin
:
bliss
device
:
$my_device
# <== any kind of object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
W
low_limit
:
0.0
# <== minimum device value [unit]
high_limit
:
100.0
# <== maximum device value [unit]
ramprate
:
0.0
# <== ramprate to reach the output value [unit/s].
-
name
:
diode_input
class
:
ExternalInput
# <== declare an 'ExternalInput' object
package
:
bliss.common.regulation
device
:
$diode
# <== a SamplingCounter object reference (pointing to a counter declared somewhere else in a YML config file)
unit
:
N/A
-
class
:
ExternalInput
# <== declare an 'ExternalInput' object
package
:
bliss.common.regulation
name
:
diode_input
device
:
$diode
# <== a SamplingCounter object reference (pointing to a counter declared somewhere else in a YML config file)
unit
:
N/A
-
class
:
ExternalOutput
# <== declare an 'ExternalOutput' object
package
:
bliss.common.regulation
name
:
robz_output
device
:
$robz
# <== an axis object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
mm
low_limit
:
-1.0
# <== minimum device value [unit]
high_limit
:
1.0
# <== maximum device value [unit]
ramprate
:
0.0
# <== ramprate to reach the output value [unit/s].
mode
:
relative
# <== the axis will perform relative moves (use 'absolute' for absolute moves)
-
name
:
robz_output
class
:
ExternalOutput
# <== declare an 'ExternalOutput' object
package
:
bliss.common.regulation
device
:
$robz
# <== an axis object reference (pointing to an object declared somewhere else in a YML config file)
unit
:
mm
low_limit
:
-1.0
# <== minimum device value [unit]
high_limit
:
1.0
# <== maximum device value [unit]
ramprate
:
0.0
# <== ramprate to reach the output value [unit/s].
mode
:
relative
# <== the axis will perform relative moves (use 'absolute' for absolute moves)
-
class
:
SoftLoop
# <== declare a 'SoftLoop' object
package
:
bliss.common.regulation
name
:
soft_regul
input
:
$custom_input
output
:
$custom_output
P
:
0.05
I
:
0.1
D
:
0.0
low_limit
:
0.0
# <== low limit of the PID output value. Usaually equal to 0 or -1.
high_limit
:
1.0
# <== high limit of the PID output value. Usaually equal to 1.
frequency
:
10.0
deadband
:
0.1
deadband_time
:
3.0
ramprate
:
1.0
wait_mode
:
deadband
max_attempts_before_failure
:
3
-
name
:
soft_regul
class
:
SoftLoop
# <== declare a 'SoftLoop' object
package
:
bliss.common.regulation
input
:
$custom_input
output
:
$custom_output
P
:
0.05
I
:
0.1
D
:
0.0
low_limit
:
0.0
# <== low limit of the PID output value. Usaually equal to 0 or -1.