fix(galilsignalbase): fix root access for controller from parent.
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m27s
CI for csaxs_bec / test (pull_request) Failing after 1m29s

This commit is contained in:
2026-02-11 09:44:35 +01:00
parent 27befc5703
commit 1cbc9c0a79
2 changed files with 6 additions and 18 deletions

View File

@@ -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):

View File

@@ -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