[feat] add cali check when conc > 10%

This commit is contained in:
zhji 2025-12-21 19:27:20 +08:00
parent d223574333
commit ddb64b4d90

View File

@ -150,6 +150,8 @@ class MainWindow(QMainWindow):
self.init_ui()
self.init_modbus()
concentration = 0
def init_ui(self):
"""初始化用户界面"""
self.setWindowTitle("气体浓度监测与标定系统")
@ -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)