fix online status && license revoke
This commit is contained in:
@@ -77,7 +77,7 @@ class ConnectionManager:
|
||||
self.log(f"压力地址: {pressure_addr}, 电机地址: {motor_addr}, 流量计地址: {flowmeter_addr}")
|
||||
|
||||
if self._on_status_change:
|
||||
self._on_status_change(True, "已连接")
|
||||
self._on_status_change(True, "● 已连接")
|
||||
|
||||
return True
|
||||
|
||||
@@ -94,7 +94,7 @@ class ConnectionManager:
|
||||
self.log("已断开连接")
|
||||
|
||||
if self._on_status_change:
|
||||
self._on_status_change(False, "未连接")
|
||||
self._on_status_change(False, "● 未连接")
|
||||
|
||||
def read_pressure(self):
|
||||
"""读取当前压力值(转换为实际物理量)
|
||||
|
||||
+11
-4
@@ -15,7 +15,7 @@ matplotlib.use('QtAgg')
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
from ui.main_window import MainWindow
|
||||
from license_utils import check_license
|
||||
from styles import apply_app_style
|
||||
|
||||
# 屏蔽多余警告
|
||||
@@ -81,16 +81,23 @@ def main():
|
||||
except (AttributeError, TypeError):
|
||||
pass # Qt < 6.5 无此方法,忽略
|
||||
|
||||
# 2. 应用全局样式
|
||||
# 2. 在导入 UI 前完成许可证校验。UI 导入的 `api` 模块会读取已验证
|
||||
# 许可证中的 device_id,因此撤销状态和设备心跳会使用同一个设备标识。
|
||||
check_license()
|
||||
|
||||
# 3. 应用全局样式
|
||||
colors = apply_app_style(app)
|
||||
_write_log("样式加载完成")
|
||||
|
||||
# 3. 创建主窗口
|
||||
# 延迟导入,避免 `api` 在许可证校验前缓存默认 device_id。
|
||||
from ui.main_window import MainWindow
|
||||
|
||||
# 4. 创建主窗口
|
||||
window = MainWindow(colors)
|
||||
_write_log("主窗口创建完成")
|
||||
window.show()
|
||||
|
||||
# 4. 进入事件循环
|
||||
# 5. 进入事件循环
|
||||
_write_log("进入事件循环")
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
@@ -460,6 +460,7 @@ class MainWindow(QMainWindow):
|
||||
if self.conn_mgr.is_connected():
|
||||
self.status_bar.set_log("正在断开连接...")
|
||||
self.conn_mgr.disconnect()
|
||||
self.status_bar.set_connection_status(False, "● 未连接")
|
||||
self.tab_connection._connect_text_lbl.setText(" 连接设备")
|
||||
self.status_bar.set_log("已断开设备连接")
|
||||
else:
|
||||
@@ -468,9 +469,11 @@ class MainWindow(QMainWindow):
|
||||
params = self.tab_connection.get_connection_params()
|
||||
success = self.conn_mgr.connect(**params)
|
||||
if success:
|
||||
self.status_bar.set_connection_status(True, "● 已连接")
|
||||
self.tab_connection._connect_text_lbl.setText(" 断开连接")
|
||||
self.status_bar.set_log("设备连接成功")
|
||||
else:
|
||||
self.status_bar.set_connection_status(False, "● 未连接")
|
||||
self.status_bar.set_log("设备连接失败,请检查参数和硬件连接")
|
||||
|
||||
def _on_set_target(self, target: float):
|
||||
|
||||
Reference in New Issue
Block a user