summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorChristian Kolset <ckolset@colostate.edu>2026-08-10 16:12:05 -0600
committerChristian Kolset <ckolset@colostate.edu>2026-08-10 16:12:05 -0600
commit5d5bcaed8639a162fda85c8cd0d340c296a054b8 (patch)
treea7a1a62fb607c9c85127dab4aab17ccf8e22c906 /core
parent46231c00994cd681d598961f2056dbda31c3e483 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'core')
-rw-r--r--core/acquisition.py19
-rw-r--r--core/signal_processor.py4
2 files changed, 23 insertions, 0 deletions
diff --git a/core/acquisition.py b/core/acquisition.py
index 4fffb8b..79bdb79 100644
--- a/core/acquisition.py
+++ b/core/acquisition.py
@@ -73,12 +73,15 @@ class AcquisitionEngine(QObject):
new_data(timestamp, readings) # readings: list[(device_id, channel_id, value)] —
# one batched emit per poll tick, not one per channel
device_status_changed(device_id, status_str)
+ channel_unit_changed(device_id, channel_id, new_unit) # e.g. Mark-10 gauge
+ # switched lb/kgF/N/ozF on its own front panel
log_started(filepath)
log_stopped(filepath)
"""
new_data = pyqtSignal(float, list)
device_status_changed = pyqtSignal(str, str)
+ channel_unit_changed = pyqtSignal(str, str, str)
log_started = pyqtSignal(str)
log_stopped = pyqtSignal(str)
@@ -87,6 +90,8 @@ class AcquisitionEngine(QObject):
self._interval = poll_interval_ms / 1000.0
self._devices: List[BaseDevice] = []
self._buffers: Dict[str, Dict[str, ChannelBuffer]] = {}
+ self._last_units: Dict[Tuple[str, str], str] = {}
+ self._last_status: Dict[str, str] = {}
self._running = False
self._thread: Optional[threading.Thread] = None
self._t0 = 0.0
@@ -104,10 +109,15 @@ class AcquisitionEngine(QObject):
ch.channel_id: ChannelBuffer()
for ch in dev.info.channels
}
+ for ch in dev.info.channels:
+ self._last_units[(dev.info.device_id, ch.channel_id)] = ch.unit
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)
+ self._last_status.pop(device_id, None)
+ for key in [k for k in self._last_units if k[0] == device_id]:
+ self._last_units.pop(key, None)
def get_buffer(self, device_id: str, channel_id: str) -> Optional[ChannelBuffer]:
return self._buffers.get(device_id, {}).get(channel_id)
@@ -186,6 +196,10 @@ class AcquisitionEngine(QObject):
batch: List[Tuple[str, str, float]] = []
for dev in list(self._devices):
+ if self._last_status.get(dev.info.device_id) != dev.status.value:
+ self._last_status[dev.info.device_id] = dev.status.value
+ self.device_status_changed.emit(dev.info.device_id, dev.status.value)
+
active = dev.status in (DeviceStatus.CONNECTED, DeviceStatus.SIMULATED)
try:
readings = dev.read_channels() if active else {}
@@ -194,6 +208,11 @@ class AcquisitionEngine(QObject):
readings = {}
for ch in dev.info.channels:
+ key = (dev.info.device_id, ch.channel_id)
+ if self._last_units.get(key) != ch.unit:
+ self._last_units[key] = ch.unit
+ self.channel_unit_changed.emit(dev.info.device_id, ch.channel_id, ch.unit)
+
val = readings.get(ch.channel_id)
if val is None or not ch.enabled:
log_row.append("")
diff --git a/core/signal_processor.py b/core/signal_processor.py
index 8ab3937..c00df73 100644
--- a/core/signal_processor.py
+++ b/core/signal_processor.py
@@ -598,4 +598,8 @@ class SignalProcessor(QObject):
elif dc.kind == "none":
return inputs[0] if inputs else None
+ elif dc.kind == "scale_offset":
+ if not inputs: return None
+ return inputs[0] * dc.params.get("scale", 1.0) + dc.params.get("offset", 0.0)
+
return None