Commit 27be99fa authored by Perceval Guillou's avatar Perceval Guillou
Browse files

fix motor children

parent ec229a7d
......@@ -7,17 +7,18 @@ class Moco(Controller):
bliss.controllers.motor.Controller
"""
def __init__(self, name, config, axes, *args):
def _load_config(self):
if len(axes) > 1:
super()._load_config()
axnum = len(self.config.get("axes"))
if axnum > 1:
raise RuntimeError(
f"moco: only 1 motor is allowed, but {len(axes)} are configured."
f"moco: only 1 motor is allowed, but {axnum} are configured."
)
self.moco = config.get("moco")
super().__init__(self.moco.name + "_motor", config, axes, *args)
self.moco = self.config.get("moco")
self._name = self.moco.name + "_motor"
self.moco.motor = self
def initialize(self):
......
......@@ -39,27 +39,17 @@ _log = logging.getLogger("bliss.controllers.motors.spec")
class Spec(Controller):
def __init__(self, name, config, axes, *args, **kwargs):
new_axes = {}
# _log.warning(f"axes[{axes}]")
for axis_name, axis_cfg in axes.items():
axis_cfg = list(axis_cfg)
# change class name for axes created by this controller
# to NoSettingsAxis: no settings will be stored in redis,
# thus forcing to ask spec every time (no cache)
axis_cfg[0] = NoSettingsAxis
# make sure steps per unit is 1, to avoid conversions
# between spec units and Bliss units
assert (
axis_cfg[1].get("steps_per_unit", int) == 1
), "steps_per_unit must be defined and equal to 1"
new_axes[axis_name] = axis_cfg
Controller.__init__(self, name, config, new_axes, *args, **kwargs)
def _load_config(self):
super()._load_config()
for ax_cfg in self.config.get("axes", []):
if ax_cfg.get("steps_per_unit") != 1:
raise ValueError(f"steps_per_unit must be defined and equal to 1")
def _get_subitem_default_class_name(self, cfg, parent_key):
if parent_key == "axes":
return "NoSettingsAxis"
else:
return super()._get_subitem_default_class_name(cfg, parent_key)
def initialize(self):
self.connection = SpecConnection(self.config.get("spec"))
......
......@@ -50,9 +50,9 @@ from bliss.common.utils import object_attribute_get
class SpeedgoatMotor(Controller):
def __init__(self, name, config, *args, **kwargs):
Controller.__init__(self, name, config, *args, **kwargs)
self.speedgoat = config.get("speedgoat")
def _load_config(self):
super()._load_config()
self.speedgoat = self.config.get("speedgoat")
self._axis_init_done = {}
def initialize(self):
......
......@@ -23,14 +23,12 @@ computer.
class TangoEMot(Controller):
def __init__(self, *args, **kwargs):
Controller.__init__(self, *args, **kwargs)
def _load_config(self):
super()._load_config()
# Gets DS name from xml config.
self.ds_name = self.config.get("ds_name")
# tests if DS is responding.
def initialize(self):
pass
......
......@@ -8,10 +8,6 @@ class Wago:
class WagoMotor(Controller):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def initialize(self):
# initialize hardware communication
self.wago = self.config.get("wago", converter=None)
......
......@@ -1136,9 +1136,10 @@ 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 == "bliss_controller" and instance_name in item_cfg.get(
"tango_server", ()
):
if item_cfg.plugin in [
"bliss_controller",
"emotion",
] and instance_name in item_cfg.get("tango_server", ()):
result.append(item_name)
return result
......@@ -1351,7 +1352,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 == "bliss_controller":
if obj_cfg.plugin in ["bliss_controller", "emotion"]:
try:
if name in [x["name"] for x in obj_cfg.parent["axes"]]:
axis_names.append(name)
......
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