修复UCD连接错误、修改色准计算方式、修改localdiming选择方块

This commit is contained in:
xinzhu.yin
2026-06-24 15:54:58 +08:00
parent 2d8d4119e3
commit a500751d85
6 changed files with 338 additions and 143 deletions

View File

@@ -102,16 +102,16 @@ class ConnectionController:
def _prepare_ucd_reconnect(self) -> None:
"""Release stale SDK/native handles before a new open attempt."""
if self._device.state.name != "CLOSED":
try:
self._device.close()
return
except Exception as exc: # noqa: BLE001
self._log(f"关闭旧 UCD 会话失败,将强制重置: {exc}", level="info")
if self._device.state.name == "CLOSED":
return
try:
self._device.force_reset()
self._device.close()
except Exception as exc: # noqa: BLE001
self._log(f"强制重置 UCD SDK 失败: {exc}", level="error")
self._log(f"关闭旧 UCD 会话失败,将强制重置: {exc}", level="info")
try:
self._device.force_reset()
except Exception as exc2: # noqa: BLE001
self._log(f"强制重置 UCD SDK 失败: {exc2}", level="error")
def connect_ucd(self, display: str, *, rescan: bool = True) -> bool:
"""打开指定 UCD 设备。成功返回 True。"""
@@ -141,11 +141,11 @@ class ConnectionController:
level="error",
)
if attempt == 0:
if attempt == 0 and self._device.state.name != "CLOSED":
try:
self._device.force_reset()
self._device.close()
except Exception as exc: # noqa: BLE001
self._log(f"重连前强制重置 UCD 失败: {exc}", level="error")
self._log(f"重连前关闭 UCD 失败: {exc}", level="info")
if rescan:
_, display = self._refresh_ucd_selection(display)
if not display:
@@ -341,7 +341,7 @@ class ConnectionController:
app = self._app
com_ports = self.list_com_ports()
ucd_list = self.list_ucd_devices()
if not ucd_list or all("(in use)" in d.lower() for d in ucd_list):
if ucd_list and all("(in use)" in d.lower() for d in ucd_list):
try:
self._device.force_reset()
except Exception as exc: # noqa: BLE001