summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/reference_registry.py32
-rw-r--r--core/signal_processor.py17
2 files changed, 48 insertions, 1 deletions
diff --git a/core/reference_registry.py b/core/reference_registry.py
index b6fcd0f..7ab9649 100644
--- a/core/reference_registry.py
+++ b/core/reference_registry.py
@@ -20,7 +20,7 @@ hold such a reference and rewrites it. It expects a MainWindow instance
reachable from.
"""
-from typing import Tuple
+from typing import List, Tuple
Ref = Tuple[str, str]
@@ -72,3 +72,33 @@ def propagate_rename(app, old_ref: Ref, new_ref: Ref) -> None:
win.refresh_derived()
if hasattr(win, "refresh_devices"):
win.refresh_devices()
+
+
+def find_references(app, ref: Ref) -> List[str]:
+ """Reverse lookup: human-readable names of everything currently holding
+ a (device_id, channel_id) reference — same 5 subsystems propagate_rename()
+ walks, but collecting instead of rewriting. Used to flag a signal_id an
+ Apply & Reconnect just dropped (still referenced elsewhere = orphaned),
+ without blocking the reconnect itself — see devices_window/channels_window/
+ control_panel "missing source" indicators, which do the live per-widget
+ check; this is only for a one-line summary breadcrumb."""
+ found: List[str] = []
+
+ for dc in app.processor.get_derived():
+ if ref in dc.sources:
+ found.append(f"Channel '{dc.name}'")
+
+ chart = getattr(app, "_chart", None)
+ if chart is not None and chart._cfg is not None:
+ for pane in chart._cfg.panes:
+ for tr in pane.traces:
+ if (tr.device_id, tr.channel_id) == ref:
+ found.append(f"Plot '{pane.title}' trace '{tr.label or tr.channel_id}'")
+
+ ctrl = getattr(app, "_ctrl", None)
+ if ctrl is not None:
+ for spec in ctrl.get_specs():
+ if (spec.device_id, spec.channel_id) == ref:
+ found.append(f"Control '{spec.title}'")
+
+ return found
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: