From ddb64b4d90af5eec97e0065a4b8d5d23577a9de6 Mon Sep 17 00:00:00 2001 From: zhji Date: Sun, 21 Dec 2025 19:27:20 +0800 Subject: [PATCH] [feat] add cali check when conc > 10% --- python/hfc/cali.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/python/hfc/cali.py b/python/hfc/cali.py index b22d61c..70a5f31 100644 --- a/python/hfc/cali.py +++ b/python/hfc/cali.py @@ -149,6 +149,8 @@ class MainWindow(QMainWindow): self.modbus_worker = None self.init_ui() self.init_modbus() + + concentration = 0 def init_ui(self): """初始化用户界面""" @@ -254,6 +256,7 @@ class MainWindow(QMainWindow): def update_concentration(self, concentration): """更新浓度显示""" + self.concentration = concentration # 直接显示整数,不加小数位 if license_check(): self.concentration_label.setText(f"{concentration} ppm") @@ -261,9 +264,9 @@ class MainWindow(QMainWindow): self.concentration_label.setText("许可证无效") # 根据浓度值改变颜色 - if concentration < 100: + if concentration < 100000: color = "#27ae60" # 绿色 - elif concentration < 500: + elif concentration < 500000: color = "#f39c12" # 橙色 else: color = "#e74c3c" # 红色 @@ -280,6 +283,22 @@ class MainWindow(QMainWindow): """) def start_calibration(self): + """当浓度大于10%时提示用户""" + if self.concentration > 100000: + msg_box = QMessageBox() + msg_box.setWindowTitle("标定操作") + msg_box.setText("当前浓度较高,是否继续标定?") + msg_box.setIcon(QMessageBox.Question) + calibrate_button = msg_box.addButton("继续标定", QMessageBox.AcceptRole) + cancel_button = msg_box.addButton("取消", QMessageBox.RejectRole) + msg_box.setDefaultButton(cancel_button) + msg_box.exec_() + clicked_button = msg_box.clickedButton() + if clicked_button == calibrate_button: + print("用户选择了【进行标定】") + else: + print("用户选择了【取消标定】") + return """开始标定""" if self.modbus_worker and not self.modbus_worker.calibrating: self.calibrate_button.setEnabled(False)