diff --git a/csaxs_bec/devices/omny/galil/galil_rio.py b/csaxs_bec/devices/omny/galil/galil_rio.py index ed9c021..7788a27 100644 --- a/csaxs_bec/devices/omny/galil/galil_rio.py +++ b/csaxs_bec/devices/omny/galil/galil_rio.py @@ -72,6 +72,7 @@ class GalilRIOSignalRO(GalilSignalRO): def __init__(self, signal_name: str, channel: int, **kwargs): super().__init__(signal_name, **kwargs) self._channel = channel + self._metadata["connected"] = False def _socket_get(self) -> float: """Get command for the readback signal""" @@ -123,25 +124,29 @@ class GalilRIO(PSIDeviceBase): ) super().__init__(name=name, device_manager=device_manager, scan_info=scan_info, **kwargs) - self._metadata["connected"] = False - def wait_for_connection(self, timeout: float = 30.0, **kwargs) -> None: """Wait for the RIO controller to be connected within timeout period.""" self.controller.on(timeout=timeout) - self._metadata["connected"] = True + self._update_connection_state() def destroy(self) -> None: """Make sure to turn off the controller socket on destroy.""" self.controller.off() + self._update_connection_state() return super().destroy() + def _update_connection_state(self, **kwargs): + for walk in self.walk_signals(): + walk.item._metadata["connected"] = self.controller.connected + def read(self): """Read all 8 analog input channels from the Galil RIO controller.""" # Get number of channels channels: list[tuple[int, str]] = [()] res = super().read() - for _, signal in self._get_components_of_kind(Kind.normal): # This gets all signals + # This yields tuples of cpt, signal + for _, signal in self._get_components_of_kind(Kind.normal): channels.append((signal._channel, signal.name)) # pylint: disable=protected-access cmd = "MG@" + ",@".join([f"AN[{ii}]" for ii, _ in channels])