Clear warning

This commit is contained in:
atse 2023-08-11 17:09:33 +08:00
parent c3fdb105eb
commit 01a3601c3b
1 changed files with 16 additions and 1 deletions

View File

@ -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)