From 5d5bcaed8639a162fda85c8cd0d340c296a054b8 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Mon, 10 Aug 2026 16:12:05 -0600 Subject: Unify Signals/Channels around auto-naming, plot-by-channel, and shared vars Devices: auto-name from OS-reported port description (Device Manager / udev string) instead of a generic label; default Serial #Channels 1; consistent simulate-mode checkbox across backends; inline device rename. Channels: calibration/filters move out of Signals into a Channel "Operation" (adds Scale/Offset alongside the existing math kinds); single-physical-source Channels get an embedded Filters block; new Channels auto-name/auto-ID from their source and reject duplicate names/IDs on apply; "Create Channel" button on each Signal row; renamed "Sources" -> "Signals" in the Channels UI; Signals' READ/WRITE dir badge (was silently-broken IN/OUT) now reflects the real writable flag. Plot: default layout is one pane per Channel (not per device, not raw Signals) titled by channel name; "+ Add Channel" is a checkbox dialog instead of an inline dropdown; traces get up/down reorder; live unit changes (e.g. a Mark-10 gauge switching lb/kgF/N/ozF) propagate to an open pane's axis label without clobbering a manually-typed one. Control Panel: hardware assignment now picks from the same writable- Signals list instead of a separate device/channel combo with a hardcoded Arduino pin list; stale visual indicator when a control's target device/channel disconnects or disappears; documented the `vars` bridge (Control Panel On Action Script <-> Channel scripts) in both directions' help text and script templates. Co-Authored-By: Claude Sonnet 5 --- devices/arduino_device.py | 7 ++++++- devices/serial_device.py | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 10 deletions(-) (limited to 'devices') diff --git a/devices/arduino_device.py b/devices/arduino_device.py index 2f5e8e6..3ad0c7b 100644 --- a/devices/arduino_device.py +++ b/devices/arduino_device.py @@ -112,9 +112,14 @@ class ArduinoDevice(BaseDevice): color=_DO_COLORS[i % len(_DO_COLORS)], )) + _desc = ArduinoLayer.describe_port(port) if not simulate else "" + if _desc: + _name = _desc if port in _desc else f"{_desc} ({port})" + else: + _name = f"Arduino ({port})" info = DeviceInfo( device_id=device_id, - name="Arduino", + name=_name, device_type=self.DEVICE_TYPE, description=(f"Arduino — {len(self._analog_pins)} analog, " f"{len(self._di_pins)} DI, {len(self._do_pins)} DO"), diff --git a/devices/serial_device.py b/devices/serial_device.py index fb131aa..61c3a64 100644 --- a/devices/serial_device.py +++ b/devices/serial_device.py @@ -52,6 +52,27 @@ _LABEL_FOR: Dict[str, str] = {v: k for k, v in _FORMAT_LABELS.items()} _GENERIC_FORMATS = {"key:val", "csv", "json"} _PROTOCOL_FORMATS = {"scpi", "modbus_rtu", "mark10", "cml"} +# parse_format → auto-name label — fallback only, used when the OS can't +# describe the port (simulation mode, or the device isn't enumerable) +_AUTO_NAME_LABEL: Dict[str, str] = { + "mark10": "Mark-10 USB Device", + "scpi": "SCPI Serial Device", + "modbus_rtu": "Modbus Serial Device", + "cml": "CML Serial Device", +} + + +def _auto_name(parse_format: str, port: str, simulate: bool = False) -> str: + """Prefer the OS-reported device description (same string Windows Device + Manager / Linux udev shows for this port) over a generic protocol label, + so the auto-assigned name matches what the operator sees outside the app.""" + if not simulate: + desc = ArduinoLayer.describe_port(port) + if desc: + return desc if port in desc else f"{desc} ({port})" + label = _AUTO_NAME_LABEL.get(parse_format, "USB Serial Device") + return f"{label} ({port})" + # Index into the config-widget stacked panel _STACK_IDX = { "key:val": 0, @@ -78,7 +99,7 @@ class SerialDevice(BaseDevice): parse_format: str = "key:val", simulate: bool = True, # ── Generic stream options ────────────────────────────────────── - num_channels: int = 4, + num_channels: int = 1, channel_names: List[str] = None, units: List[str] = None, # ── SCPI ─────────────────────────────────────────────────────── @@ -116,7 +137,7 @@ class SerialDevice(BaseDevice): channels = self._build_channel_configs() info = DeviceInfo( device_id=device_id, - name="Serial / UART", + name=_auto_name(parse_format, port, simulate), device_type=self.DEVICE_TYPE, description=self._description(), icon=self.ICON, @@ -459,14 +480,12 @@ class SerialConfigWidget(QWidget): self._fmt_cb.currentIndexChanged.connect(self._on_fmt_changed) conn_form.addRow("Protocol / Format:", self._fmt_cb) - self._sim_cb = QComboBox() - self._sim_cb.addItems(["Simulate", "Real Hardware"]) - self._sim_cb.setCurrentIndex(0 if self.device.simulate else 1) + self._sim_cb = QCheckBox("Simulation Mode (no hardware)") + self._sim_cb.setChecked(self.device.simulate) from core.app_settings import is_developer_mode - mode_lbl = QLabel("Mode:") dev_mode = is_developer_mode() - mode_lbl.setVisible(dev_mode); self._sim_cb.setVisible(dev_mode) - conn_form.addRow(mode_lbl, self._sim_cb) + self._sim_cb.setVisible(dev_mode) + conn_form.addRow(self._sim_cb) root.addWidget(conn_grp) @@ -535,7 +554,7 @@ class SerialConfigWidget(QWidget): port=self._port_edit.text().strip() or "COM3", baud=int(self._baud_cb.currentText()), fmt=fmt, - simulate=(self._sim_cb.currentIndex() == 0), + simulate=self._sim_cb.isChecked(), ) if fmt in _GENERIC_FORMATS: kwargs.update(self._generic_panel.collect()) -- cgit v1.2.3