修改引用逻辑、新增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 @@
"""设备连接管理UCD323 / CA410
"""设备连接管理UCD323 / CA410
重构目标
---------
@@ -26,6 +26,12 @@ from app.ucd_domain import ConnectionChanged, UcdError
from drivers.caSerail import CASerail
from drivers.ucd_driver import DeviceInfo
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pqAutomationApp import PQAutomationApp
if TYPE_CHECKING:
from app.ucd_domain import EventBus
from drivers.ucd_driver import UCD323Device
@@ -231,38 +237,38 @@ class ConnectionController:
# 挂接一并删除,让 GUI 直接调用 ``self.connection.xxx``。
def get_available_ucd_ports(self):
def get_available_ucd_ports(self: "PQAutomationApp"):
return self.connection.list_ucd_devices()
def get_available_com_ports(self):
def get_available_com_ports(self: "PQAutomationApp"):
return self.connection.list_com_ports()
def refresh_com_ports(self):
def refresh_com_ports(self: "PQAutomationApp"):
self.connection.refresh_ports()
def check_com_connections(self):
def check_com_connections(self: "PQAutomationApp"):
self.connection.check_all_async()
def update_connection_indicator(self, indicator, connected):
def update_connection_indicator(self: "PQAutomationApp", indicator, connected):
indicator.config(bg="green" if connected else "red")
def check_port_connection(self, is_ucd=True):
def check_port_connection(self: "PQAutomationApp", is_ucd=True):
"""[已弃用] 旗参数反模式;保留仅为兼容旧调用点。"""
if is_ucd:
return self.connection.connect_ucd(self.ucd_list_var.get())
return self.connection.connect_ca()
def enable_com_widgets(self):
def enable_com_widgets(self: "PQAutomationApp"):
self.connection._enable_widgets()
def disconnect_com_connections(self):
def disconnect_com_connections(self: "PQAutomationApp"):
self.connection.disconnect_all()
@@ -278,3 +284,17 @@ __all__ = [
"enable_com_widgets",
"disconnect_com_connections",
]
class DeviceConnectionMixin:
"""由 tools/refactor_to_mixins.py 自动生成。
把本模块的自由函数挂到 PQAutomationApp 上,便于 F12 跳转与类型推断。
"""
get_available_ucd_ports = get_available_ucd_ports
get_available_com_ports = get_available_com_ports
refresh_com_ports = refresh_com_ports
check_com_connections = check_com_connections
update_connection_indicator = update_connection_indicator
check_port_connection = check_port_connection
enable_com_widgets = enable_com_widgets
disconnect_com_connections = disconnect_com_connections