根据新版本调整set_pattern:0~65535
This commit is contained in:
@@ -22,6 +22,12 @@ from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
||||
from matplotlib.figure import Figure
|
||||
|
||||
from app.tests.color_accuracy import calculate_delta_e_2000
|
||||
from app.solid_color_scale import (
|
||||
SOLID_COLOR_MAX,
|
||||
pct_to_solid_color,
|
||||
solid_color_to_byte,
|
||||
solid_color_to_pct,
|
||||
)
|
||||
from app.views.modern_styles import get_theme_palette
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -41,10 +47,15 @@ DE_FORMULAS = ["2000", "94", "76"]
|
||||
|
||||
|
||||
def _pct_to_gray_rgb(pct: int) -> tuple[int, int, int]:
|
||||
value = int(round(pct * 255 / 100))
|
||||
value = solid_color_to_byte(pct_to_solid_color(pct))
|
||||
return value, value, value
|
||||
|
||||
|
||||
def _pct_to_pattern_rgb(pct: int) -> int:
|
||||
"""灰阶百分比 → SolidColor 码值(0–65535)。"""
|
||||
return pct_to_solid_color(pct)
|
||||
|
||||
|
||||
def _rgb_to_hex(rgb: tuple[int, int, int]) -> str:
|
||||
r, g, b = rgb
|
||||
return f"#{r:02x}{g:02x}{b:02x}"
|
||||
@@ -325,6 +336,8 @@ def create_calman_panel(self: "PQAutomationApp") -> None:
|
||||
self.calman_stop_event = threading.Event()
|
||||
self.calman_running = False
|
||||
self.calman_patch_send_busy = False
|
||||
self.calman_rgb_session = None
|
||||
self.calman_rgb_session_test_type = None
|
||||
self.calman_current_level = None
|
||||
self.calman_last_record = None
|
||||
self.calman_last_step_seconds = None
|
||||
@@ -728,6 +741,29 @@ def toggle_calman_panel(self: "PQAutomationApp") -> None:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _get_calman_rgb_session(self: "PQAutomationApp", test_type: str):
|
||||
"""复用 Calman 发图 session,避免每次点击都重新 stage profile。"""
|
||||
cached = getattr(self, "calman_rgb_session", None)
|
||||
if cached is not None and getattr(self, "calman_rgb_session_test_type", None) == test_type:
|
||||
return cached
|
||||
if not hasattr(self, "pattern_service") or self.pattern_service is None:
|
||||
return None
|
||||
session = self.pattern_service.prepare_session(
|
||||
"rgb",
|
||||
test_type=test_type,
|
||||
log_details=False,
|
||||
)
|
||||
self.calman_rgb_session = session
|
||||
self.calman_rgb_session_test_type = test_type
|
||||
_calman_log(self, f"calman rgb session prepared test_type={test_type}")
|
||||
return session
|
||||
|
||||
|
||||
def _clear_calman_rgb_session(self: "PQAutomationApp") -> None:
|
||||
self.calman_rgb_session = None
|
||||
self.calman_rgb_session_test_type = None
|
||||
|
||||
|
||||
def send_patch(self: "PQAutomationApp", pct: int) -> None:
|
||||
"""点击色块时,发送对应灰阶图案到信号发生器。"""
|
||||
if not self.signal_service.is_connected:
|
||||
@@ -738,7 +774,7 @@ def send_patch(self: "PQAutomationApp", pct: int) -> None:
|
||||
self.calman_status_var.set("发送进行中,请稍候...")
|
||||
return
|
||||
|
||||
rgb_val = int(round(pct * 255 / 100))
|
||||
rgb_val = _pct_to_pattern_rgb(pct)
|
||||
self.calman_current_level = pct
|
||||
self.calman_status_var.set(f"发送 {pct}%(RGB={rgb_val})...")
|
||||
_highlight_patch(self, pct)
|
||||
@@ -751,8 +787,10 @@ def send_patch(self: "PQAutomationApp", pct: int) -> None:
|
||||
_calman_log(self, f"send_solid_rgb start pct={pct}")
|
||||
test_type = getattr(self.config, "current_test_type", "screen_module")
|
||||
if hasattr(self, "pattern_service") and self.pattern_service is not None:
|
||||
rgb_session = _get_calman_rgb_session(self, test_type)
|
||||
self.pattern_service.send_rgb(
|
||||
(rgb_val, rgb_val, rgb_val),
|
||||
session=rgb_session,
|
||||
test_type=test_type,
|
||||
)
|
||||
else:
|
||||
@@ -902,11 +940,7 @@ def start_sequence_test(self: "PQAutomationApp") -> None:
|
||||
test_type = getattr(self.config, "current_test_type", "screen_module")
|
||||
rgb_session = None
|
||||
if hasattr(self, "pattern_service") and self.pattern_service is not None:
|
||||
rgb_session = self.pattern_service.prepare_session(
|
||||
"rgb",
|
||||
test_type=test_type,
|
||||
log_details=False,
|
||||
)
|
||||
rgb_session = _get_calman_rgb_session(self, test_type)
|
||||
_calman_log(self, f"sequence ucd profile applied test_type={test_type}")
|
||||
|
||||
order = sorted(self.calman_levels, reverse=True)
|
||||
@@ -918,7 +952,7 @@ def start_sequence_test(self: "PQAutomationApp") -> None:
|
||||
self._dispatch_ui(self.log_gui.log, "已停止连续测试", "warning")
|
||||
break
|
||||
step_t0 = time.perf_counter()
|
||||
rgb_val = int(round(pct * 255 / 100))
|
||||
rgb_val = _pct_to_pattern_rgb(pct)
|
||||
self._dispatch_ui(
|
||||
self.calman_status_var.set, f"[{i}/{total}] 发送 {pct}%"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user