summaryrefslogtreecommitdiff
path: root/core/acquisition.py
diff options
context:
space:
mode:
authorChristian Kolset <ckolset@colostate.edu>2026-08-13 10:59:25 -0600
committerChristian Kolset <ckolset@colostate.edu>2026-08-13 11:04:34 -0600
commit012a1093e3cb9a1b376fc3beee4df859ccfb8da5 (patch)
treeacc261cd944187961c65bafcdea84137f87d0ead /core/acquisition.py
parentb7b3a84f37cc94494e17ea2098f72d6317090c53 (diff)
Fixed loading profiles data retention and display.
Diffstat (limited to 'core/acquisition.py')
-rw-r--r--core/acquisition.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/acquisition.py b/core/acquisition.py
index 79bdb79..f54f265 100644
--- a/core/acquisition.py
+++ b/core/acquisition.py
@@ -112,6 +112,24 @@ class AcquisitionEngine(QObject):
for ch in dev.info.channels:
self._last_units[(dev.info.device_id, ch.channel_id)] = ch.unit
+ def on_device_reconfigured(self, device_id: str):
+ """Reconcile buffers with a device's current channel list — reconfigure()
+ can add/remove channels (e.g. Signals count changed), and buffers keyed
+ by the old channel list would silently drop data for anything new."""
+ dev = next((d for d in self._devices if d.info.device_id == device_id), None)
+ if dev is None:
+ return
+ bufs = self._buffers.setdefault(device_id, {})
+ valid_ids = {ch.channel_id for ch in dev.info.channels}
+ for stale_id in [cid for cid in bufs if cid not in valid_ids]:
+ bufs.pop(stale_id, None)
+ for ch in dev.info.channels:
+ if ch.channel_id not in bufs:
+ bufs[ch.channel_id] = ChannelBuffer()
+ self._last_units[(device_id, ch.channel_id)] = ch.unit
+ for key in [k for k in self._last_units if k[0] == device_id and k[1] not in valid_ids]:
+ self._last_units.pop(key, None)
+
def remove_device(self, device_id: str):
self._devices = [d for d in self._devices if d.info.device_id != device_id]
self._buffers.pop(device_id, None)