From 8200d3f7c524d9b97184fa4be28ea227846aca7d Mon Sep 17 00:00:00 2001 From: appel_c Date: Mon, 26 Jan 2026 10:09:46 +0100 Subject: [PATCH] w --- csaxs_bec/devices/omny/galil/galil_rio.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/csaxs_bec/devices/omny/galil/galil_rio.py b/csaxs_bec/devices/omny/galil/galil_rio.py index 8c8fb1d..febef29 100644 --- a/csaxs_bec/devices/omny/galil/galil_rio.py +++ b/csaxs_bec/devices/omny/galil/galil_rio.py @@ -79,7 +79,6 @@ class GalilRIOSignalRO(GalilSignalRO): super().__init__(signal_name, parent=parent, **kwargs) self._channel = channel self._metadata["connected"] = False - self.last_readback = self.parent.last_readback def _socket_get(self) -> float: """Get command for the readback signal""" @@ -93,8 +92,8 @@ class GalilRIOSignalRO(GalilSignalRO): def get(self): """Get current analog channel values from the Galil RIO controller.""" # If the last readback has happend more than 0.5 seconds ago, read all channels again - logger.debug(f"Reading value for {self.name}, last readback at {self.last_readback}") - if time.monotonic() - self.last_readback < 0.5: # self._READ_TIMEOUT: + logger.debug(f"Reading value for {self.name}, last readback at {self.parent.last_readback}") + if time.monotonic() - self.parent.last_readback < 0.5: # self._READ_TIMEOUT: logger.debug(f"Using cached readback value for {self.name}: {self._readback}") return self._readback self._readback = self._socket_get() @@ -112,7 +111,7 @@ class GalilRIOSignalRO(GalilSignalRO): """ timestamp = time.time() # NOTE: Update parent's last readback before running subscriptions!! - self.parent.last_readback = time.monotonic() + self.parent._last_readback = time.monotonic() for walk in self.parent.walk_signals(): if walk.item.attr_name.startswith("an_ch"): idx = int(walk.item.attr_name[-1]) @@ -162,12 +161,17 @@ class GalilRIO(PSIDeviceBase): self.controller = GalilRIOController( socket_cls=socket_cls, socket_host=host, socket_port=port, device_manager=device_manager ) - self.last_readback: float = time.monotonic() + self._last_readback: float = time.monotonic() super().__init__(name=name, device_manager=device_manager, scan_info=scan_info, **kwargs) self.controller.subscribe( self._update_connection_state, event_type=self.SUB_CONNECTION_CHANGE ) + @property + def last_readback(self) -> float: + """Return the time of the last readback from the controller.""" + return self._last_readback + def wait_for_connection(self, timeout: float = 30.0) -> None: """Wait for the RIO controller to be connected within timeout period.""" self.controller.on(timeout=timeout)