Commit 36fce890 authored by Perceval Guillou's avatar Perceval Guillou
Browse files

fix motors switches

parent 73f9017e
......@@ -171,6 +171,16 @@ class Controller(BlissController):
self.__initialized_encoder[encoder] = False
return encoder
elif parent_key == "switches":
switch = item_class(name, cfg)
self._switches[name] = switch
return switch
elif parent_key == "shutters":
shutter = item_class(name, cfg)
self._shutters[name] = shutter
return shutter
def _init(self):
try:
self.initialize()
......
......@@ -112,6 +112,23 @@ class Icepap(Controller):
self._last_axis_power_time = {}
self._limit_search_in_progress = weakref.WeakKeyDictionary()
def _create_subitem_from_config(
self, name, cfg, parent_key, item_class, item_obj=None
):
if parent_key == "switches":
switch = item_class(name, self, cfg)
self._switches[name] = switch
return switch
elif parent_key == "shutters":
shutter = item_class(name, self, cfg)
self._shutters[name] = shutter
return shutter
else:
return super()._create_subitem_from_config(
name, cfg, parent_key, item_class, item_obj
)
def initialize(self):
self._icestate = AxisState()
self._icestate.create_state("HOMEFOUND", "home signal found")
......
......@@ -51,7 +51,7 @@ class Switch(BaseSwitch):
include_rack = config.get("include-rack")
if include_rack is None: # All
include_rack = set()
for axis_class, axis_config in self.__controller._axes_config.values():
for axis_config in self.__controller._axes_config.values():
address = axis_config.get("address", None)
if not isinstance(address, int):
continue
......@@ -67,10 +67,7 @@ class Switch(BaseSwitch):
managed_rack = include_rack - exclude_rack
self.__addresses = dict()
for (
axis_name,
(axis_class, axis_config),
) in self.__controller._axes_config.items():
for axis_name, axis_config in self.__controller._axes_config.items():
address = axis_config.get("address", None)
if not isinstance(address, int):
continue
......
......@@ -14,9 +14,7 @@ import numpy as np
from bliss.physics.trajectory import LinearTrajectory
from bliss.controllers.motor import Controller, CalcController
from bliss.common.axis import Axis, AxisState
from bliss.common.switch import Switch as BaseSwitch
from bliss.common import event
from bliss.config.static import get_config
from bliss.config.settings import SimpleSetting
from bliss.common.hook import MotionHook
from bliss.common.utils import object_method
......@@ -49,11 +47,6 @@ class Motion:
self.trajectory = LinearTrajectory(pi, pf, velocity, acceleration, ti)
class Switch(BaseSwitch):
def __init__(self, name, controller, config):
super().__init__(name, config)
class MockupAxis(Axis):
def __init__(self, *args, **kwargs):
Axis.__init__(self, *args, **kwargs)
......@@ -89,18 +82,6 @@ class Mockup(Controller):
self._hw_state.create_state("PARKED", "mot au parking")
def _create_subitem_from_config(
self, name, cfg, parent_key, item_class, item_obj=None
):
if parent_key == "switches":
switch = item_class(name, self, cfg)
self._switches[name] = switch
return switch
else:
return super()._create_subitem_from_config(
name, cfg, parent_key, item_class, item_obj
)
def steps_position_precision(self, axis):
"""Mockup is really a stepper motor controller"""
return 1
......
......@@ -387,33 +387,6 @@ class musst(BlissController):
def _get_default_chain_counter_controller(self):
return self._counter_controllers["icc"]
def _create_subitem_from_config(
self, name, cfg, parent_key, item_class, item_obj=None
):
# Called when a new subitem is created (i.e accessed for the first time via self._get_subitem)
"""
Return the instance of a new item owned by this controller.
args:
name: item name
cfg : item config
parent_key: the config key under which the item was found (ex: 'counters').
item_class: a class to instantiate the item (None if item is a reference)
item_obj: the item instance (None if item is NOT a reference)
return: item instance
"""
# currently the only subitem of the musst with a name in config
# would be a channel of type switch which is expected to be a reference
# so item_class should be None and item_obj should be the switch instance
if parent_key == "channels":
if cfg.get("type") == "switch":
return item_obj
raise NotImplementedError
def _channels_init(self, config):
""" Handle configured channels """
......
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