优化ucd调用结构
This commit is contained in:
@@ -9,9 +9,14 @@ import traceback
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
from app_version import APP_NAME, APP_VERSION, get_app_title
|
||||
from drivers.ucd_driver import UCD323Device
|
||||
from app.ucd_domain import EventBus
|
||||
from app.services.ucd_service import SignalService
|
||||
from app.ucd import (
|
||||
ConnectionChanged,
|
||||
DeviceKind,
|
||||
EventBus,
|
||||
PatternService,
|
||||
SignalService,
|
||||
UCD323Device,
|
||||
)
|
||||
from app.pq.pq_config import PQConfig
|
||||
from app.pq.pq_result import PQResultStore
|
||||
from app.export import (
|
||||
@@ -55,7 +60,6 @@ from app.plots.plot_gamut import PlotGamutMixin
|
||||
from app.views.chart_frame import ChartFrameMixin
|
||||
from app.config_io import ConfigIOMixin
|
||||
from app.tests.local_dimming import LocalDimmingMixin
|
||||
from app.services import PatternService
|
||||
from app.device.connection import DeviceConnectionMixin
|
||||
from app.runner.test_runner import TestRunnerMixin
|
||||
|
||||
@@ -201,6 +205,7 @@ class PQAutomationApp(
|
||||
self.create_calman_panel()
|
||||
# 创建测试类型选择区域
|
||||
self.create_test_type_frame()
|
||||
self._setup_connection_event_handlers()
|
||||
# 创建操作按钮区域
|
||||
self.create_operation_frame()
|
||||
# 创建结果图表区域
|
||||
@@ -229,6 +234,23 @@ class PQAutomationApp(
|
||||
anchor=tk.E,
|
||||
).pack(side=tk.RIGHT)
|
||||
|
||||
def _setup_connection_event_handlers(self) -> None:
|
||||
"""订阅连接事件,驱动 UCD / CA 指示灯(替代轮询 controller.status)。"""
|
||||
|
||||
def on_connection_changed(evt: ConnectionChanged) -> None:
|
||||
if evt.device is DeviceKind.UCD:
|
||||
indicator = getattr(self, "ucd_status_indicator", None)
|
||||
elif evt.device is DeviceKind.CA:
|
||||
indicator = getattr(self, "ca_status_indicator", None)
|
||||
else:
|
||||
return
|
||||
if indicator is None:
|
||||
return
|
||||
state = "green" if evt.connected else "gray"
|
||||
self._dispatch_ui(self.update_connection_indicator, indicator, state)
|
||||
|
||||
self.event_bus.subscribe(ConnectionChanged, on_connection_changed)
|
||||
|
||||
def _dispatch_ui(self, fn, *args, **kwargs):
|
||||
"""把 ``fn(*args, **kwargs)`` 调度到 Tk 主线程执行。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user