summaryrefslogtreecommitdiff
path: root/core/signal_processor.py
diff options
context:
space:
mode:
authorChristian Kolset <christian.kolset@gmail.com>2026-09-20 11:31:07 -0600
committerChristian Kolset <christian.kolset@gmail.com>2026-09-20 11:31:07 -0600
commitbb8be051ffffa56a01093c9f3aaa80e84748568f (patch)
treedb5c0e3e5f8a453984aea9c70afa007319c610c3 /core/signal_processor.py
parentf3327d56d48d63b21ffc03a55fa5e7db753d1707 (diff)
Fix Signal name reset and orphaned references on device reconfigure
Apply & Reconnect rebuilt a device's whole Signal list from hardware defaults on every call, silently discarding user/profile-set names, units, and colors even when pins hadn't changed. Add merge_signal_metadata() and call it from ArduinoDevice.remap_pins() and SerialDevice.reconfigure() to reapply the same fields ProfileManager already treats as user overrides, keyed by signal_id. Also close a related gap: removing a pin that a Channel/Plot/Control still referenced left it silently dangling, and SignalProcessor never pruned its latest-value cache, so a derived Channel kept computing off a permanently frozen stale reading. Add SignalProcessor. on_device_reconfigured() to purge that cache, reference_registry. find_references() for a console breadcrumb, and live "missing source" indicators on Plot traces and Channel blocks reusing ControlWidget's existing stale/QSS pattern. Also fixes ControlWidget._write() still enqueuing writes to a channel that no longer exists. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'core/signal_processor.py')
-rw-r--r--core/signal_processor.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/signal_processor.py b/core/signal_processor.py
index da615b6..c79ea87 100644
--- a/core/signal_processor.py
+++ b/core/signal_processor.py
@@ -492,6 +492,23 @@ class SignalProcessor(QObject):
def all_virtual_channel_ids(self) -> List[str]:
return list(self._derived_bufs.keys())
+ def on_device_reconfigured(self, device_id: str, current_signal_ids: set) -> List[str]:
+ """Drop cached state for any signal_id a device's Apply & Reconnect
+ just removed — otherwise _latest keeps a stale frozen (timestamp,
+ value) forever (it's only ever written to, never pruned elsewhere),
+ and a derived Channel sourced from that id keeps silently computing
+ off that frozen value instead of skipping like a genuinely-missing
+ source would. Mirrors AcquisitionEngine.on_device_reconfigured().
+ Returns the removed signal_ids (those with a cached entry keyed to
+ this device that's no longer in current_signal_ids), so the caller
+ can flag any still-dangling references without recomputing the diff."""
+ removed = []
+ with self._lock:
+ for key in [k for k in self._latest if k[0] == device_id and k[1] not in current_signal_ids]:
+ self._latest.pop(key, None)
+ removed.append(key[1])
+ return removed
+
def clear_history(self):
"""Clear derived channel buffers and latest-value cache."""
with self._lock: