重构UCD模块

This commit is contained in:
xinzhu.yin
2026-06-11 15:53:41 +08:00
parent 38222ff002
commit cc7218411c
11 changed files with 395 additions and 188 deletions

View File

@@ -9,7 +9,6 @@ import traceback
import matplotlib
import matplotlib.pyplot as plt
from app_version import APP_NAME, APP_VERSION, get_app_title
from drivers.UCD323_Function import UCDController
from drivers.ucd_driver import UCD323Device
from app.ucd_domain import EventBus
from app.services.ucd_service import SignalService
@@ -100,13 +99,10 @@ class PQAutomationApp(
# 初始化设备连接状态
self.ca = None # CA410色度计
self.ucd = UCDController() # 信号发生器(旧接口,过渡期保留)
# 新架构EventBus + 设备抽象 + 服务层。
# UCD323Device 内部委托 self.ucd保证零行为变更
# 新代码统一走 self.signal_service。
# UCDEventBus + 设备抽象 + 服务层;上层统一走 signal_service / ucd_device
self.event_bus = EventBus()
self.ucd_device = UCD323Device(self.event_bus, self.ucd)
self.ucd_device = UCD323Device(self.event_bus)
self.signal_service = SignalService(self.ucd_device, self.event_bus)
# 连接控制器:统一管理 CA/UCD 生命周期。
@@ -467,7 +463,7 @@ class PQAutomationApp(
def _check_start_preconditions(self):
"""检查开始测试前置条件:设备连接 & 未在测试中。"""
if self.ca is None or self.ucd is None:
if self.ca is None or not self.signal_service.is_connected:
messagebox.showerror("错误", "请先连接CA410和信号发生器")
return False
if self.testing:
@@ -808,8 +804,8 @@ class PQAutomationApp(
print("配置已清理,不再保存")
# 断开设备连接
if self.ucd.status:
self.ucd.close()
if self.signal_service.is_connected:
self.connection.disconnect_ucd()
if self.ca is not None:
self.ca.close()