diff options
| author | Christian Kolset <christian.kolset@gmail.com> | 2026-09-19 17:38:07 -0600 |
|---|---|---|
| committer | Christian Kolset <christian.kolset@gmail.com> | 2026-09-19 17:38:07 -0600 |
| commit | f3327d56d48d63b21ffc03a55fa5e7db753d1707 (patch) | |
| tree | e19d4c7846dd4a434f8a18f82290597731b4a12c /ui/main_window.py | |
| parent | 00671a90bb51bfe485d98a928a456d55adbe1faf (diff) | |
Redesign Signal/Channel naming and fix pin-remap breaking references
Arduino analog Signal ids used to be the pin name itself, so fixing a
wrong pin silently changed the id and orphaned any plot trace, control,
or filter pipeline pointing at it. Analog Signal ids are now positional
(ai0, ai1, ...) and decoupled from the underlying pin, matching how
digital I/O already worked.
More broadly, formalizes a Device -> Signal -> Channel -> Plot naming
model (SignalConfig for physical device channels, Channel for derived/
computed ones) and adds core/reference_registry.py to propagate any
Signal or Channel id rename through plot traces, controls, and filter
pipelines instead of leaving them dangling. Signal ids are now editable
in the Signals tab with the same propagation.
.labui profile schema bumped to v2.0 with a transparent migration for
old files, including remapping old pin-name Signal ids to the new
positional ones. Removed six confirmed-dead files (two legacy device
classes, four superseded top-level ui/ duplicates).
Diffstat (limited to 'ui/main_window.py')
| -rw-r--r-- | ui/main_window.py | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/ui/main_window.py b/ui/main_window.py index b632535..0e21b2e 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -93,9 +93,6 @@ class _DockTitleBar(QWidget): lay.addWidget(close_btn) -from devices.arduino_device import ArduinoDevice -from devices.nidaqmx_device import NidaqmxDevice -from devices.serial_device import SerialDevice from devices.device_registry import DeviceRegistry from core.acquisition import AcquisitionEngine from core.signal_processor import SignalProcessor @@ -148,24 +145,11 @@ class MainWindow(QMainWindow): self._wheel_blocker = _WheelBlocker(self) QApplication.instance().installEventFilter(self._wheel_blocker) - self._init_demo_devices() self._build_ui() self._connect_signals() self._init_plugins() self._apply_settings_on_startup() - # ── Demo ────────────────────────────────────────────────────────────── - - def _init_demo_devices(self): - for dev in [ - NidaqmxDevice(device_id="ni_0", num_analog=4, num_di=2, num_do=4, simulate=True), - ArduinoDevice(device_id="ard_0", num_analog=4, num_di=2, num_do=4, simulate=True), - SerialDevice (device_id="ser_0", num_channels=3, simulate=True), - ]: - dev.connect() - self.registry.add_instance(dev) - self.engine.add_device(dev) - # ── UI ──────────────────────────────────────────────────────────────── def _build_ui(self): @@ -276,7 +260,6 @@ class MainWindow(QMainWindow): # ── Control Panel dock ──────────────────────────────────────────── self._ctrl = ControlPanel(self.registry, processor=self.processor, engine=self.engine) self._ctrl.setMinimumWidth(200); self._ctrl.setMaximumWidth(340) - self._ctrl._add_demo_widgets() self._ctrl_dock = QDockWidget("Control Panel", self) self._ctrl_dock.setObjectName("controlPanelDock") @@ -561,6 +544,7 @@ class MainWindow(QMainWindow): self._win_config.channel_unit_changed.connect(self._on_channel_unit_changed) self._win_config.pipeline_changed.connect(lambda: None) self._win_config.derived_changed.connect(self._on_derived_changed) + self._win_config.channel_renamed.connect(self._on_channel_renamed) self._win_config.layout_applied.connect(self._chart.apply_layout) self._win_config.tabs.setCurrentIndex(tab) self._show_win(self._win_config, "right") @@ -762,6 +746,13 @@ class MainWindow(QMainWindow): if self._win_config: self._win_config.refresh_plot(self._chart._cfg) + def _on_channel_renamed(self, old_dev: str, old_id: str, new_dev: str, new_id: str): + """A Signal or Channel's id changed — rewrite every plot trace, + control target, and filter pipeline that still points at the old + (device_id, channel_id) pair so it doesn't silently stop updating.""" + from core.reference_registry import propagate_rename + propagate_rename(self, (old_dev, old_id), (new_dev, new_id)) + # ── Run / Log ───────────────────────────────────────────────────────── def _toggle_run(self, c: bool): |
