feat: add complete yiyezhqiu productivity suite

This commit is contained in:
阿白叔 committed 2026-10-10 17:10:32 +08:00
commit e422ca8b2a
155 files changed
+18959

No files matched your search

@@ -0,0 +1,334 @@
# DxDesigner 7.9.5 Automatic Reference Designator Tool
Date: 2026-09-01
## 1. Purpose
Build the first module of a maintainable DxDesigner 7.9.5 productivity suite: automatic reference designator assignment with preview, validation, safe write-back, and recovery.
The tool replaces the legacy workflow that copies selected reference designators to Excel, generates values manually, and pastes them back. Excel is not part of the new annotation workflow.
## 2. Compatibility Baseline
DxDesigner/Expedition Enterprise 7.9.5 is the only supported schematic integration baseline for this phase.
The installation and import flow must remain compatible with the method demonstrated by the supplied legacy tool:
1. The user opens DxDesigner 7.9.5.
2. The user opens `Settings -> Run at Startup`.
3. The user adds one `MenuAdd.vbs` file to the Scripts list.
4. After DxDesigner restarts, one `Dx Productivity` menu appears on the Sheet Menu Bar.
The integration must not require a newer Xpedition add-in framework, a copied DLL from another release, COM re-registration, or a project-format upgrade.
`MenuAdd.vbs` uses only interfaces already demonstrated in the legacy package:
- `Scripting.GetEnvVariable`
- `CommandBars("Sheet Menu Bar").Controls.Add`
- menu control captions and `OnAction`
- the 7.9.5 internal scripting host
The release is a portable directory distributed as one ZIP archive. It does not use an installer, registry entries, environment variables, administrator privileges, or a system Python installation. `MenuAdd.vbs` is placed at the root of the portable directory and resolves every bundled file from its own loaded script location; it contains no `D:\NET_CHECK` or other fixed installation path.
The user extracts the complete directory to a stable location and imports the root `MenuAdd.vbs`. Moving the directory later requires selecting the script again in `Settings -> Run at Startup`; replacing the files in place does not require re-importing the script.
## 3. Compatibility Probe
The first implementation milestone is a read-only 7.9.5 probe imported through the exact startup-script flow above. It must not change a schematic.
The probe verifies:
- the imported script can add and remove its own menu entries without duplication;
- the 7.9.5 script host exposes a reliable loaded-script location that can be used as the portable-directory root;
- a menu item can enter the internal VBS bridge and launch the bundled executable by a path relative to that root;
- `ActiveView.Query(VDM_COMP, VD_SELECTED)` returns selected components;
- `Application.DesignComponents` enumerates the full design;
- component reference designator, sheet number, X/Y position, attributes, full path, and stable identity are readable;
- the bridge can hold component object references while the Python process is open;
- UTF-8 snapshot and result files can be exchanged through the user-local run directory.
The release menu action uses the first 7.9.5-native route proven by the probe. The permitted routes, in order, are:
1. a named bridge procedure in the imported startup VBS;
2. the 7.9.5 `Run` script action;
3. the proven `Form` action with a minimal 7.9.5 EFM launcher.
No unverified route is shipped. If the first two routes are unavailable, the launcher EFM is created or adapted using the 7.9.5 form format; it is not copied from a newer release.
## 4. Architecture
```text
DxDesigner 7.9.5
-> imported MenuAdd.vbs
-> internal VBS bridge
-> UTF-8 snapshot + in-memory component map
-> bundled DxDesignerTools.exe/PySide6 application
-> validated bridge_id/new_refdes result
-> VBS write-back and full-design verification
```
### 4.1 VBS integration layer
The VBS layer owns every DxDesigner COM/API call. It reads the current design, launches Python, waits for the result, revalidates the snapshot, applies changes, verifies the design, and rolls back on failure.
Python does not attach directly to `ViewDraw.Application`. This avoids 32-bit versus 64-bit COM registration and licensing incompatibilities between DxDesigner 7.9.5 and modern Python.
### 4.2 Python domain layer
The Python domain layer is independent of DxDesigner. It parses snapshots, groups components, computes deterministic annotation plans, validates collisions, and produces an immutable change set.
This layer has no GUI imports and can be exhaustively unit tested with fixtures.
### 4.3 Python UI layer
The desktop UI uses PySide6 and a local style sheet. It implements the approved three-column workbench:
- suite navigation on the left;
- annotation rules in the center;
- live old-to-new preview on the right.
The source remains runnable with Python 3.12 for development. The release application is packaged as a Windows x64 PyInstaller `onedir` distribution containing Python 3.12, PySide6, Qt plug-ins, qtawesome, and all application modules. Packaging does not change the VBS bridge protocol.
### 4.4 Portable release layout
The release archive expands to this structure:
```text
DxDesigner productivity tools\
MenuAdd.vbs
RefDesBridge.vbs
DxDesignerTools.exe
_runtime\
docs\
resources\
```
`MenuAdd.vbs`, `RefDesBridge.vbs`, and `DxDesignerTools.exe` remain at the portable root so path resolution and user support stay simple. `_runtime` contains the bundled interpreter and dependencies and is not user-editable. The complete directory may contain Chinese characters and spaces.
Transient run files, backups, history, logs, and per-user preferences remain under `%LOCALAPPDATA%\DxProductivity`. The portable directory therefore remains replaceable and may be read-only at runtime.
## 5. Bridge Protocol
Each run uses a unique directory:
```text
%LOCALAPPDATA%\DxProductivity\runs\<run_id>\
request.json
result.tsv
apply-status.json
```
VBS writes `request.json` as UTF-8 using a deterministic JSON escaping helper. Python writes an ordered `result.tsv` apply schedule with five constrained fields: `sequence`, `bridge_id`, `expected_refdes`, `new_refdes`, and `final_refdes`. Tabs and line breaks are illegal in every result field.
Each sequence number is unique and contiguous from 1. A bridge ID normally appears once. It may appear twice only when a validated reannotation cycle requires a temporary placeholder step followed by the final assignment. VBS verifies `expected_refdes` immediately before every step and verifies `final_refdes` after the complete schedule.
Each snapshot component contains:
- ephemeral `bridge_id` assigned by the current VBS run;
- stable UID when exposed by 7.9.5;
- hierarchical full path as an identity fallback;
- sheet number and current-view membership;
- X and Y schematic coordinates;
- current reference designator;
- symbol-level default reference designator or prefix when available;
- selection state;
- part number and Value for preview;
- lock or protection state when exposed by 7.9.5.
VBS retains an in-memory `bridge_id -> component object` map while Python is open. Result rows never rely on COM enumeration order.
Before write-back, VBS confirms that the active design, component identity, component count in scope, and original reference designators still match the snapshot. A mismatch invalidates the plan and requires a refresh.
## 6. Annotation Behavior
### 6.1 Scope
The UI supports three explicit scopes:
- selected components, which is the default;
- current sheet;
- full design.
If the selected scope is empty, Apply remains disabled. The tool does not silently fall back to another scope.
### 6.2 Processing mode
The default mode fills only unannotated components:
- blank reference designators;
- placeholders matching a leading alphabetic prefix followed by one or more question marks, such as `R?`, `C??`, or `TP?`.
Existing formal reference designators are preserved. A separate, explicit mode reannotates every eligible component in scope.
### 6.3 Prefix resolution
Prefix resolution is deterministic:
1. use the alphabetic prefix in the current placeholder;
2. otherwise use the symbol-level default reference designator/prefix exposed by 7.9.5;
3. otherwise require an explicit prefix in the preview table.
An unresolved prefix is a blocking validation error. Prefix comparison is case-insensitive and output is normalized to uppercase.
### 6.4 Multi-unit components
All symbols that represent the same logical component are grouped by stable component identity. They receive one base reference designator. Symbol units or gates do not consume additional sequence numbers.
If 7.9.5 does not expose a stable UID, the compatibility adapter derives a stable grouping key from the hierarchical component path and validated component metadata. Ambiguous groups are blocked rather than guessed.
### 6.5 Sorting
The default order is:
1. numeric sheet number ascending;
2. schematic Y coordinate from top to bottom;
3. X coordinate from left to right within the same visual row;
4. stable identity as the final deterministic tie-breaker.
Because schematic Y-axis direction is API-dependent, the compatibility adapter normalizes coordinates so larger visual height always sorts first. Components are grouped into visual rows using a default 5 mm tolerance. The user can change the tolerance.
Alternative orders are available for left-to-right column scanning and reverse directions.
### 6.6 Numbering modes
Continuous mode is the default. Each prefix owns an independent sequence beginning at 1 unless the user changes the start value. Numbers already used anywhere outside the target set are skipped.
Page mode uses:
```text
number = numeric_sheet_number * page_step + page_start
```
The defaults are `page_step = 100` and `page_start = 1`, so sheet 3 starts at 301. Each prefix has an independent page sequence. Non-numeric sheet identifiers require an explicit numeric mapping before Apply.
### 6.7 Collision rules
Validation is case-insensitive and covers:
- duplicates inside the proposed change set;
- collisions with components outside the target set;
- illegal or empty prefixes;
- invalid numeric ranges;
- duplicate existing formal reference designators in the source design;
- multiple proposed values for one logical component.
Blocking issues disable Apply. Warnings remain selectable and can locate the affected schematic component.
## 7. Safe Apply and Recovery
Every Apply operation follows this sequence:
1. revalidate the snapshot against the active design;
2. run all collision and format checks again;
3. write a timestamped backup mapping under `%LOCALAPPDATA%\DxProductivity\backups`;
4. apply changes using the in-memory component map;
5. re-enumerate the full design and verify every expected reference designator;
6. write a machine-readable apply status and append an operation-history entry.
Fill-only plans normally write directly because they cannot swap existing formal identifiers.
Full reannotation plans are ordered as a dependency graph. Acyclic moves are applied first. Cycles use the component prefix placeholder, such as `R?`, as a temporary value, then complete the cycle. This uses a placeholder format already accepted by DxDesigner 7.9.5 instead of inventing a new temporary reference-designator syntax.
If any assignment or verification fails, VBS restores every component from the backup mapping and verifies the restoration. A rollback failure is reported prominently with the backup path and the exact remaining mismatch.
The operation-history view exposes Restore Last Annotation. Restore performs the same preflight, backup, apply, and verification sequence; it is not a blind file replay.
## 8. User Interface and Visual Acceptance
The approved mockup is the visual baseline. The release implementation follows these measurable requirements derived from Apple Human Interface Guidelines while remaining a Windows desktop application:
- 13 pt default content text and no essential text below 10 pt;
- approximately 28 by 28 pt default desktop controls and no interactive target below 20 by 20 pt;
- 16 px simplified line icons with consistent weight and optical alignment;
- tooltips and accessible names for icon-only controls;
- one semantic use per status color;
- text contrast of at least 4.5:1 for normal text;
- icons or text in addition to color for every status;
- light, dark, and increased-contrast-compatible palettes;
- complete keyboard navigation with visible focus;
- no clipping or overlap at 100%, 125%, and 150% Windows display scaling;
- a resizable window with a minimum supported content area of 1100 by 700 logical pixels;
- no required command placed only at the bottom edge of the window;
- no automatic, blinking, bouncing, or decorative motion.
Interface icons use a cross-platform icon set with Apple-like semantic consistency. Apple SF Symbols are a design reference only and are not redistributed in the Windows application.
Official design references:
- [Designing for macOS](https://developer.apple.com/design/human-interface-guidelines/designing-for-macos)
- [Layout](https://developer.apple.com/design/human-interface-guidelines/layout)
- [Typography](https://developer.apple.com/design/human-interface-guidelines/typography)
- [Color](https://developer.apple.com/design/human-interface-guidelines/color)
- [Accessibility](https://developer.apple.com/design/human-interface-guidelines/accessibility)
- [Icons](https://developer.apple.com/design/human-interface-guidelines/icons)
## 9. Error Handling
Errors are divided into three levels:
- blocking: Apply is disabled, for example duplicate output or missing prefix;
- warning: the plan remains applicable after review, for example a nonstandard existing designator outside scope;
- informational: no action required, for example a locked component preserved by policy.
The UI shows an icon, short message, affected component count, and location action. Technical details and bridge logs are available in a diagnostics view and retained per run. Normal users do not need to inspect raw JSON, TSV, COM error codes, or Python tracebacks.
If the bundled executable or runtime is missing, corrupt, or cannot start, the VBS bridge shows a concise message with the resolved executable path and exits without changing the design.
## 10. Testing Strategy
### 10.1 Automated domain tests
Tests cover:
- placeholder recognition and prefix normalization;
- continuous and page numbering;
- occupied-number skipping;
- row tolerance and every sort direction;
- numeric and non-numeric sheet identifiers;
- multi-unit grouping;
- duplicate and collision detection;
- deterministic output for equal coordinates;
- reannotation dependency graphs and cycles;
- backup and restore plan generation.
### 10.2 Bridge contract tests
Pure VBS helpers are tested with `cscript` where possible. Tests cover UTF-8, JSON escaping, result parsing, invalid rows, duplicate or noncontiguous sequence numbers, unknown bridge IDs, illegal repeated bridge steps, stale snapshots, and simulated assignment failures.
Python contract tests use captured 7.9.5-compatible fixtures and never require a live DxDesigner instance.
Portable-path tests cover a root containing Chinese characters and spaces, absence of `DXTOOLS_HOME`, relocation followed by script re-import, and a missing or incomplete `_runtime` directory.
### 10.3 UI tests
Qt tests cover default selections, scope changes, preview filtering, blocking-error behavior, keyboard tab order, light/dark themes, and Apply confirmation for full reannotation.
Screenshots are checked at representative 1100 by 700 and 1440 by 900 window sizes under 100%, 125%, and 150% scaling. Text, controls, and tables must not overlap or clip.
### 10.4 Live 7.9.5 acceptance
The user runs the compatibility probe and a sample-project acceptance checklist on the target DxDesigner 7.9.5 installation. Live acceptance covers startup-script import, menu creation, selected/current/full scopes, coordinate order, write-back, duplicate prevention, rollback, restoration, Chinese installation paths, and paths containing spaces.
No release is marked 7.9.5-compatible solely from mocked COM tests.
### 10.5 Offline release acceptance
The packaged directory is tested on a clean Windows 11 x64 environment with network access disabled and no Python installation. Acceptance requires startup from the root `MenuAdd.vbs`, successful Qt plug-in and icon loading, correct access to `%LOCALAPPDATA%`, and no dependency on files outside the portable directory other than Windows system components and DxDesigner 7.9.5.
## 11. Deliverables for Phase One
- 7.9.5 compatibility probe;
- portable Windows x64 ZIP containing the bundled Python runtime and all dependencies;
- copy, startup-script import, upgrade-in-place, and folder-removal instructions;
- `MenuAdd.vbs` and the verified 7.9.5 bridge adapter;
- Python source and dependency metadata;
- automatic reference designator GUI;
- annotation domain tests and bridge contract tests;
- live 7.9.5 acceptance checklist;
- user guide for installation, annotation, preview, Apply, and Restore.
## 12. Non-Goals
This phase does not implement Value/Value1/Part Number editing, attribute visibility, design audits, network navigation, BOM generation, BOM-to-schematic navigation, or Expedition PCB assembly text placement. Those modules reuse the verified bridge and shared application shell in later phase-specific designs.
This phase does not import code or binaries from newer Xpedition releases and does not modify the DxDesigner project format.
@@ -0,0 +1,210 @@
# 一叶知秋_重构版:旧功能迁移与在线更新设计
日期:2026-09-11
状态:待审阅
## 1. 目标与范围
“一叶知秋_重构版”以当前自动位号分配工具为主程序宿主,逐步恢复原始“一叶知秋”中的其他功能,并增加可控的在线更新能力。
本阶段的目标不是一次性重写所有旧工具,而是先让旧功能在 DxDesigner 7.9.5 中可用,再按模块逐步迁移到当前的桥接、预览、校验、备份和回滚框架。
纳入迁移范围的旧功能:
- BOM 导出;
- Value / Value1 修改;
- Part Number 修改;
- PartName / PartLabel 显示属性处理;
- 网络跨页互动、网络列表和网络检查;
- Expedition PCB 装配位号移动,作为独立 PCB 模块。
当前自动位号分配、预览、应用、历史和恢复功能保持现状,不因旧模块迁移而改变既有行为。
不纳入本阶段的内容:
- 不修改 DxDesigner 7.9.5 的工程格式;
- 不引入新版 Xpedition 专用 API 或 DLL;
- 不把旧 EFM 文件直接当作已验证的现代 Python 模块;
- 不做无提示的静默更新或强制覆盖;
- 不要求中心库、`.lmc` 或额外许可证作为普通 DxDesigner 模块的前置条件。
## 2. 产品与版本身份
用户可见产品名统一为“一叶知秋_重构版”。当前 Python 包名、模块名和内部协议标识暂不改名,以避免破坏现有脚本、测试和便携发布结构。
版本口径分为三类:
1. 源码版本:Git 提交或发布分支对应的版本;
2. 发布版本:可下载的便携 ZIP 版本;
3. 更新清单版本:远端 manifest 中声明的 SemVer 版本。
只有通过本地测试、打包测试和对应模块验收的版本才能标记为 stable。未完成 DxDesigner 7.9.5 实机验收的版本必须保持“实机验收待完成”声明。
## 3. 总体架构
```text
DxDesigner 7.9.5
-> 私有启动配置与 MenuAdd.vbs
-> 一叶知秋_重构版菜单
-> 当前自动位号桥接 / 旧功能兼容适配器
-> EFM/VBS 或 Python 模块
-> 结果、日志、备份与回滚
```
### 3.1 兼容层
旧 EFM/VBS 资产放在发布目录的独立 legacy 区域。兼容层负责:
- 从工具自身目录解析资源,不使用 `D:\NET_CHECK`;
- 为旧脚本提供受控的资源路径和必要环境映射;
- 将旧菜单动作注册到同一个产品菜单下;
- 记录模块名称、版本、调用方式和失败原因;
- 不让旧模块直接修改当前自动位号模块的运行目录或历史记录。
EFM 兼容接入只证明“旧功能能够被调用”,不等同于现代化重构完成。每个模块都必须在目标 DxDesigner 7.9.5 上用副本工程验收。
### 3.2 现代化模块
需要安全写回的器件属性模块优先复用当前桥接协议:VBS 负责 DxDesigner 对象访问,Python 负责预览、规则、校验和结果生成。模块逐步获得以下能力:
- 快照和对象身份确认;
- 变更预览;
- 冲突和格式校验;
- 变更前备份;
- 写回后验证;
- 失败回滚和历史记录。
网络、BOM 和 PCB 功能不假设与 RefDes 的对象模型完全相同,必须分别定义适配器和验收项。
## 4. 功能迁移顺序
迁移顺序按复用程度、风险和用户价值确定:
1. BOM 导出:先保留原始 EFM 逻辑,解决路径和输出位置;
2. Value / Value1 / Part Number:复用器件遍历和写回框架,逐步加入预览与回滚;
3. PartName / PartLabel:先做兼容调用,再确认属性字段和显示状态的 7.9.5 行为;
4. 网络跨页互动、网络列表和网络检查:单独验证网络枚举、跨页导航和只读检查;
5. PCB 装配位号移动:独立于 DxDesigner 菜单和桥接,按 Expedition PCB 环境单独打包和验收。
每个模块都经历以下状态:`兼容接入`、`重构中`、`已验证`。模块未达到 `已验证` 前,不在稳定版说明中声称完整支持。
## 5. 菜单与配置
菜单顶层使用“一叶知秋_重构版”产品名,当前自动位号作为已验证入口。旧模块使用独立子菜单或清晰的模块分组,避免旧脚本和新脚本同名冲突。
启动配置继续使用当前的私有启动目录和备份策略。迁移模块不得要求用户手工设置全局 `SKY_MT`;如旧 EFM 仍需要该语义,兼容层在动作调用时提供等价的临时资源根,不写入持久化系统环境变量。
## 6. 在线更新协议
### 6.1 远端 manifest
更新地址由设置提供,默认支持 HTTPS;后续也可适配用户提供的企业存储地址或只读共享路径。manifest 至少包含:
```json
{
"product": "yiyezhqiu-refactored",
"version": "1.1.0",
"channel": "stable",
"min_supported_version": "1.0.0",
"package_url": null,
"sha256": null,
"release_notes": "",
"published_at": "2026-09-11"
}
```
客户端必须校验产品标识、版本格式、最低支持版本、下载地址协议、文件摘要和发布时间字段。版本比较使用 SemVer,不按文件名或修改时间判断新旧。
### 6.2 安全策略
SHA-256 是最低完整性校验。生产更新优先增加签名字段和内置公钥,使用签名校验防止“下载包和摘要同时被替换”。签名校验失败时禁止安装,不提供绕过按钮。
不保存账号密码、访问令牌或私有存储凭据。需要认证的存储由系统凭据或用户当前网络会话负责。
### 6.3 更新流程
默认行为是“自动检查、人工安装”:
1. 启动时或用户手动触发检查 manifest;
2. 无网络、无新版本或检查失败时不影响当前工具使用;
3. 发现新版本后显示版本号、发布时间、更新说明和校验状态;
4. 用户第一次确认下载与安装;
5. 下载到 `%LOCALAPPDATA%\\DxProductivity\\updates\\<version>` 临时目录;
6. 校验摘要和签名;
7. 用户第二次确认切换版本;
8. 启动独立更新器,备份当前版本并执行原子切换;
9. 新版本启动成功后保留可恢复的旧版本;
10. 新版本启动失败、文件不完整或切换异常时恢复旧版本并记录原因。
主程序运行期间不覆盖自身 EXE。便携包优先采用旁路新目录切换,兼容只读目录、共享盘和中文路径。
### 6.4 设置项
设置中提供:
- 更新源地址;
- 自动检查开关;
- 更新通道;
- 检查更新按钮;
- 当前版本和上次检查结果;
- 更新日志入口;
- 下载、校验、安装和回滚状态。
默认不自动安装。更新地址改变后必须重新检查 manifest,不能沿用旧下载结果。
## 7. 审批与发布门禁
迁移采用多级审批:
1. 本设计文档审批:确认范围、顺序和更新策略;
2. 实施计划审批:确认具体文件和测试任务;
3. 模块审批:每个旧功能兼容接入后单独验收;
4. 重构审批:兼容模块改为现代桥接前确认行为保持一致;
5. 发布审批:确认版本声明、变更说明、校验文件和回滚包;
6. 在线更新审批:先用本地模拟源,再用真实存储地址做联网验收。
任何模块失败只阻断该模块的 stable 标记,不阻断已验证模块继续使用。
## 8. 错误处理与回滚
错误分为四类:
- 配置错误:更新地址或模块资源不存在;
- 兼容错误:DxDesigner API、EFM 表单或脚本宿主不支持;
- 数据错误:输入冲突、快照过期、校验失败;
- 更新错误:下载、摘要、签名、切换或启动失败。
所有错误必须给出模块名、阶段、可操作建议和诊断日志位置。旧模块不得在资源或执行失败时静默修改工程。更新失败只恢复版本目录,不修改原理图工程。
## 9. 测试与验收
### 9.1 自动化测试
- 旧菜单路径重写和资源枚举;
- 每个兼容模块的动作注册和缺失资源错误;
- manifest 解析、SemVer 比较、协议限制和字段校验;
- SHA-256/签名校验失败;
- 下载中断、临时目录清理和重复安装;
- 旁路切换、启动失败回滚和旧版本保留;
- 中文路径、空格路径、共享盘和离线环境。
### 9.2 DxDesigner 7.9.5 实机验收
使用副本工程逐模块确认:菜单加载、动作调用、组件/网络枚举、结果写回、工程保存、错误提示和重复启动行为。任何只读模拟测试不能替代实机结论。
### 9.3 发布验收
发布包必须包含版本声明、更新 manifest 示例、SHA-256 文件、回滚说明和模块支持矩阵。发布前验证 ZIP 解压后的便携启动、更新器独立启动和旧版本恢复。
## 10. 交付顺序
第一阶段:冻结“一叶知秋_重构版”产品命名和模块支持矩阵,完成旧资产清点。
第二阶段:接入兼容菜单和第一个旧模块,验证相对路径、日志和失败隔离。
第三阶段:依次迁移器件属性、网络和 BOM 模块,每个模块单独验收。
第四阶段:实现更新 manifest、检查 UI、下载校验、旁路切换和回滚。
第五阶段:使用用户提供的真实存储地址做在线更新验收,并发布 stable 版本。