add(系统诊断: 设备检测和系统检测、dals中数据库路径)

This commit is contained in:
2026-01-13 18:31:54 +08:00
parent 29c459e0f2
commit 360cb13b73
5 changed files with 193 additions and 67 deletions

View File

@ -8,7 +8,7 @@ from view.widgets.message_popup_widget import MessagePopupWidget
from service.msg_recorder import MessageRecorder
from service.msg_query_thread import MsgQueryThread
from service.device_monitor_thread import DeviceMonitorThread
from service.monitor_thread import MonitorThread
"""
控制主界面底部的所有按钮, 包括系统诊断、系统中心等的行为。
@ -22,8 +22,10 @@ class BottomControlController:
# 系统诊断弹窗
self.system_diagnostics_dialog = SystemDiagnosticsDialog(self.main_window)
self.current_diagnostics_row = 0 # 系统诊断弹窗的行号从0开始
self.current_diagnostics_col = 0 # 系统诊断弹窗的列号从0开始
self.diagnostics_device_row = 0 # 系统诊断弹窗的设备检测行号从0开始
self.diagnostics_device_col = 0 # 系统诊断弹窗的设备检测列号从0开始
self.diagnostics_service_row = 0 # 系统诊断弹窗的服务检测行号从0开始
self.diagnostics_service_col = 2 # 系统诊断弹窗的服务检测行号从2开始
# 系统中心弹窗
self.system_center_dialog = SystemCenterDialog(self.main_window)
@ -42,14 +44,14 @@ class BottomControlController:
self.msg_query_thread.start() # 启动线程
# =======================================================================
# ===================== 设备检测(系统诊断相关) ====================================
self.device_monitor = DeviceMonitorThread()
# ===================== 检测线程(系统诊断相关) ====================================
self.device_monitor = MonitorThread()
self.device_monitor.start()
# =======================================================================
# 绑定主界面底部按钮的信号(如:系统诊断按钮等,点击触发弹窗)
self._bind_buttons()
# 绑定弹窗中按钮的信号
# 绑定弹窗的信号
self._bind_dialog_signals()
@Slot(int, list)
@ -83,20 +85,23 @@ class BottomControlController:
# 底部预警消息列表按钮 → 触发预警消息列表显示/隐藏
self.bottom_control_widget.warning_list_btn.clicked.connect(self.toggle_system_warning_msg_list)
# 设备检测结果显示(底部的系统诊断按钮处显示)
# 底部系统诊断按钮 → 设备检测结果显示(底部的系统诊断按钮处显示)
self.device_monitor.state_result.connect( self.bottom_control_widget.set_system_status, Qt.QueuedConnection)
def _bind_dialog_signals(self):
"""绑定弹窗按钮的信号"""
"""绑定弹窗的信号"""
# 系统中心弹窗的按钮信号
self.system_center_dialog.sys_setting_clicked.connect(self.handle_sys_setting)
self.system_center_dialog.data_center_clicked.connect(self.handle_data_center)
self.system_center_dialog.user_center_clicked.connect(self.handle_user_center)
# 系统诊断弹窗的信号
self.device_monitor.check_finished.connect(self.reset_diagnostics_row_col) # 重置系统诊断的行号和列号
self.device_monitor.connect_success.connect(self._handle_diagnostics_connect_success) # 设备正常
self.device_monitor.connect_failed.connect(self._handle_diagnostics_connect_failed) # 设备异常
self.device_monitor.check_finished.connect(self._reset_diagnostics_device) # 重置系统诊断弹窗中的设备检测
self.device_monitor.connect_success.connect(self._handle_diagnostics_device_connect_success) # 设备正常
self.device_monitor.connect_failed.connect(self._handle_diagnostics_device_connect_failed) # 设备异常
self.device_monitor.check_finished.connect(self._reset_diagnostics_service) # 重置系统诊断弹窗中的服务检测
self.device_monitor.service_normal.connect(self._handle_diagnostics_service_normal) # 服务正常
self.device_monitor.service_error.connect(self._handle_diagnostics_service_error) # 服务异常
# ------------------- 系统中心弹窗逻辑-------------------
def toggle_system_center_dialog(self):
@ -176,39 +181,93 @@ class BottomControlController:
# 设置弹窗位置
self.system_diagnostics_dialog.move(dialog_x, dialog_y)
def get_diagnostics_row_col(self):
"""获取系统诊断弹窗的 行号 和 列号, 都从0开始"""
diagnostics_row = self.current_diagnostics_row
diagnostics_col = self.current_diagnostics_col
self.current_diagnostics_col += 1
if self.current_diagnostics_col == self.system_diagnostics_dialog.max_col:
self.current_diagnostics_row += 1
self.current_diagnostics_col = 0
if self.current_diagnostics_row == self.system_diagnostics_dialog.max_row:
self.current_diagnostics_row = 0
return diagnostics_row, diagnostics_col
def _get_diagnostics_device_row_col(self):
"""获取系统诊断弹窗中 设备检测的 行号 和 列号, 都从0开始"""
device_row = self.diagnostics_device_row
device_col = self.diagnostics_device_col
self.diagnostics_device_col += 1
if self.diagnostics_device_col == self.system_diagnostics_dialog.max_col // 2: # 左边两列是 设备检测
self.diagnostics_device_row += 1
self.diagnostics_device_col = 0
if self.diagnostics_device_row == self.system_diagnostics_dialog.max_row:
self.diagnostics_device_row = 0
return device_row, device_col
def reset_diagnostics_row_col(self):
"""重置系统诊断弹窗的 行号 和 列号 为0"""
self.current_diagnostics_row = 0
self.current_diagnostics_col = 0
def _reset_diagnostics_device(self):
"""重置系统诊断弹窗中 设备检测"""
# 0、隐藏多余的设备检测框
# 1、设备检测的行号 和 列号(diagnostics_device_row、 self.diagnostics_device_col) 重置为0
while True:
if self.diagnostics_device_row == 0 and self.diagnostics_device_col == 0:
break
row, col = self._get_diagnostics_device_row_col()
self.system_diagnostics_dialog.set_selected_hide(row, col)
def _handle_diagnostics_connect_success(self, device_name:str, delay:int):
def _handle_diagnostics_device_connect_success(self, device_name:str, delay:int):
"""处理系统诊断弹窗: 设备连接成功 (设备检测正常)"""
row, col = self.get_diagnostics_row_col()
row, col = self._get_diagnostics_device_row_col()
self.system_diagnostics_dialog.set_selected_device(row, col, device_name)
self.system_diagnostics_dialog.set_ms_value(row, col, delay)
if delay <= self.device_monitor.warning_delay:
self.system_diagnostics_dialog.set_circle_status(row, col, "normal")
else:
self.system_diagnostics_dialog.set_circle_status(row, col, "warning")
# 显示检测组件
self.system_diagnostics_dialog.set_selected_show(row, col)
def _handle_diagnostics_connect_failed(self, device_name:str):
def _handle_diagnostics_device_connect_failed(self, device_name:str):
"""处理系统诊断弹窗: 设备检测异常"""
row, col = self.get_diagnostics_row_col()
row, col = self._get_diagnostics_device_row_col()
self.system_diagnostics_dialog.set_selected_device(row, col, device_name)
self.system_diagnostics_dialog.set_ms_value(row, col, -1)
self.system_diagnostics_dialog.set_circle_status(row, col, "error")
# 显示检测组件
self.system_diagnostics_dialog.set_selected_show(row, col)
def _get_diagnostics_service_row_col(self):
"""获取系统诊断弹窗中 服务检测的 行号 和 列号"""
service_row = self.diagnostics_service_row
service_col = self.diagnostics_service_col
self.diagnostics_service_col += 1
if self.diagnostics_service_col == self.system_diagnostics_dialog.max_col: # 右边两列是 服务检测
self.diagnostics_service_row += 1
self.diagnostics_service_col = 2
if self.diagnostics_service_row == self.system_diagnostics_dialog.max_row:
self.diagnostics_service_row = 0
return service_row, service_col
def _handle_diagnostics_service_normal(self, service_name:str, delay:int):
"""处理系统诊断弹窗: 服务检测正常"""
row, col = self._get_diagnostics_service_row_col()
self.system_diagnostics_dialog.set_selected_service(row, col, service_name)
self.system_diagnostics_dialog.set_ms_value(row, col, delay)
if delay <= self.device_monitor.warning_delay:
self.system_diagnostics_dialog.set_circle_status(row, col, "normal")
else:
self.system_diagnostics_dialog.set_circle_status(row, col, "warning")
# 显示检测组件
self.system_diagnostics_dialog.set_selected_show(row, col)
def _handle_diagnostics_service_error(self, service_name:str):
"""处理系统诊断弹窗: 服务检测异常"""
row, col = self._get_diagnostics_service_row_col()
self.system_diagnostics_dialog.set_selected_service(row, col, service_name)
self.system_diagnostics_dialog.set_ms_value(row, col, -1)
self.system_diagnostics_dialog.set_circle_status(row, col, "error")
# 显示检测组件
self.system_diagnostics_dialog.set_selected_show(row, col)
def _reset_diagnostics_service(self):
"""重置系统诊断弹窗中 服务检测"""
# 0、隐藏多余的服务检测框
# 1、设备检测的行号 self.diagnostics_service_row 重置为0 self.diagnostics_service_col 重置为2
while True:
if self.diagnostics_service_row == 0 and self.diagnostics_service_col == 2:
break
row, col = self._get_diagnostics_service_row_col()
self.system_diagnostics_dialog.set_selected_hide(row, col)
# ================== 系统状态消息列表: 显示系统消息 ===================
def toggle_system_status_msg_list(self):