From 012a1093e3cb9a1b376fc3beee4df859ccfb8da5 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Thu, 13 Aug 2026 10:59:25 -0600 Subject: Fixed loading profiles data retention and display. --- core/acquisition.py | 18 ++++++++++++++++++ core/profile.py | 6 ++++++ 2 files changed, 24 insertions(+) (limited to 'core') 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) diff --git a/core/profile.py b/core/profile.py index 8c73b4b..1fa667a 100644 --- a/core/profile.py +++ b/core/profile.py @@ -306,6 +306,12 @@ class ProfileManager: if engine is not None: engine.remove_device(dev.info.device_id) + # Clear signal pipelines and derived channels — profile defines the + # complete set; otherwise the previous profile's leftovers stick around. + processor._pipelines.clear() + for dc in list(processor.get_derived()): + processor.remove_derived(dc.channel_id) + for dev_cfg in profile.devices: dev_type = dev_cfg.get("device_type") dev_id = dev_cfg.get("device_id") -- cgit v1.2.3