[feat] add cali check when conc > 10%
This commit is contained in:
parent
d223574333
commit
ddb64b4d90
@ -150,6 +150,8 @@ class MainWindow(QMainWindow):
|
|||||||
self.init_ui()
|
self.init_ui()
|
||||||
self.init_modbus()
|
self.init_modbus()
|
||||||
|
|
||||||
|
concentration = 0
|
||||||
|
|
||||||
def init_ui(self):
|
def init_ui(self):
|
||||||
"""初始化用户界面"""
|
"""初始化用户界面"""
|
||||||
self.setWindowTitle("气体浓度监测与标定系统")
|
self.setWindowTitle("气体浓度监测与标定系统")
|
||||||
@ -254,6 +256,7 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def update_concentration(self, concentration):
|
def update_concentration(self, concentration):
|
||||||
"""更新浓度显示"""
|
"""更新浓度显示"""
|
||||||
|
self.concentration = concentration
|
||||||
# 直接显示整数,不加小数位
|
# 直接显示整数,不加小数位
|
||||||
if license_check():
|
if license_check():
|
||||||
self.concentration_label.setText(f"{concentration} ppm")
|
self.concentration_label.setText(f"{concentration} ppm")
|
||||||
@ -261,9 +264,9 @@ class MainWindow(QMainWindow):
|
|||||||
self.concentration_label.setText("许可证无效")
|
self.concentration_label.setText("许可证无效")
|
||||||
|
|
||||||
# 根据浓度值改变颜色
|
# 根据浓度值改变颜色
|
||||||
if concentration < 100:
|
if concentration < 100000:
|
||||||
color = "#27ae60" # 绿色
|
color = "#27ae60" # 绿色
|
||||||
elif concentration < 500:
|
elif concentration < 500000:
|
||||||
color = "#f39c12" # 橙色
|
color = "#f39c12" # 橙色
|
||||||
else:
|
else:
|
||||||
color = "#e74c3c" # 红色
|
color = "#e74c3c" # 红色
|
||||||
@ -280,6 +283,22 @@ class MainWindow(QMainWindow):
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
def start_calibration(self):
|
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:
|
if self.modbus_worker and not self.modbus_worker.calibrating:
|
||||||
self.calibrate_button.setEnabled(False)
|
self.calibrate_button.setEnabled(False)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user