重构测试执行部分+去除转发器

This commit is contained in:
xinzhu.yin
2026-04-20 11:13:57 +08:00
parent 9d2cdb9ed4
commit b6c1c2ab93
14 changed files with 1583 additions and 1631 deletions

View File

@@ -8,11 +8,8 @@ import json
import os
import sys
def get_config_path(app):
def get_config_path(self):
"""获取配置文件的完整路径(兼容打包后的程序)"""
self = app
import os
import sys
# 判断是否是打包后的程序
if getattr(sys, "frozen", False):
@@ -33,9 +30,8 @@ def get_config_path(app):
return config_file
def load_pq_config(app):
def load_pq_config(self):
"""加载PQ配置兼容打包后的程序"""
self = app
try:
# ✅ 使用 self.config_file已经是动态路径
if os.path.exists(self.config_file):
@@ -52,9 +48,8 @@ def load_pq_config(app):
self.log_gui.log(f"⚠️ 加载配置文件失败: {str(e)},使用默认配置")
def save_pq_config(app):
def save_pq_config(self):
"""保存PQ配置兼容打包后的程序"""
self = app
try:
# 确保目录存在
os.makedirs(os.path.dirname(self.config_file), exist_ok=True)
@@ -66,9 +61,8 @@ def save_pq_config(app):
self.log_gui.log(f"保存配置文件失败: {str(e)}")
def clear_config_file(app):
def clear_config_file(self):
"""清理配置文件(兼容打包后的程序)"""
self = app
from tkinter import messagebox
config_file = self.get_config_path()

View File

@@ -10,15 +10,13 @@ from tkinter import messagebox
from utils.caSerail import CASerail
def get_available_ucd_ports(app):
def get_available_ucd_ports(self):
"""获取可用的UCD端口列表"""
self = app
return self.ucd.search_device()
def get_available_com_ports(app):
def get_available_com_ports(self):
"""获取可用的COM端口列表"""
self = app
try:
import serial.tools.list_ports
@@ -29,9 +27,8 @@ def get_available_com_ports(app):
return []
def refresh_com_ports(app):
def refresh_com_ports(self):
"""刷新COM端口列表"""
self = app
available_ports = self.get_available_com_ports()
available_list = self.get_available_ucd_ports()
@@ -60,9 +57,8 @@ def refresh_com_ports(app):
self.update_config()
def check_com_connections(app):
def check_com_connections(self):
"""检测COM端口连接状态"""
self = app
# 禁用连接按钮,防止重复点击
self.check_button.configure(state="disabled")
self.refresh_button.configure(state="disabled")
@@ -105,18 +101,16 @@ def check_com_connections(app):
threading.Thread(target=check_connections, daemon=True).start()
def update_connection_indicator(app, indicator, connected):
def update_connection_indicator(self, indicator, connected):
"""更新连接状态指示器颜色"""
self = app
if connected:
indicator.config(bg="green")
else:
indicator.config(bg="red")
def check_port_connection(app, is_ucd=True):
def check_port_connection(self, is_ucd=True):
"""检测指定端口是否可以连接"""
self = app
try:
if is_ucd:
if self.ucd.status:
@@ -166,16 +160,14 @@ def check_port_connection(app, is_ucd=True):
return False
def enable_com_widgets(app):
def enable_com_widgets(self):
"""重新启用所有控件"""
self = app
self.check_button.configure(state="normal")
self.refresh_button.configure(state="normal")
def disconnect_com_connections(app):
def disconnect_com_connections(self):
"""断开所有串口连接"""
self = app
try:
# 断开TV连接
if self.ucd.status:

View File

@@ -6,9 +6,8 @@ Step 2 重构:从 pqAutomationApp.PQAutomationApp.plot_accuracy 原样搬迁
from matplotlib.patches import Rectangle
def plot_accuracy(app, accuracy_data, test_type):
def plot_accuracy(self, accuracy_data, test_type):
"""绘制色准测试结果 - 29色显示 - 简洁版布局(显示 Gamma"""
self = app
self.accuracy_ax.clear()
self.accuracy_ax.set_xlim(0, 1)

View File

@@ -6,9 +6,8 @@ Step 2 重构:从 pqAutomationApp.PQAutomationApp.plot_cct 原样搬迁。
import numpy as np
def plot_cct(app, test_type):
def plot_cct(self, test_type):
"""绘制 x 和 y 坐标分离图 - 每个点标注纵坐标值"""
self = app
self.cct_fig.clear()

View File

@@ -6,9 +6,8 @@ Step 2 重构:从 pqAutomationApp.PQAutomationApp.plot_contrast 原样搬迁
from matplotlib.patches import Rectangle
def plot_contrast(app, contrast_data, test_type):
def plot_contrast(self, contrast_data, test_type):
"""绘制对比度测试结果 - 固定布局版本"""
self = app
# 清空并重置
self.contrast_ax.clear()

View File

@@ -6,9 +6,8 @@ Step 2 重构:从 pqAutomationApp.PQAutomationApp.plot_eotf 原样搬迁。
import numpy as np
def plot_eotf(app, L_bar, results_with_eotf_list, test_type):
def plot_eotf(self, L_bar, results_with_eotf_list, test_type):
"""绘制 EOTF 曲线 + 数据表格HDR 专用,包含实测亮度)"""
self = app
# ========== 1. 清空并重置左侧曲线 ==========
self.eotf_ax.clear()

View File

@@ -6,9 +6,8 @@ Step 2 重构:从 pqAutomationApp.PQAutomationApp.plot_gamma 原样搬迁。
import numpy as np
def plot_gamma(app, L_bar, results_with_gamma_list, target_gamma, test_type):
def plot_gamma(self, L_bar, results_with_gamma_list, target_gamma, test_type):
"""绘制Gamma曲线 + 数据表格(包含实测亮度)"""
self = app
# ========== 1. 清空并重置左侧曲线 ==========
self.gamma_ax.clear()

View File

@@ -10,11 +10,10 @@ import algorithm.pq_algorithm as pq_algorithm
from app.resources import get_resource_path
def plot_gamut(app, results, coverage, test_type):
def plot_gamut(self, results, coverage, test_type):
"""绘制色域图 - 根据用户选择的参考标准动态计算覆盖率"""
# 实现从原 PQAutomationApp 方法体原样搬迁,为减少修改面
# 范围、保持行为一致,给 self 赋值为传入的 app 实例。
self = app
self.gamut_ax_xy.clear()
self.gamut_ax_uv.clear()

0
app/runner/__init__.py Normal file
View File

1462
app/runner/test_runner.py Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -8,9 +8,8 @@ import threading
import tkinter as tk
from tkinter import filedialog, messagebox
def start_local_dimming_test(app):
def start_local_dimming_test(self):
"""开始 Local Dimming 测试"""
self = app
# 检查设备连接
if not self.ca or not self.ucd.status:
messagebox.showerror("错误", "请先连接 CA410 和 UCD323")
@@ -65,9 +64,8 @@ def start_local_dimming_test(app):
threading.Thread(target=run_test, daemon=True).start()
def update_ld_results(app, results):
def update_ld_results(self, results):
"""更新 Local Dimming 结果显示"""
self = app
for percentage, x, y, lv, X, Y, Z in results:
self.ld_tree.insert(
"",
@@ -76,16 +74,14 @@ def update_ld_results(app, results):
)
def stop_local_dimming_test(app):
def stop_local_dimming_test(self):
"""停止 Local Dimming 测试"""
self = app
if hasattr(self, "ld_test_instance"):
self.ld_test_instance.stop()
def send_ld_window(app, percentage):
def send_ld_window(self, percentage):
"""发送指定百分比的窗口"""
self = app
if not self.ucd.status:
messagebox.showwarning("警告", "请先连接 UCD323 设备")
return
@@ -120,9 +116,8 @@ def send_ld_window(app, percentage):
threading.Thread(target=send, daemon=True).start()
def measure_ld_luminance(app):
def measure_ld_luminance(self):
"""测量当前亮度"""
self = app
if not self.ca:
messagebox.showwarning("警告", "请先连接 CA410 色度计")
return
@@ -178,9 +173,8 @@ def measure_ld_luminance(app):
threading.Thread(target=measure, daemon=True).start()
def clear_ld_records(app):
def clear_ld_records(self):
"""清空测试记录"""
self = app
for item in self.ld_tree.get_children():
self.ld_tree.delete(item)
self.ld_result_label.config(text="亮度: -- cd/m² | x: -- | y: --")
@@ -188,9 +182,8 @@ def clear_ld_records(app):
self.log_gui.log("🗑️ 测试记录已清空")
def save_local_dimming_results(app):
def save_local_dimming_results(self):
"""保存 Local Dimming 结果"""
self = app
from tkinter import filedialog
import csv
import datetime

View File

@@ -10,9 +10,8 @@ import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from views.pq_debug_panel import PQDebugPanel
def init_gamut_chart(app):
def init_gamut_chart(self):
"""初始化色域图表 - 手动设置subplot位置完全避免重叠"""
self = app
container = ttk.Frame(self.gamut_chart_frame)
container.pack(expand=True, fill=tk.BOTH)
@@ -47,9 +46,8 @@ def init_gamut_chart(app):
self.gamut_canvas.draw()
def init_gamma_chart(app):
def init_gamma_chart(self):
"""初始化Gamma曲线图表 - 左侧曲线 + 右侧表格(✅ 4列 + 通用说明)"""
self = app
container = ttk.Frame(self.gamma_chart_frame)
container.pack(expand=True, fill=tk.BOTH)
@@ -157,9 +155,8 @@ def init_gamma_chart(app):
self.gamma_fig.suptitle("Gamma曲线 + 数据表格", fontsize=12, y=0.98)
self.gamma_canvas.draw()
def init_eotf_chart(app):
def init_eotf_chart(self):
"""初始化 EOTF 曲线图表HDR 专用)- 左侧曲线 + 右侧表格(✅ 4列"""
self = app
container = ttk.Frame(self.eotf_chart_frame)
container.pack(expand=True, fill=tk.BOTH)
@@ -263,9 +260,8 @@ def init_eotf_chart(app):
self.eotf_fig.suptitle("EOTF 曲线 + 数据表格", fontsize=12, y=0.98)
self.eotf_canvas.draw()
def init_cct_chart(app):
def init_cct_chart(self):
"""初始化色度坐标图表 - 正向横坐标,标题居中最上方"""
self = app
container = ttk.Frame(self.cct_chart_frame)
container.pack(expand=True)
@@ -309,9 +305,8 @@ def init_cct_chart(app):
self.cct_canvas.draw()
def init_contrast_chart(app):
def init_contrast_chart(self):
"""初始化对比度图表 - 固定大小,居中显示"""
self = app
container = ttk.Frame(self.contrast_chart_frame)
container.pack(expand=True)
@@ -345,9 +340,8 @@ def init_contrast_chart(app):
self.contrast_canvas.draw()
def init_accuracy_chart(app):
def init_accuracy_chart(self):
"""初始化色准图表 - 固定大小,居中显示"""
self = app
container = ttk.Frame(self.accuracy_chart_frame)
container.pack(expand=True)
@@ -381,9 +375,8 @@ def init_accuracy_chart(app):
self.accuracy_canvas.draw()
def clear_chart(app):
def clear_chart(self):
"""清空所有图表"""
self = app
# ========== 1. 清空色域图表 ==========
if hasattr(self, "gamut_ax_xy") and hasattr(self, "gamut_ax_uv"):
@@ -678,7 +671,7 @@ def clear_chart(app):
self.accuracy_canvas.draw()
def update_chart_tabs_state(app):
def update_chart_tabs_state(self):
"""根据测试项目复选框状态动态增删图表 Tab保持规范顺序
- 色域 / Gamma 或 EOTF / 色度一致性 / 对比度 / 色准 全部走动态 add/forget
@@ -686,7 +679,6 @@ def update_chart_tabs_state(app):
- 屏模组测试强制隐藏色准 Tab
- 客户模板 Tab 由 change_test_type 独立管理,这里不动
"""
self = app
if not hasattr(self, "chart_notebook"):
return
@@ -751,9 +743,8 @@ def update_chart_tabs_state(app):
if hasattr(self, "log_gui"):
self.log_gui.log(f"更新Tab状态失败: {str(e)}")
def create_result_chart_frame(app):
def create_result_chart_frame(self):
"""创建结果图表区域 - 6个独立TabGamma 和 EOTF 分离)"""
self = app
# 创建Notebook用于图表切换
self.chart_notebook = ttk.Notebook(self.result_frame)
self.chart_notebook.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
@@ -812,9 +803,8 @@ def create_result_chart_frame(app):
self.log_gui.log("✓ 单步调试面板已创建(放在测试结果图表下方)")
def on_chart_tab_changed(app, event):
def on_chart_tab_changed(self, event):
"""Tab切换时的事件处理"""
self = app
try:
self._last_tab_index = self.chart_notebook.index(
self.chart_notebook.select()