From 01a3601c3b6e48ef7876cea7e0c8cb55f232b7b9 Mon Sep 17 00:00:00 2001 From: atse Date: Fri, 11 Aug 2023 17:09:33 +0800 Subject: [PATCH] Clear warning --- pytec/tec_qt.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index e154924..c8bfbf0 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -80,6 +80,9 @@ def get_argparser(): class WrappedClient(QObject, Client): connection_error = pyqtSignal() + def __init__(self, parent): + super().__init__(parent) + async def _read_line(self): try: return await super()._read_line() @@ -87,6 +90,18 @@ class WrappedClient(QObject, Client): logging.error("Client connection error, disconnecting", exc_info=True) self.connection_error.emit() + async def _check_zero_limits(self): + pwm_report = await self.get_pwm() + for pwm_channel in pwm_report: + if (neg := pwm_channel["max_i_neg"]["value"]) != (pos := pwm_channel["max_i_pos"]["value"]): + # Set the minimum of the 2 + lcd = min(neg, pos) + await self.set_param("pwm", pwm_channel["channel"], 'max_i_neg', lcd) + await self.set_param("pwm", pwm_channel["channel"], 'max_i_pos', lcd) + for limit in ["max_i_pos", "max_v"]: + if pwm_channel[limit]["value"] == 0.0: + QtWidgets.QMessageBox.warning(self.parent(), "Limits", "Max {} is set to zero on channel {}!".format("Current" if limit == "max_i_pos" else "Voltage", pwm_channel["channel"])) + class ClientWatcher(QObject): fan_update = pyqtSignal(dict) @@ -180,7 +195,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.hw_rev_data = None - self.client = WrappedClient() + self.client = WrappedClient(self) self.client.connection_error.connect(self.bail) self.client_watcher = ClientWatcher(self, self.client, self.report_refresh_spin.value()) self.client_watcher.fan_update.connect(self.fan_update)