将 pattern 切换后的等待时间设置添加到pq_config

This commit is contained in:
xinzhu.yin
2026-06-16 15:56:49 +08:00
parent 3dd383b982
commit 9c15751dd0
5 changed files with 132 additions and 25 deletions

View File

@@ -36,6 +36,15 @@ def get_config_path(self: "PQAutomationApp"):
return config_file
def _apply_acquisition_timing(self: "PQAutomationApp"):
"""将 PQConfig 中的采集节奏同步到 app 运行时属性。"""
timing = getattr(self.config, "acquisition_timing", {})
self.pattern_settle_time = max(0.2, float(timing.get("pattern_settle_time", 0.4)))
self.pattern_progress_log_step = max(
1, int(timing.get("pattern_progress_log_step", 5))
)
def load_pq_config(self: "PQAutomationApp"):
"""加载PQ配置兼容打包后的程序"""
try:
@@ -44,12 +53,15 @@ def load_pq_config(self: "PQAutomationApp"):
with open(self.config_file, "r", encoding="utf-8") as f:
config_dict = json.load(f)
self.config.from_dict(config_dict)
_apply_acquisition_timing(self)
if hasattr(self, "log_gui"):
self.log_gui.log("配置文件加载成功", level="success")
else:
_apply_acquisition_timing(self)
if hasattr(self, "log_gui"):
self.log_gui.log("配置文件不存在,使用默认配置", level="error")
except Exception as e:
_apply_acquisition_timing(self)
if hasattr(self, "log_gui"):
self.log_gui.log(f"加载配置文件失败: {str(e)},使用默认配置", level="error")