From 4ab2eea9af5338485303d421476fa874e5af6841 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Mon, 21 Sep 2026 00:16:15 -0600 Subject: Fix Buffer size setting never being applied; add Safety Switch control type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Buffer size (samples) in Settings > Acquisition was captured into the settings dict but never read anywhere — SignalBuffer always used the hardcoded MAX_BUFFER=20_000 constant (which happens to match the dialog's default, hence it looking like the value "reverts"). Add AcquisitionEngine.set_buffer_size(), wired in on startup and on Settings apply; existing buffers are rebuilt at the new size in place, keeping their most recent samples. - New "Safety Switch" control type: an On/Off Switch that's disabled outright until acquisition is running, with a lock icon shown while disabled. AcquisitionEngine gains a run_state_changed(bool) signal (emitted from start()/stop()); ControlWidget gains a _check_safety_lock() hook (no-op by default, called uniformly by ControlPanel on every widget) that SafetySwitch overrides. engine is now threaded through to every ControlWidget for this. Persists via ControlSpec.control_type alone — no schema change needed. Co-Authored-By: Claude Sonnet 5 --- ui/control_editor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ui/control_editor.py') diff --git a/ui/control_editor.py b/ui/control_editor.py index 40cde7e..e62e146 100644 --- a/ui/control_editor.py +++ b/ui/control_editor.py @@ -40,6 +40,7 @@ from devices.device_registry import DeviceRegistry CONTROL_TYPES = [ "On/Off Switch", + "Safety Switch", "Motor Control", "PWM Output", "Setpoint", @@ -48,6 +49,7 @@ CONTROL_TYPES = [ CONTROL_ICONS = { "On/Off Switch": "⏻", + "Safety Switch": "🔒", "Motor Control": "⟳", "PWM Output": "⊓", "Setpoint": "◎", @@ -160,6 +162,7 @@ class AnalogOutParams(QWidget): _PARAM_PANELS = { "On/Off Switch": OnOffParams, + "Safety Switch": OnOffParams, # same shape as On/Off — no extra params "Motor Control": MotorParams, "PWM Output": PwmParams, "Setpoint": SetpointParams, @@ -347,7 +350,7 @@ class ControlEditorDialog(QDialog): self._stack.setCurrentIndex(idx) self._stack.updateGeometry() self._params_grp.updateGeometry() - self._active_low_chk.setEnabled(type_name == "On/Off Switch") + self._active_low_chk.setEnabled(type_name in ("On/Off Switch", "Safety Switch")) # Auto-set title if still default if not self._title_edit.text() or \ self._title_edit.text() in CONTROL_TYPES: -- cgit v1.2.3