From c3f07a7ffa320aecb3fca5dd40e7644424bddfb5 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Mon, 27 Jul 2026 17:13:41 -0600 Subject: Fix .gitignore: remove duplicate entry for plugins/enabled.json --- .gitignore | 1 + devices/serial_device.py | 2 ++ ui/control_panel.py | 17 +++++++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c2d1427..bcef6d0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pychache__/ .claude/settings.local.json plugins/enabled.json plugins/enabled.json +plugins/enabled.json diff --git a/devices/serial_device.py b/devices/serial_device.py index 8b8de04..ca551c6 100644 --- a/devices/serial_device.py +++ b/devices/serial_device.py @@ -157,6 +157,8 @@ class SerialDevice(BaseDevice): return mapped def write_channel(self, channel_id: str, value: Any) -> bool: + if self.status not in (DeviceStatus.CONNECTED, DeviceStatus.SIMULATED): + return False return self._layer.write(channel_id, int(value)) def get_config_widget(self) -> QWidget: diff --git a/ui/control_panel.py b/ui/control_panel.py index 6e78e89..2b936c4 100644 --- a/ui/control_panel.py +++ b/ui/control_panel.py @@ -33,6 +33,7 @@ from PyQt6.QtCore import Qt, pyqtSignal, QTimer from PyQt6.QtGui import QFont from devices.device_registry import DeviceRegistry +from devices.base_device import DeviceStatus # ══════════════════════════════════════════════════════════════════════════════ @@ -119,13 +120,17 @@ class ControlWidget(QFrame): if self.registry and self.device_id and self.channel_id: dev = self.registry.get_instance(self.device_id) if dev: - ok = dev.write_channel(self.channel_id, value) - if ok: - written = True + if dev.status not in (DeviceStatus.CONNECTED, DeviceStatus.SIMULATED): + print(f"[Control] write_channel({self.channel_id}, {value}) skipped on " + f"{self.device_id} — device status is {dev.status.value}, not connected") else: - print(f"[Control] write_channel({self.channel_id}, {value}) " - f"returned False on {self.device_id} — " - f"check device type and channel ID") + ok = dev.write_channel(self.channel_id, value) + if ok: + written = True + else: + print(f"[Control] write_channel({self.channel_id}, {value}) " + f"returned False on {self.device_id} — " + f"check device type and channel ID") self.value_changed.emit(self.channel_id, value) if self._on_action_fn is not None: -- cgit v1.2.3