修改引用逻辑、新增Pattern更改界面、新增Calman灰阶界面

This commit is contained in:
xinzhu.yin
2026-05-27 11:26:28 +08:00
parent a903c17cb3
commit dff4e0df4d
24 changed files with 3327 additions and 386 deletions

View File

@@ -1,4 +1,4 @@
"""Local Dimming 测试逻辑(应用层)。
"""Local Dimming 测试逻辑(应用层)。
整合自原 drivers/local_dimming_test.py窗口图片生成与测试主循环
直接落在本模块UCD 通用操作通过 SignalService 完成。
@@ -18,6 +18,12 @@ from tkinter import filedialog, messagebox
import numpy as np
from PIL import Image
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pqAutomationApp import PQAutomationApp
# --------------------------------------------------------------------------
@@ -87,7 +93,7 @@ def _ensure_window_image(width, height, percentage):
# GUI 入口(绑定为 PQAutomationApp 方法)
# --------------------------------------------------------------------------
def start_local_dimming_test(self):
def start_local_dimming_test(self: "PQAutomationApp"):
"""开始 Local Dimming 测试。"""
if not self.ca or not self.signal_service.is_connected:
messagebox.showerror("错误", "请先连接 CA410 和 UCD323")
@@ -163,7 +169,7 @@ def start_local_dimming_test(self):
threading.Thread(target=worker, daemon=True).start()
def update_ld_results(self, results):
def update_ld_results(self: "PQAutomationApp", results):
"""把批量测试结果填入 Treeview。"""
for percentage, x, y, lv, _X, _Y, _Z in results:
self.ld_tree.insert(
@@ -172,14 +178,14 @@ def update_ld_results(self, results):
)
def stop_local_dimming_test(self):
def stop_local_dimming_test(self: "PQAutomationApp"):
"""请求停止当前 Local Dimming 测试。"""
ev = getattr(self, "ld_stop_event", None)
if ev:
ev.set()
def send_ld_window(self, percentage):
def send_ld_window(self: "PQAutomationApp", percentage):
"""发送指定百分比的白色窗口(手动模式)。"""
if not self.signal_service.is_connected:
messagebox.showwarning("警告", "请先连接 UCD323 设备")
@@ -209,7 +215,7 @@ def send_ld_window(self, percentage):
threading.Thread(target=send, daemon=True).start()
def measure_ld_luminance(self):
def measure_ld_luminance(self: "PQAutomationApp"):
"""测量当前显示的亮度并追加一行到 Treeview。"""
if not self.ca:
messagebox.showwarning("警告", "请先连接 CA410 色度计")
@@ -246,7 +252,7 @@ def measure_ld_luminance(self):
threading.Thread(target=measure, daemon=True).start()
def clear_ld_records(self):
def clear_ld_records(self: "PQAutomationApp"):
"""清空 Treeview 中的测试记录。"""
for item in self.ld_tree.get_children():
self.ld_tree.delete(item)
@@ -255,7 +261,7 @@ def clear_ld_records(self):
self.log_gui.log("测试记录已清空", level="info")
def save_local_dimming_results(self):
def save_local_dimming_results(self: "PQAutomationApp"):
"""把 Treeview 中的全部记录导出为 CSV。"""
if len(self.ld_tree.get_children()) == 0:
messagebox.showinfo("提示", "没有可保存的数据")
@@ -284,3 +290,16 @@ def save_local_dimming_results(self):
except Exception as e:
self.log_gui.log(f"保存失败: {str(e)}", level="error")
messagebox.showerror("错误", f"保存失败: {str(e)}")
class LocalDimmingMixin:
"""由 tools/refactor_to_mixins.py 自动生成。
把本模块的自由函数挂到 PQAutomationApp 上,便于 F12 跳转与类型推断。
"""
start_local_dimming_test = start_local_dimming_test
update_ld_results = update_ld_results
stop_local_dimming_test = stop_local_dimming_test
send_ld_window = send_ld_window
measure_ld_luminance = measure_ld_luminance
clear_ld_records = clear_ld_records
save_local_dimming_results = save_local_dimming_results