diff --git a/csaxs_bec/devices/omny/galil/galil_ophyd.py b/csaxs_bec/devices/omny/galil/galil_ophyd.py index c1215b1..f05325e 100644 --- a/csaxs_bec/devices/omny/galil/galil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/galil_ophyd.py @@ -348,23 +348,7 @@ class GalilSignalBase(SocketSignal): def __init__(self, signal_name, **kwargs): self.signal_name = signal_name super().__init__(**kwargs) - self.controller: Controller = self._find_attribute_recursively("controller") - - def _find_attribute_recursively(self, attribute: str) -> Any: - """ - Find an attribute recursively for nested sub-devices. - This is needed to find for example the controller instance for DDC components, - thus nested devices. - """ - max_depth = 10 # to prevent infinite recursion - current_parent = self.parent - depth = 0 - while current_parent is not None and depth < max_depth: - if hasattr(current_parent, attribute): - return getattr(current_parent, attribute) - current_parent = getattr(current_parent, "parent", None) - depth += 1 - raise RuntimeError(f"Attribute '{attribute}' not found within maximum depth {max_depth}.") + self.controller = self.root.controller if hasattr(self.root, "controller") else None class GalilSignalRO(GalilSignalBase): diff --git a/csaxs_bec/devices/omny/galil/galil_rio.py b/csaxs_bec/devices/omny/galil/galil_rio.py index 0a3aabb..49df491 100644 --- a/csaxs_bec/devices/omny/galil/galil_rio.py +++ b/csaxs_bec/devices/omny/galil/galil_rio.py @@ -84,7 +84,11 @@ class GalilRIOSignal(GalilSignalBase): def __init__(self, signal_name: str, channel: int, parent: GalilRIO, **kwargs): super().__init__(signal_name, parent=parent, **kwargs) - self._readback_metadata = self._find_attribute_recursively("_readback_metadata") + self._readback_metadata = ( + self.root._readback_metadata + if hasattr(self.root, "_readback_metadata") + else {"last_readback": 0.0} + ) self._channel = channel self._metadata["connected"] = False