From 6be553822f4376c5475980bfc481af932f1effdb Mon Sep 17 00:00:00 2001 From: Scaxlibur <51772892+Scaxlibur@users.noreply.github.com> Date: Mon, 3 Aug 2026 19:31:52 +0800 Subject: [PATCH 1/9] feat: add frequency response run reports --- .github/workflows/ci.yml | 2 +- README.md | 26 +- doc/README_EN.md | 19 +- ...77\347\224\250\346\214\207\345\215\227.md" | 85 +++ ...23\345\207\272\346\240\274\345\274\217.md" | 27 + pyproject.toml | 2 + src/wavebench/cli.py | 25 +- src/wavebench/cli_parser.py | 9 + src/wavebench/config.py | 9 +- src/wavebench/data/packages.py | 28 +- src/wavebench/report/html.py | 500 +++++++++++++++-- src/wavebench/services/frequency_response.py | 513 ++++++++++++++++++ src/wavebench/services/run_analysis.py | 5 + src/wavebench/services/run_plan.py | 120 ++++ src/wavebench/services/run_safety.py | 6 + src/wavebench/services/run_service.py | 280 +++++++++- src/wavebench/services/run_templates.py | 88 +++ tests/test_cli.py | 108 ++++ tests/test_frequency_response.py | 270 +++++++++ tests/test_packages.py | 18 + tests/test_report.py | 146 ++++- tests/test_run_plan.py | 109 ++++ tests/test_run_service.py | 218 ++++++++ tests/test_run_templates.py | 54 +- 24 files changed, 2590 insertions(+), 77 deletions(-) create mode 100644 src/wavebench/services/frequency_response.py create mode 100644 tests/test_frequency_response.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caa5ea5..4af28da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Install package and test dependencies run: | python -m pip install --upgrade pip - python -m pip install -e ".[dev]" + python -m pip install -e ".[dev,analysis,pdf]" - name: Run Ruff run: python -m ruff check . diff --git a/README.md b/README.md index b3e3a8e..399cd4d 100644 --- a/README.md +++ b/README.md @@ -107,11 +107,11 @@ WaveBench 主包长期预装 RTM2000/RTM2032、DS1104Z/DS1000Z、DG4000/DG4202 - `run check --plan `:只解析并汇总 plan,不连接仪器 - `run verify --plan `:只读查询 plan 涉及仪器的高阻保护状态与 `*IDN?`,用于执行前预检可达性 -- `run template --list` / `run template --output `:列出或生成保守 run plan 模板;可用 `--frequency`、`--vpp`、`--source-channel` 等少量参数定制;不连接仪器,不覆盖已有文件,除非显式 `--force` -- `run plan --plan `:执行显式 source、power、scope、dmm、sleep 步骤;一次 run 内统一打开并复用所需仪器 session,成功或失败后统一关闭,不静默断线重连 -- `run report `:根据 `run.json` / `summary.csv` 生成静态离线 HTML 报告,包含信号分析指标、DMM 读数卡片、实验证据摘要、产物链接、证据时间线和截图 +- `run template --list` / `run template --output `:列出或生成保守 run plan 模板;可用 `--frequency`、`--frequencies`、`--reference-channel`、`--response-channel`、`--fit` 等少量参数定制;不连接仪器,不覆盖已有文件,除非显式 `--force` +- `run plan --plan `:执行显式 source、power、scope、dmm、sleep 和双通道 `sweep.frequency_response` 步骤;一次 run 内统一打开并复用所需仪器 session,成功或失败后统一关闭,不静默断线重连 +- `run report `:根据 `run.json` / `summary.csv` 生成静态离线 HTML 报告;频响 run 额外包含幅频、相频、拟合对比、逐点 CSV 与采集证据链接。加 `--pdf` 可同时导出嵌入截图、SVG 和表格的便携 PDF - `capture inspect `:打印离线采集包摘要 -- 默认示波器高阻保护:`scope.capture` / `scope.fetch` / `sweep discrete` / run-plan `scope.capture` 在采集前查询通道耦合。RTM2032 的 `DCL`/`ACL` 视为高阻,`DC`/`AC` 默认按可能的 50 Ω 拒绝;DS1000Z 输入固定为 1 MΩ,`AC`/`DC`/`GND` 只表示耦合方式,均按该机型语义检查。WaveBench 不会自动修改耦合或输入设置 +- 默认示波器高阻保护:`scope.capture` / `scope.fetch` / `sweep discrete` / run-plan `scope.capture` / `sweep.frequency_response` 在采集前查询通道耦合。频响会同时保护 reference 与 response 两路;RTM2032 的 `DCL`/`ACL` 视为高阻,`DC`/`AC` 默认按可能的 50 Ω 拒绝;DS1000Z 输入固定为 1 MΩ,`AC`/`DC`/`GND` 只表示耦合方式,均按该机型语义检查。WaveBench 不会自动修改耦合或输入设置 - 可选 `[restore] source_state = true`:在 `finally` 路径快照并恢复 basic 信号源通道状态(输出、函数、频率、Vpp、方波占空比)。该选项不恢复 offset、phase、frequency mode、sweep、负载、极性、噪声、同步、burst、调制、marker、pulse hold 或易失任意波内存;run artifact 以 `source_state_scope = "basic"` 明示范围 - run 输出位于 `data/runs/_