feat: integrate V1.1.0 project task planning into existing desktop UI
This commit is contained in:
1 parent
157b99851a
commit
de2d48fbe0
14 files changed
+1530
-48
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
面向 Windows 和 DxDesigner/Expedition Enterprise 7.9.5 的器件批量替换工具。工具通过 DxDesigner 原生 `Replace Part` 完成替换,并在写入前后保存快照、检查受保护字段、记录操作证据,支持桌面连续队列和可恢复的批处理流程。
|
||||
|
||||
**V1.1.0**:目录读取后一个工程对应一个任务,可采集位号并直接选择部分器件替换,逐行设置新料号、Value 和 NC;Excel 为可选编辑方式,同批任务顺序执行。见 [V1.1.0 使用说明](docs/user/v1.1.0-project-tasks.md) 和 [快速测试入口](docs/testing/v1.1.0-test-entrypoints.md)。
|
||||
|
||||
> **当前发布级别:evaluation-only(仅评估)。** 在目标现场完成 7.9.5 验收并取得可追溯证据之前,只能对完整、可丢弃的工程副本和对应中央库进行操作。不要用于唯一工程副本、生产库或未经认证的料号映射。
|
||||
|
||||
## 能做什么
|
||||
@@ -26,9 +28,9 @@
|
||||
|
||||
1. 解压与目标 DxDesigner 版本匹配的发布包,保留 `DxPartReplace.exe`、`_internal` 和 `data` 目录结构。
|
||||
2. 双击 `DxPartReplace.exe`。
|
||||
3. 新建任务,选择包含 `.prj` 文件的工程目录并扫描;选择要处理的工程。
|
||||
3. 新建任务,读取包含 `.prj` 文件的根目录;勾选工程后批量创建任务,一个工程一个任务。
|
||||
4. 添加“旧 Part Number → 新 Part Number”映射,按需要设置 Value 和 `/NC` 选项。
|
||||
5. 先确认工程已经保存并关闭,再点击 **连续执行队列**。
|
||||
5. 需要只替换部分位号时,在“位号计划”采集、勾选并保存;先确认工程已经保存并关闭,再点击 **连续执行队列** 或 **顺序执行本批任务**。
|
||||
6. 执行过程中不要在 DxDesigner 中切页、编辑或关闭当前工程。遇到“结果无法确认”、保护锁或恢复提示时,先保留现场文件并按恢复文档处理,不要重复点击。
|
||||
|
||||
发布版默认把可变数据放在 EXE 同目录的 `data` 下:
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# V1.1.0 DxDesigner 7.9.5 原生替换接口调研
|
||||
|
||||
调研日期:2026-10-14。范围为现有工作区源码、已有测试、本机注册的 7.9.5 COM TypeLib 与安装帮助;本次没有附着、启动或修改任何 CAD 工程,也没有做写入式 live probe。
|
||||
|
||||
**安装版 TypeLib 复核更正:** 本机实际注册的 `viewdraw.tlb` 是版本 `1.0`,不含 `ReplacePart`、`OpenReplacePartDialog`、`ReplacePartCompleted` 或 `SelectExactSet`。工作区保存的一份同名 `designer_ifc.py` 是声明版本 `119.0` 的 makepy wrapper,虽然含 `IVdApp.ReplacePart(SourcePart, Scope, DestinationPart, PinMapping, PropertyMapping)`、`SRP_Selection=5` 和 `PropMT_LibraryWins=3`,但**不能用于证明本机 7.9.5 有这些成员**。下文旧桥中的这些名称应按候选/模拟接口理解。本机真实接口结果以 [离线 TypeLib 证据](v1.1.0-native-typelib-evidence.json) 为准。
|
||||
|
||||
## 结论
|
||||
|
||||
现有的 `Viewdraw.Application` COM 接口足以读取工程/图页/器件,按 UID 精确选中指定器件,并在替换前后核对选中集合。V1.1.0 的“一个旧料号只替换部分位号”可沿用这条选择链路。**写入路径仍应调用原生 Replace Symbol / Replace Part 并明确核验 Library Wins**。目前没有证据表明 `Block.ChangeComponentPreserveRefdes` 或 `ExecuteCommand("ccomp ...")` 能完整实现中央库选件、Library Wins、引脚及网络保持、Undo 和 Packager 通过。两者只适合作为可丢弃工程上的隔离探针,不能注册为默认执行后端。
|
||||
|
||||
这里的“原生接口”需要分清层次:现行自动执行使用 COM 读写选中状态,再从 `viewdraw.exe` 菜单资源识别 Replace Symbol 命令并发送 `WM_COMMAND`,随后通过 DxDesigner 原生对话框选择库行及选项。这是**原生 UI 工作流的自动化**,不是已证明存在的“传入旧件、新料号、Library Wins 参数的一次性 COM API”。
|
||||
|
||||
## 现有证据
|
||||
|
||||
| 路线 | 已有证据 | 当前判断 |
|
||||
| --- | --- | --- |
|
||||
| `Viewdraw.Application` | `QuickPartReplace.vbs:184,402,416` 附着/创建对象;`native_helper.py:196-204` 从活动对象取得 `IVdApp`;一叶知秋 `integration/dxdesigner795/CompatibilityProbe.vbs:122-132` 使用 `GetProjectData` 和 `DesignComponents` 枚举全工程。 | 可用作工程上下文、清单和选中控制;实际环境、精确 build 和 32/64 位组合仍需现场验收。 |
|
||||
| 按器件精确选择 | `native_helper.py:214-249` 以 UID 设置 `Selected` 并重新读取选中 UID;本机 TypeLib 有 `IVdComp.Selected/_SetSelected` 和 `IVdApp.SelectComponent`;旧桥 `PartReplaceBridge.vbs:2097-2150` 所用的 `SelectExactSet` 不在安装版 TypeLib。一叶知秋 `core/Mailbox.vbs:365-375` 已用 `SelectByName` 定位单件。 | 位号应在扫描阶段绑定项目、图页、UID、旧料号;执行前重查完整身份和选中集合。仅用 RefDes 文本不能跨图页唯一定位。 |
|
||||
| 原生 Replace Part + Library Wins | `native_helper.py:165-193,437-445` 从 Viewdraw 菜单资源识别 Replace Symbol;`:450-517` 打开原生对话框、选择精确库行、检查目标 Part Number/符号、确认原生选项,再执行;`:519-553` 验证结果及未选中件未变。`QuickPartReplace.vbs:780-815` 调用 helper;`:837-865` 对未保存失败做原生 Undo 和快照验证。 | 是已有的自动写入路线;需在现场 build/中央库上回归,并以证据确认每个控件 ID 对应的选项,不能只依赖 ID。 |
|
||||
| `Application.OpenReplacePartDialog` | 旧桥 `PartReplaceBridge.vbs:2260-2261,2341-2384` 调用该名称并读 `ReplacePartCompleted`;旧 probe `PartReplaceProbe.vbs:951-985` 将其列为候选,`ccomp_research` 明确 `production_enabled=false`。本机 7.9.5 `IVdApp` TypeLib 没有这两个成员。 | 旧桥属于未证实候选/模拟路径;不能注册为本机可调用 COM 接口。 |
|
||||
| `Block.ChangeComponentPreserveRefdes` | 本机 7.9.5 TypeLib 的 `IVdBlock` 确有 DISPID `42`,参数 `OldComp, NewComp`,返回 `VARIANT_BOOL`;保存的 wrapper `designer_ifc.py:5005,9943` 也有相同名称。现有设计 `docs/superpowers/specs/2026-09-01-dxdesigner-795-part-replacement-design.md:50-61` 记录符号原点及 Packager 失败的社区线索。 | 存在方法不等于可用于库料号替换;签名没有 Library Wins 参数,也未说明只作用于选中位号、如何选库及连接语义。 |
|
||||
| `ExecuteCommand("ccomp ...")` | 类型库包装 `designer_ifc.py:1385,2974,3926` 暴露 `ExecuteCommand(CommandString)`;现有脚本只在 `QuickPartReplace.vbs:845,1143` 对 `undo` 使用它。旧设计 `...part-replacement-design.md:50-60` 仅记载 `ccomp :component_name` 候选,旧 probe 将 `Application.CComp` 标为研究项。全工作区未找到执行 `ExecuteCommand("ccomp ...")` 的生产调用或成功报告。 | 命令存在性、准确语法、选择范围及 Library Wins 行为均未证实。不能用 `undo` 可执行推断 `ccomp` 可执行。 |
|
||||
|
||||
已有文档 `docs/user/part-replacement.md:5,129-142` 对生产边界、精确选择与硬不变量作了明确约束。旧设计 `...part-replacement-design.md:37` 曾写“Python 不直接附着 COM”,但当前 `native_helper.py:196-204` 已直接附着。V1.1.0 文档应以当前实现和 live 证据为准,修正这处历史差异;不要把旧设计中的未验证候选当作生产能力。模拟测试 `tests/integration/test_part_replace_probe.py:498-562` 与 `test_part_replace_bridge.py:336-355` 只能证明协议和错误处理,不构成真实 7.9.5 行为证据。
|
||||
|
||||
## 本机安装版 TypeLib 细查
|
||||
|
||||
注册表 `HKLM\SOFTWARE\Classes\TypeLib\{4ADEF4E1-690A-11CE-9261-0020C5E26659}\1.0\0\win32` 指向 `D:\Mentor\7.9.5EE\SDD_HOME\wv\win32\bin\viewdraw.tlb`,SHA-256 为 `09323c8940f1acf3f469d887dcfdf7bcd114164a29b01ebeb9a7f978fa1a0df7`,共 223 个 TypeInfo。离线脚本 `tools/research/probe-native-capabilities.py` 直接调用 `pythoncom.LoadTypeLib(path)` 读这个文件,并与保存的 wrapper 比较;它不调用 `GetActiveObject` 或 `CreateObject`。输出 `docs/research/v1.1.0-native-typelib-evidence.json` 的 `wrapper_matches_installed_version=false`。
|
||||
|
||||
安装版真实可见成员包括 `IVdApp.ExecuteCommand(CommandString)` DISPID 29、`SelectComponent(sSchName, sSheetName, sCompUID)` DISPID 266、`QueryPages` DISPID 46、`DesignComponents` DISPID 59、`GetProjectData` DISPID 228;`IVdComp.Selected` 和 `_SetSelected`;`IVdBlock.DeSelectAll`、`ChangeComponent` DISPID 24、`ChangeComponentPreserveRefdes` DISPID 42。**没有任何名称含 Replace 的 TypeLib 函数**。旧桥引用的 `SelectExactSet`、`OpenReplacePartDialog`、`ReplacePartCompleted` 在安装版各接口中均未出现;目前测试里的同名 mock 不能当作原生接口。
|
||||
|
||||
外部 wrapper 的 `IVdApp.ReplacePart` 确有 DISPID 300、两个 BSTR、三个 32 位整数/枚举、布尔返回,以及 `SRP_Selection=5`、`PinMT_ByPinNumber=2`、`PropMT_LibraryWins=3`。它的声明版本是 `119.0`,与安装版 `1.0` 不同。因此可作为**未来版本接口线索**,但本机 V1.1.0 后端 capability 必须返回 `unavailable`,不能尝试按 DISPID 300 盲调。只有安装的 TypeLib 与运行时真实包含该方法,且 Selection + 精确 UID 选中 + Library Wins 的现场语义全部验证,才能为对应 build 启用直接 API 后端。
|
||||
|
||||
安装版 `automate.chm` 尝试用系统 `hh.exe -decompile` 提取,但没有得到可读文件;工作区的 `designer_auto_ref.pdf` 为较新 Xpedition Designer Automation Reference,页 696-697 解释 PinMapping/PropertyMapping 枚举,却不能代表本机 7.9.5 的接口集。故本结论优先依据安装版二进制 TypeLib,帮助材料只用于理解候选语义。
|
||||
|
||||
## 建议的 live probe
|
||||
|
||||
1. 准备已关闭、可丢弃的完整工程副本,记录 DxDesigner 版本/build、中央库身份、工程树哈希;选择同一旧料号的两个以上器件,其中仅一个目标位号需要替换。另选一个多单元或引脚较多的代表件。
|
||||
2. 先只读探测 `ProjectPath`、`QueryPages`、`DesignComponents`、每个器件的 UID/RefDes/层级/图页/旧料号/Value/引脚/网络;在不同图页和同页重复位号场景验证身份是否唯一。记录 COM 调用返回值与错误号。
|
||||
3. 在副本上单独验证 `IVdComp.Selected` 与 `IVdApp.SelectComponent`:只选目标 UID,重新枚举选中集合。若集合不一致则停止。记录目标与同旧料号未选中器件的完整前快照。`SelectExactSet` 不作为本机 7.9.5 探针调用。
|
||||
4. 建立基准:使用现行原生对话框路线对目标位号执行一次 Replace Part + Library Wins,记录库行、目标符号、控件文本/状态、替换后全图页快照、Undo、保存关闭再打开回读、Packager/ERC/网表结果。
|
||||
5. 对 `ChangeComponentPreserveRefdes` 和 `ccomp` **分别使用新的副本**做最小写入探针。先只读确认签名和命令语法;确认可恢复后仅改一个目标件。记录实际作用范围、库控制字段、RefDes/位置/方向、引脚号与网络、非目标件、Undo、保存回读和 Packager。任一步不确定就关闭副本且不保存,并留证;不能把属性值或 Part Number 单字段变化视为通过。
|
||||
6. 只有候选路线在多类器件、多图页、现场中央库上满足与基准相同的硬不变量,且有可重复证据和精确 build 绑定,才考虑提升为可选后端。选择一组目标位号后,必须证明未选中的同料号位号保持原样。
|
||||
|
||||
现行代码核验目标及未选中件料号(`native_helper.py:519-547`),但后端晋级标准还要使用 `docs/user/part-replacement.md:140` 的完整保护字段,并核对 NC/Value 策略、保存回读和独立 Packager/ERC/网表结果。现场报告应保存命令、参数、返回值/错误、前后快照、差异及文件 SHA-256,而不是只保存“成功”布尔值。
|
||||
|
||||
## V1.1.0 后端边界建议
|
||||
|
||||
将**计划和身份验证**留在任务层;替换后端只负责一组已冻结的目标 UID。在单工程任务内按图页、旧料号、新料号及 Value/NC 策略分组,后端逐组处理。最小契约可表达为:
|
||||
|
||||
```text
|
||||
ReplacementRequest:
|
||||
project_path, project_fingerprint, sheet_identity
|
||||
targets: [{uid, refdes, old_part_number, baseline_fingerprint}]
|
||||
new_part_number, library_identity, policy, command_id
|
||||
|
||||
ReplacementBackend:
|
||||
capability(build, library_identity) -> supported / research_only / unavailable
|
||||
inspect(request) -> current target identities and full-sheet baseline
|
||||
replace(request, evidence_dir) -> result with attempted/committed/uncertain status
|
||||
verify(request, result) -> selected and unselected differences
|
||||
recover(request, result) -> verified undo or close_without_save evidence
|
||||
```
|
||||
|
||||
生产后端先封装当前 native dialog/helper 路线。`ChangeComponentPreserveRefdes` 与 `ccomp` 应放入独立研究适配器,并强制 `research_only`、可丢弃副本和显式试验入口。后端不能自行扩大目标集合;命令中无 UID、旧料号或工程指纹匹配失败时,必须在写入前失败。结果须区分“未开始”“已变更但未确认”“已验证”和“已恢复”,使批次调度器遇到不确定状态时停下。
|
||||
|
||||
## 外部资料与证据等级
|
||||
|
||||
现有设计在 `...part-replacement-design.md:69` 引用了 Siemens 社区关于 `ChangeComponentPreserveRefdes` 导致封装失败的讨论。此次网络可访问 Siemens 支持门户首页(HTTP 200),但未取得公开的 7.9.5 API 正文或可复核的 `ccomp`/Library Wins 参数说明;搜索请求超时。因此报告中对这两条路线的判断以本机类型库、工作区源码与设计记录为依据,**没有宣称公开资料证明其替换语义**。下一轮应优先取得站点安装包里的 Automation Reference、命令手册和现场 build 录屏/日志,再做写入试验。
|
||||
@@ -0,0 +1,629 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"mode": "offline_installed_typelib_and_wrapper_comparison",
|
||||
"attached_to_viewdraw": false,
|
||||
"mutation_attempted": false,
|
||||
"wrapper": {
|
||||
"path": "F:\\Sync Tool Skyworth\\Work Maps\\AppTraceRecorder\\reference\\SiemensEDA_Python_Interface\\xpedition_designer\\designer_ifc.py",
|
||||
"sha256": "4f6c341091b3b55ed579df6747b2cf261f49533cdbafaa9db306b06ff751c95a"
|
||||
},
|
||||
"typelib": {
|
||||
"path": "D:\\Mentor\\7.9.5EE\\SDD_HOME\\wv\\win32\\bin\\viewdraw.tlb",
|
||||
"exists": true,
|
||||
"sha256": "09323c8940f1acf3f469d887dcfdf7bcd114164a29b01ebeb9a7f978fa1a0df7",
|
||||
"size": 188040
|
||||
},
|
||||
"saved_wrapper_candidates": {
|
||||
"declared_version": {
|
||||
"major": 119,
|
||||
"minor": 0
|
||||
},
|
||||
"constants": {
|
||||
"SRP_Project": 1,
|
||||
"SRP_Board": 2,
|
||||
"SRP_Schematic": 3,
|
||||
"SRP_Sheet": 4,
|
||||
"SRP_Selection": 5,
|
||||
"PinMT_ByName": 1,
|
||||
"PinMT_ByPinNumber": 2,
|
||||
"PropMT_LibraryOnly": 1,
|
||||
"PropMT_SchematicWins": 2,
|
||||
"PropMT_LibraryWins": 3
|
||||
},
|
||||
"methods": [
|
||||
{
|
||||
"interface": "IVdApp",
|
||||
"name": "ReplacePart",
|
||||
"dispid": 300,
|
||||
"arguments": [
|
||||
"SourcePart",
|
||||
"Scope",
|
||||
"DestinationPart",
|
||||
"PinMapping",
|
||||
"PropertyMapping"
|
||||
],
|
||||
"makepy_return_type": [
|
||||
11,
|
||||
0
|
||||
],
|
||||
"makepy_argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
]
|
||||
],
|
||||
"wrapper_line": 3347,
|
||||
"status": "typelib_candidate"
|
||||
},
|
||||
{
|
||||
"interface": "IVdAppProtectionProxy",
|
||||
"name": "ReplacePart",
|
||||
"dispid": 300,
|
||||
"arguments": [
|
||||
"SourcePart",
|
||||
"Scope",
|
||||
"DestinationPart",
|
||||
"PinMapping",
|
||||
"PropertyMapping"
|
||||
],
|
||||
"makepy_return_type": [
|
||||
11,
|
||||
0
|
||||
],
|
||||
"makepy_argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
]
|
||||
],
|
||||
"wrapper_line": 4277,
|
||||
"status": "typelib_candidate"
|
||||
},
|
||||
{
|
||||
"interface": "IVdApplicationAtTest",
|
||||
"name": "ReplaceConnector",
|
||||
"dispid": 2,
|
||||
"arguments": [
|
||||
"SourceConnector",
|
||||
"Scope",
|
||||
"DestinationConnector",
|
||||
"PinMapping",
|
||||
"PropertyMapping"
|
||||
],
|
||||
"makepy_return_type": [
|
||||
11,
|
||||
0
|
||||
],
|
||||
"makepy_argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
]
|
||||
],
|
||||
"wrapper_line": 4549,
|
||||
"status": "typelib_candidate"
|
||||
},
|
||||
{
|
||||
"interface": "IVdApplicationAtTest",
|
||||
"name": "ReplaceSymbol",
|
||||
"dispid": 3,
|
||||
"arguments": [
|
||||
"SourceSymbol",
|
||||
"Scope",
|
||||
"DestinationSymbol",
|
||||
"PinMapping",
|
||||
"PropertyMapping"
|
||||
],
|
||||
"makepy_return_type": [
|
||||
11,
|
||||
0
|
||||
],
|
||||
"makepy_argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
],
|
||||
[
|
||||
3,
|
||||
1
|
||||
]
|
||||
],
|
||||
"wrapper_line": 4554,
|
||||
"status": "typelib_candidate"
|
||||
}
|
||||
]
|
||||
},
|
||||
"installed_typelib": {
|
||||
"guid": "{4ADEF4E1-690A-11CE-9261-0020C5E26659}",
|
||||
"major_version": 1,
|
||||
"minor_version": 0,
|
||||
"type_count": 223,
|
||||
"interfaces": {
|
||||
"IVdApp": [
|
||||
{
|
||||
"name": "ExecuteCommand",
|
||||
"dispid": 29,
|
||||
"parameters": [
|
||||
"CommandString"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "QueryPages",
|
||||
"dispid": 46,
|
||||
"parameters": [
|
||||
"Name"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
[
|
||||
26,
|
||||
[
|
||||
29,
|
||||
50338560
|
||||
]
|
||||
],
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DesignComponents",
|
||||
"dispid": 59,
|
||||
"parameters": [
|
||||
"Library",
|
||||
"Name",
|
||||
"EndSheet",
|
||||
"LevelString",
|
||||
"RecurseDown"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
49
|
||||
],
|
||||
[
|
||||
8,
|
||||
49
|
||||
],
|
||||
[
|
||||
11,
|
||||
49
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
[
|
||||
26,
|
||||
[
|
||||
29,
|
||||
50338560
|
||||
]
|
||||
],
|
||||
32
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "GetProjectData",
|
||||
"dispid": 228,
|
||||
"parameters": [],
|
||||
"argument_types": [],
|
||||
"return_type": [
|
||||
[
|
||||
26,
|
||||
[
|
||||
29,
|
||||
50343040
|
||||
]
|
||||
],
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SelectComponent",
|
||||
"dispid": 266,
|
||||
"parameters": [
|
||||
"sSchName",
|
||||
"sSheetName",
|
||||
"sCompUID"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"IVdView": [
|
||||
{
|
||||
"name": "SelectByName",
|
||||
"dispid": 1,
|
||||
"parameters": [
|
||||
"Name"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SelectObject",
|
||||
"dispid": 12,
|
||||
"parameters": [
|
||||
"ObjectType",
|
||||
"Expression",
|
||||
"SelectOwner",
|
||||
"RegExp",
|
||||
"AddSelect"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
[
|
||||
29,
|
||||
50334848
|
||||
],
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
11,
|
||||
1
|
||||
],
|
||||
[
|
||||
11,
|
||||
1
|
||||
],
|
||||
[
|
||||
11,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
22,
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"IVdBlock": [
|
||||
{
|
||||
"name": "DeSelectAll",
|
||||
"dispid": 14,
|
||||
"parameters": [],
|
||||
"argument_types": [],
|
||||
"return_type": [
|
||||
24,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ChangeComponent",
|
||||
"dispid": 24,
|
||||
"parameters": [
|
||||
"OldComp",
|
||||
"NewComp"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ChangeComponentPreserveRefdes",
|
||||
"dispid": 42,
|
||||
"parameters": [
|
||||
"OldComp",
|
||||
"NewComp"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"IVdComp": [
|
||||
{
|
||||
"name": "Selected",
|
||||
"dispid": 26,
|
||||
"parameters": [],
|
||||
"argument_types": [
|
||||
[
|
||||
11,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
24,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "_SetSelected",
|
||||
"dispid": 12,
|
||||
"parameters": [
|
||||
"Flag"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
22,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
24,
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"ICommandsManager": [
|
||||
{
|
||||
"name": "ExecuteCommand",
|
||||
"dispid": 307,
|
||||
"parameters": [
|
||||
"CommandString"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"IVdAppProtectionProxy": [
|
||||
{
|
||||
"name": "ExecuteCommand",
|
||||
"dispid": 29,
|
||||
"parameters": [
|
||||
"CommandString"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "QueryPages",
|
||||
"dispid": 46,
|
||||
"parameters": [
|
||||
"Name"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
[
|
||||
26,
|
||||
[
|
||||
29,
|
||||
50338560
|
||||
]
|
||||
],
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DesignComponents",
|
||||
"dispid": 59,
|
||||
"parameters": [
|
||||
"Library",
|
||||
"Name",
|
||||
"EndSheet",
|
||||
"LevelString",
|
||||
"RecurseDown"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
49
|
||||
],
|
||||
[
|
||||
8,
|
||||
49
|
||||
],
|
||||
[
|
||||
11,
|
||||
49
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
[
|
||||
26,
|
||||
[
|
||||
29,
|
||||
50338560
|
||||
]
|
||||
],
|
||||
32
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "GetProjectData",
|
||||
"dispid": 228,
|
||||
"parameters": [],
|
||||
"argument_types": [],
|
||||
"return_type": [
|
||||
[
|
||||
26,
|
||||
[
|
||||
29,
|
||||
50343040
|
||||
]
|
||||
],
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SelectComponent",
|
||||
"dispid": 266,
|
||||
"parameters": [
|
||||
"sSchName",
|
||||
"sSheetName",
|
||||
"sCompUID"
|
||||
],
|
||||
"argument_types": [
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
],
|
||||
[
|
||||
8,
|
||||
1
|
||||
]
|
||||
],
|
||||
"return_type": [
|
||||
11,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"wrapper_matches_installed_version": false
|
||||
}
|
||||
@@ -29,13 +29,13 @@ Files: models.py, store.py, service.py, quick_run.py, recovery.py, QuickPartRepl
|
||||
|
||||
Interfaces consumed: TaskStore transaction(), create_task(), sync_projects(); QuickRunPreparer and existing sheet discovery. Produced: directory task creation, task inventory, target plan edit/import/export APIs and versioned target-aware queue preparation. Define exact signatures in the implementation report for UI/task queue integration.
|
||||
|
||||
- [ ] Write failing behavior tests for two .prj files creating two single-project tasks, duplicate scanning not duplicating active tasks, same names differentiated by relative path; run these tests and observe missing APIs.
|
||||
- [ ] Implement transaction-backed group/order/project binding and migrations; maintain legacy constructor defaults. Test transaction rollback and reopen.
|
||||
- [ ] Write failing tests using injected inventory rows for same old part on R1/R2/R3: selecting R1/R3 yields only those UIDs; R2 stays excluded; missing target errors, empty target errors, conflicting imports and equal/chain/cycle rules error.
|
||||
- [ ] Implement component inventory read mode on existing discovery route, collecting effective Value and all stable identifiers without pin/attribute full snapshots; do not save while scanning.
|
||||
- [ ] Implement target rule grouping and target-aware command/snapshot/recovery freeze validation in both Python and VBS. Run isolated VBS contract tests and native_helper mocks; tests must prove selectors survive recovery and stale targets do not become no_match.
|
||||
- [ ] Add openpyxl reader/writer using explicit columns and literal values; parse whole workbook, validate identity and duplicates, then commit atomically. Test roundtrip editing new part, Value and NC plus forged UID and duplicate row rejection.
|
||||
- [ ] Run V1.1 behavior tests and relevant existing inputs/value/recovery tests; commit this task only after covering tests pass and report API signatures and validation limits.
|
||||
- [x] Write failing behavior tests for two .prj files creating two single-project tasks, duplicate scanning not duplicating active tasks, same names differentiated by relative path; run these tests and observe missing APIs.
|
||||
- [x] Implement transaction-backed group/order/project binding and migrations; maintain legacy constructor defaults. Test transaction rollback and reopen.
|
||||
- [x] Write failing tests using injected inventory rows for same old part on R1/R2/R3: selecting R1/R3 yields only those UIDs; R2 stays excluded; missing target errors, empty target errors, conflicting imports and equal/chain/cycle rules error.
|
||||
- [x] Implement component inventory read mode on existing discovery route, collecting effective Value and all stable identifiers without pin/attribute full snapshots; do not save while scanning.
|
||||
- [x] Implement target rule grouping and target-aware command/snapshot/recovery freeze validation in both Python and VBS. Run isolated VBS contract tests and native_helper mocks; tests must prove selectors survive recovery and stale targets do not become no_match.
|
||||
- [x] Add openpyxl reader/writer using explicit columns and literal values; parse whole workbook, validate identity and duplicates, then commit atomically. Test roundtrip editing new part, Value and NC plus forged UID and duplicate row rejection.
|
||||
- [x] Run V1.1 behavior tests and relevant existing inputs/value/recovery tests; commit this task only after covering tests pass and report API signatures and validation limits.
|
||||
|
||||
## Task 2: Cross-task scheduler and existing UI integration
|
||||
|
||||
@@ -43,18 +43,20 @@ Files: task_queue.py; ui/main_window.py, task_list.py, mapping_table.py; tests/v
|
||||
|
||||
Consumed APIs: Task 1 report; existing service.execute_quick_run_queue/quick_run_progress and safe pause. Produced APIs: fixed ordered task queue runner and UI directory wizard/inventory target table/Excel optional entry points.
|
||||
|
||||
- [ ] Write failing scheduler test with fake runner logging starts/ends: A completes before B starts; pause leaves B unstarted; uncertain A prevents B; safe ordinary A failure allows B and summary records both.
|
||||
- [ ] Implement scheduler with per-task evidence paths and fixed IDs/plan fingerprints; reject same-project concurrent tasks, preserve active task evidence on resume.
|
||||
- [ ] Add directory scanner/create dialog to existing New action with project checkboxes and async scan; existing edit/name notes and historical view survive. Show counts and execution order, support ordering and group start/pause.
|
||||
- [ ] Add Collect Targets action and editable target table: per row enabled/new part/custom Value/NC controls; preserve existing rule dialog/full-match path. Excel import/export optional actions use same plan validation; blank typed target lists rejected rather than matching all.
|
||||
- [ ] Verify Qt widgets with offscreen smoke interactions and scheduler failure/lock tests. Commit after tests pass.
|
||||
- [x] Write failing scheduler test with fake runner logging starts/ends: A completes before B starts; pause leaves B unstarted; uncertain A prevents B; safe ordinary A failure allows B and summary records both.
|
||||
- [x] Implement scheduler with per-task evidence paths and fixed IDs/plan fingerprints; reject same-project concurrent tasks, preserve active task evidence on resume.
|
||||
- [x] Add directory scanner/create dialog to existing New action with project checkboxes and async scan; existing edit/name notes and historical view survive. Show counts and execution order, support ordering and group start/pause.
|
||||
- [x] Add Collect Targets action and editable target table: per row enabled/new part/custom Value/NC controls; preserve existing rule dialog/full-match path. Excel import/export optional actions use same plan validation; blank typed target lists rejected rather than matching all.
|
||||
- [x] Verify Qt widgets with offscreen smoke interactions and scheduler failure/lock tests. Commit after tests pass.
|
||||
|
||||
## Task 3: Test entry points, version and deliverable verification
|
||||
|
||||
Files: pyproject.toml, version.py, packaging/Build-DxPartReplace.ps1, docs/user/v1.1.0-project-tasks.md, tests/conftest.py or tests/legacy/conftest.py, tools/test_v1_1.ps1 and tools/test_legacy.ps1.
|
||||
|
||||
- [ ] Default testpaths becomes tests/v1_1. Keep existing directories reachable with explicit paths; scripts set local src PYTHONPATH to prevent unrelated installed dx_productivity package collisions.
|
||||
- [ ] Version pyproject and desktop to 1.1.0. Add openpyxl dependency and ensure packaging discovers it; update build QA commands to run V1.1 and meaningful safety regressions rather than reintroducing full slow suite implicitly.
|
||||
- [ ] Document new task/inventory/Excel/NC workflows, previous data migration and real CAD validation limits; include native research report.
|
||||
- [ ] Run default behavior suite, selected safety/Qt/VBS tests, compileall and build/frozen smoke if toolchain available. Review diff for selector fallback, evidence overwrites, migration loss and UI async locks; fix findings.
|
||||
- [ ] Bring verified commits into the main workspace without rewriting user work; supply V1.1.0 ZIP/EXE if build succeeds and distinguish code test results from live CAD acceptance.
|
||||
- [x] Default testpaths becomes tests/v1_1. Keep existing directories reachable with explicit paths; scripts set local src PYTHONPATH to prevent unrelated installed dx_productivity package collisions.
|
||||
- [x] Version pyproject and desktop to 1.1.0. Add openpyxl dependency and ensure packaging discovers it; update build QA commands to run V1.1 and meaningful safety regressions rather than reintroducing full slow suite implicitly.
|
||||
- [x] Document new task/inventory/Excel/NC workflows, previous data migration and real CAD validation limits; include native research report.
|
||||
- [x] Run default behavior suite, selected safety/Qt/VBS tests, compileall and build/frozen smoke if toolchain available. Review diff for selector fallback, evidence overwrites, migration loss and UI async locks; fix findings.
|
||||
- [x] Bring verified commits into the main workspace without rewriting user work; supply V1.1.0 ZIP/EXE if build succeeds and distinguish code test results from live CAD acceptance.
|
||||
|
||||
Verification and implementation details: v1.1.0-task-1-report.md and v1.1.0-task-2-report.md. Live CAD acceptance remains outside offline verification.
|
||||
@@ -0,0 +1,20 @@
|
||||
# V1.1.0 UI, scheduler and delivery report
|
||||
|
||||
The existing task view now creates one task per selected project from a directory preview. The original mapping editor remains available beside the new target plan tab. The plan supports direct editing of selected targets, new Part Number, custom Value and NC; Excel import is a draft preview requiring Save. Unsaved drafts survive task switching and block group execution. NC is editable and defaults on, as confirmed by the user.
|
||||
|
||||
The task scheduler freezes task order and plan fingerprints, uses isolated per-task evidence, persists checkpoints and holds process/thread execution locks. Safe preflight failures are recorded; uncertainty stops before the next task. A paused UI queue retains the same task IDs including completed entries, allowing durable resume without replaying successful tasks. Target-mode and project-selection state are included in fingerprints.
|
||||
|
||||
Independent review identified raw-rule batch fallback, evidence routing differences, disappearing target pages, saved-unverified resume, mutation guards, purge foreign keys and subset rollback comparisons. These were fixed in the backend commits and checked against their focused tests. No live CAD write was performed.
|
||||
|
||||
## Verification and artifacts
|
||||
|
||||
- Default behavior suite: 36 passed in 5.43 seconds via `tools/Test-V1.1.ps1`.
|
||||
- Selected existing safety suite: 38 passed in 5.12 seconds.
|
||||
- Release build QA: combined 74 passed in 8.42 seconds.
|
||||
- Focused backend VBS/recovery/Value checks: 45 passed in 7.57 seconds; final VBS contract check: 10 passed in 0.14 seconds.
|
||||
- Python compileall and Git whitespace check passed.
|
||||
- Offscreen UI screenshot inspected with a Windows Chinese font loaded for the offscreen renderer. It shows selected R1/R3, retained R2/R4/R5/R6 and editable NC. Default splitter proportions give the plan more space.
|
||||
- PyInstaller 6.22.3 / Python 3.12.10 build succeeded. The frozen application started and shut down cleanly using an isolated temporary data root.
|
||||
- After the final VBS component-count guard, the release runtime script was refreshed from source, its SHA-256 checked, and the frozen smoke repeated successfully. Final bridge SHA-256: `3BDEC7476762C28D6606825183DAC98505541EE2808B2F4C240577A7E304C72D`.
|
||||
|
||||
The historical suite remains explicitly available; it is not part of default development or release checks. Actual central-library replacement, saves/readback and external CAD validation still require a disposable project acceptance run. The included native interface report confirms the installed 7.9.5 typelib lacks a direct ReplacePart method.
|
||||
@@ -0,0 +1,32 @@
|
||||
# DxPartReplace V1.1.0 使用说明
|
||||
|
||||
V1.1.0 沿用原有任务视图和料号规则编辑,增加按工程拆分的任务、按位号选择的替换计划及可选 Excel 操作。
|
||||
|
||||
## 日常流程
|
||||
|
||||
1. 点击“新建”,填写或选择根目录,点击“读取工程”。勾选要处理的 `.prj` 后创建任务,每个工程对应一个任务。已存在未完成任务的工程不会重复创建。
|
||||
2. 在原“料号规则”页填写旧料号、新料号。一个任务可以配置多条规则。
|
||||
3. 打开“位号计划”,点击“采集所有匹配位号”。采集读取工程中的器件 UID、位号、图页、旧料号和原 Value,不保存工程。
|
||||
4. 在表格中勾选需要替换的位号,其余行保持不勾选。可逐行填写不同新料号、自定义 Value 和“同步 NC”,也可选中多行批量填写新料号。采集后的位号默认保留,避免误替换。
|
||||
5. 点击“保存位号计划”。有未保存的编辑时无法执行;切换任务会保留编辑草稿。重新采集会核对工程身份并保留已保存计划;有未保存编辑时会提示丢弃草稿。
|
||||
6. 使用原有自动执行入口处理当前任务,或点击“顺序执行本批任务”按任务顺序处理同批工程。上下移动按钮调整顺序。每次仅处理一个工程,暂停在当前步骤收尾后生效。
|
||||
|
||||
## 可选 Excel 操作
|
||||
|
||||
无需导出也能完成全部编辑。需要在 Excel 中操作时,可导出采集后的 `.xlsx`,修改替换开关、新料号、自定义 Value 开关及文本、同步 NC,再导入。
|
||||
|
||||
导入先显示到表格中预览,点击“保存位号计划”后才生效。工程、图页、UID、位号、旧料号及原 Value 是身份校验字段,应保持原样。无法添加未采集器件、重复器件或跨工程目标;不接受公式。布尔选项可使用 TRUE/FALSE 或 是/否。
|
||||
|
||||
“同步 NC”默认勾选,可以按行关闭;仅按原规则识别独立 `/NC` 标记。Value 复制选项和每行自定义 Value 延续原工具的处理方式。替换计划不允许旧、新料号相同,也不允许同批链式或循环替换。
|
||||
|
||||
## 保存、恢复及旧任务
|
||||
|
||||
执行前保留原工具的备份流程,替换后保存、关闭并重新打开核验。执行证据按任务存放。目标 UID、位号、原 Value 或旧料号变化时会停止校验,绝不会退回替换全部同料号器件。保存结果不确定时停止队列,先使用核验恢复入口处理。
|
||||
|
||||
旧数据库自动升级并保留任务、状态、规则。未采集位号计划的历史任务沿用旧流程;采集后,即使没有勾选位号,也不会触发全量替换。建议首次使用新版本前自行复制原工具的 data 文件夹;不同版本不要同时打开同一数据目录。
|
||||
|
||||
## 验证范围
|
||||
|
||||
快速测试覆盖任务拆分、SQLite 迁移、位号筛选、Excel 往返、串行调度和界面编辑;发布构建另检查执行保护及冻结程序启动。测试不会修改生产 CAD 工程。
|
||||
|
||||
本机 7.9.5 的真实 TypeLib 没有可直接调用的 ReplacePart 方法,生产替换仍沿用原生对话框及 Library Wins。详见 `docs/research/v1.1.0-native-interface-probe.md`。实际中央库、器件替换和保存回读仍需用工程副本现场验收。
|
||||
@@ -102,10 +102,12 @@ def _record(value):
|
||||
def _plan_hash(child, task_id: str) -> str:
|
||||
task = child.get_task(task_id)
|
||||
payload = {
|
||||
'projects': [str(project.path.resolve(strict=False)).casefold() for project in child.projects(task_id)],
|
||||
'projects': [(str(project.path.resolve(strict=False)).casefold(), project.selected, project.available)
|
||||
for project in child.projects(task_id)],
|
||||
'rules': [_record(rule) for rule in child.rules(task_id)],
|
||||
'targets': [_record(row) for row in child.target_plan(task_id)],
|
||||
'copy_value': task.copy_part_number_to_value,
|
||||
'target_plan_mode': getattr(task, 'target_plan_mode', False),
|
||||
}
|
||||
return hashlib.sha256(json.dumps(payload, sort_keys=True, ensure_ascii=False,
|
||||
default=str).encode('utf-8')).hexdigest()
|
||||
@@ -144,7 +146,11 @@ def execute_task_queue(service, task_ids: tuple[str, ...], *, stop_event: Event,
|
||||
try:
|
||||
state = json.loads(path.read_text(encoding='utf-8'))
|
||||
if (state['version'] != 1 or state['task_ids'] != list(ids)
|
||||
or state['plan_hashes'] != hashes or set(state['entries']) != set(ids)):
|
||||
or state['plan_hashes'] != hashes or set(state['entries']) != set(ids)
|
||||
or any(not isinstance(entry, dict) or set(entry) != {'state', 'message'}
|
||||
or entry['state'] not in {'pending', 'running', 'paused', 'blocked', *_TERMINAL}
|
||||
or not isinstance(entry['message'], str)
|
||||
for entry in state['entries'].values())):
|
||||
raise ValueError('queue inputs changed')
|
||||
except (OSError, ValueError, KeyError, TypeError) as error:
|
||||
raise TaskCenterError('task_queue_state', '任务顺序或计划已变化,不能恢复原队列。') from error
|
||||
|
||||
@@ -28,6 +28,7 @@ from PySide6.QtWidgets import (
|
||||
QLineEdit,
|
||||
QComboBox,
|
||||
QMainWindow,
|
||||
QTabWidget,
|
||||
QMessageBox,
|
||||
QPushButton,
|
||||
QSplitter,
|
||||
@@ -45,6 +46,7 @@ from ..service import TaskCenterService
|
||||
from ..version import VERSION
|
||||
from .mapping_table import MappingTable
|
||||
from .project_table import ProjectTable
|
||||
from .project_plan import DirectoryTaskDialog, ProjectPlanPanel
|
||||
from .run_panel import RunPanel
|
||||
from .styles import APP_STYLESHEET
|
||||
from .task_list import TaskList
|
||||
@@ -243,6 +245,8 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self._backup_override_task_id: str | None = None
|
||||
self.destroyed.connect(lambda: setattr(self, "_ui_destroyed", True))
|
||||
self._pool = QThreadPool.globalInstance()
|
||||
self._project_queue_id = None
|
||||
self._project_queue_ids = ()
|
||||
self.setWindowTitle(f"DxDesigner 器件批量替换任务中心 · {VERSION}")
|
||||
self.setMinimumSize(900, 600)
|
||||
self.resize(1080, 760)
|
||||
@@ -254,6 +258,9 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.task_list.edit_button.clicked.connect(self._edit_task)
|
||||
self.task_list.delete_button.clicked.connect(self._delete_task)
|
||||
self.task_list.restore_button.clicked.connect(self._restore_task)
|
||||
self.task_list.queue_button.clicked.connect(self._execute_project_tasks)
|
||||
self.task_list.up_button.clicked.connect(lambda: self._move_project_task(-1))
|
||||
self.task_list.down_button.clicked.connect(lambda: self._move_project_task(1))
|
||||
|
||||
self.directory_path = QLineEdit(objectName="directoryPath")
|
||||
self.directory_path.setPlaceholderText("请选择 DxDesigner 工程所在目录")
|
||||
@@ -306,6 +313,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.skip_button = QPushButton("跳过工程", objectName="skipProjectButton")
|
||||
self.retry_button.clicked.connect(lambda: self._run_project_action(self.service.retry_project, self.retry_button))
|
||||
self.skip_button.clicked.connect(lambda: self._run_project_action(self.service.skip_project, self.skip_button))
|
||||
self.plan_panel = ProjectPlanPanel(self)
|
||||
self._build_layout()
|
||||
self._layout_settings = QSettings(str(self.service.layout_settings_path), QSettings.Format.IniFormat)
|
||||
self._restore_layout()
|
||||
@@ -354,12 +362,16 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
project_layout.addWidget(self.project_table, 1)
|
||||
project_layout.addLayout(project_commands)
|
||||
|
||||
mapping_section = QWidget(objectName="mappingSection")
|
||||
mapping_layout = QVBoxLayout(mapping_section)
|
||||
mapping_section = QTabWidget(objectName="mappingSection")
|
||||
rule_page = QWidget()
|
||||
mapping_layout = QVBoxLayout(rule_page)
|
||||
mapping_layout.setContentsMargins(0, 0, 0, 0)
|
||||
mapping_layout.addWidget(QLabel("替换规则"))
|
||||
mapping_layout.addWidget(self.mapping_table, 1)
|
||||
mapping_layout.addLayout(mapping_commands)
|
||||
mapping_section.addTab(rule_page, "料号规则")
|
||||
mapping_section.addTab(self.plan_panel, "位号计划")
|
||||
self.mapping_tabs = mapping_section
|
||||
|
||||
self.detail_splitter = QSplitter(Qt.Orientation.Vertical, objectName="detailSplitter")
|
||||
self.detail_splitter.setChildrenCollapsible(False)
|
||||
@@ -368,10 +380,10 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.detail_splitter.addWidget(project_section)
|
||||
self.detail_splitter.addWidget(mapping_section)
|
||||
self.detail_splitter.addWidget(self.run_panel)
|
||||
self.detail_splitter.setStretchFactor(0, 3)
|
||||
self.detail_splitter.setStretchFactor(1, 2)
|
||||
self.detail_splitter.setStretchFactor(0, 1)
|
||||
self.detail_splitter.setStretchFactor(1, 3)
|
||||
self.detail_splitter.setStretchFactor(2, 2)
|
||||
self.detail_splitter.setSizes((300, 190, 220))
|
||||
self.detail_splitter.setSizes((170, 340, 220))
|
||||
|
||||
self.workspace_splitter = QSplitter(Qt.Orientation.Horizontal, objectName="workspaceSplitter")
|
||||
self.workspace_splitter.setChildrenCollapsible(False)
|
||||
@@ -411,7 +423,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
def _reset_layout(self) -> None:
|
||||
self.run_panel.toggle_log_button.setChecked(False)
|
||||
self.workspace_splitter.setSizes((250, 830))
|
||||
self.detail_splitter.setSizes((300, 190, 220))
|
||||
self.detail_splitter.setSizes((170, 340, 220))
|
||||
for section, width in enumerate((58, 150, 360, 90, 210)):
|
||||
self.project_table.horizontalHeader().resizeSection(section, width)
|
||||
for section, width in enumerate((220, 220, 180, 80, 70, 65)):
|
||||
@@ -486,6 +498,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
|
||||
def _load_task_data(self) -> None:
|
||||
task = self.service.get_task(self._task_id) if self._task_id else None
|
||||
self.plan_panel.bind_task(self._task_id)
|
||||
self._discovery_root = task.discovery_root if task else None
|
||||
checkbox = self.run_panel.copy_value_check
|
||||
checkbox.blockSignals(True)
|
||||
@@ -543,7 +556,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.run_panel.queue_summary.setText("未选择任务")
|
||||
return
|
||||
projects = self.service.projects(self._task_id)
|
||||
rules = self.service.rules(self._task_id)
|
||||
rules = self._execution_rules(self._task_id)
|
||||
selected = sum(1 for project in projects if project.selected and project.available)
|
||||
enabled = sum(1 for rule in rules if rule.enabled)
|
||||
progress = self.service.quick_run_progress(self._task_id)
|
||||
@@ -587,7 +600,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
message = "请选择任务,并扫描工程目录。"
|
||||
elif not any(project.selected and project.available for project in self.service.projects(self._task_id)):
|
||||
message = "请扫描并勾选至少一个工程。"
|
||||
elif not any(rule.enabled for rule in self.service.rules(self._task_id)):
|
||||
elif not any(rule.enabled for rule in self._execution_rules(self._task_id)):
|
||||
message = "请添加并启用替换规则。"
|
||||
else:
|
||||
message = "配置就绪:确认后处理全部原理图页;未命中和普通失败记录后继续,状态不确定时停止。请先保存修改并关闭已有工程。"
|
||||
@@ -612,7 +625,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
else:
|
||||
try:
|
||||
projects = self.service.projects(self._task_id)
|
||||
rules = self.service.rules(self._task_id)
|
||||
rules = self._execution_rules(self._task_id)
|
||||
enabled = (
|
||||
self._directory_matches_saved_root()
|
||||
and any(project.selected and project.available for project in projects)
|
||||
@@ -624,6 +637,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
task_status = self._current_task_status()
|
||||
active = getattr(self._snapshot, "active_project", None)
|
||||
active_status = getattr(active, "status", None)
|
||||
enabled = enabled and not self.plan_panel.table.dirty
|
||||
self.run_panel.start_button.setEnabled(enabled and task_status in {TaskStatus.DRAFT, TaskStatus.READY})
|
||||
quick_run_busy = any(
|
||||
button in self._button_generations
|
||||
@@ -716,6 +730,28 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.delete_mapping_button.setEnabled(inputs_editable and has_rule)
|
||||
self.move_mapping_up_button.setEnabled(inputs_editable and has_rule)
|
||||
self.move_mapping_down_button.setEnabled(inputs_editable and has_rule)
|
||||
plan_busy = bool(self._workers)
|
||||
self.plan_panel.set_plan_editable(inputs_editable and not plan_busy)
|
||||
self.task_list.new_button.setEnabled(not plan_busy)
|
||||
task = self.service.get_task(self._task_id) if self._task_id else None
|
||||
bound_task = bool(task and task.primary_project_id)
|
||||
group_ids = tuple(item.task_id for item in self.service.tasks()
|
||||
if task and item.group_id == task.group_id)
|
||||
self.task_list.queue_button.setEnabled(bound_task and not plan_busy
|
||||
and not self.plan_panel.has_unsaved_plan(group_ids))
|
||||
self.task_list.up_button.setEnabled(bound_task and not plan_busy)
|
||||
self.task_list.down_button.setEnabled(bound_task and not plan_busy)
|
||||
if bound_task:
|
||||
self.directory_path.setEnabled(False)
|
||||
self.browse_directory_button.setEnabled(False)
|
||||
self.scan_projects_button.setEnabled(False)
|
||||
|
||||
def _execution_rules(self, task_id):
|
||||
task = self.service.get_task(task_id)
|
||||
if task.target_plan_mode:
|
||||
from ..target_plan import compile_target_rules
|
||||
return compile_target_rules(self.service.target_plan(task_id))
|
||||
return self.service.rules(task_id)
|
||||
|
||||
def _selected_project(self) -> Any | None:
|
||||
project_id = self.project_table.current_project_id()
|
||||
@@ -733,24 +769,78 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
return None
|
||||
|
||||
def _new_task(self) -> None:
|
||||
dialog = _TaskDialog(self)
|
||||
while dialog.exec() == QDialog.DialogCode.Accepted:
|
||||
name, note = dialog.values()
|
||||
dialog = DirectoryTaskDialog(self.service, self)
|
||||
if dialog.exec() == QDialog.DialogCode.Accepted:
|
||||
root, selected = dialog.values()
|
||||
self._run_async(lambda: self.service.create_project_tasks(root, selected_paths=selected),
|
||||
self._project_tasks_created, self.task_list.new_button)
|
||||
|
||||
def _project_tasks_created(self, tasks):
|
||||
self.task_list.filter.setCurrentText("进行中")
|
||||
self._refresh_task_list()
|
||||
if tasks:
|
||||
self.open_task(tasks[0].task_id)
|
||||
self._set_operator_message(f"已创建 {len(tasks)} 个任务;每个任务绑定一个工程。先填写料号规则,再采集位号。", "success")
|
||||
else:
|
||||
self._set_operator_message("所选工程已经有未完成任务,无需重复创建。", "warning")
|
||||
|
||||
def _move_project_task(self, offset):
|
||||
if self._task_id:
|
||||
try:
|
||||
task = self.service.create_task(name, note=note)
|
||||
except TaskCenterError as error:
|
||||
if error.code in DIALOG_ERROR_TEXT:
|
||||
dialog.validation.setText(DIALOG_ERROR_TEXT[error.code])
|
||||
continue
|
||||
self.service.move_project_task(self._task_id, offset)
|
||||
self._refresh_task_list()
|
||||
except Exception as error:
|
||||
self._show_error(error)
|
||||
return
|
||||
self._task_id = task.task_id
|
||||
self.task_list.filter.blockSignals(True)
|
||||
self.task_list.filter.setCurrentText("进行中")
|
||||
self.task_list.filter.blockSignals(False)
|
||||
self._refresh_task_list()
|
||||
self.open_task(task.task_id)
|
||||
|
||||
def _execute_project_tasks(self):
|
||||
if not self._task_id or self._workers or self.plan_panel.table.dirty:
|
||||
return
|
||||
task = self.service.get_task(self._task_id)
|
||||
tasks = sorted((item for item in self.service.tasks()
|
||||
if item.group_id == task.group_id and item.primary_project_id
|
||||
and item.status not in {TaskStatus.DELETED, TaskStatus.COMPLETED}),
|
||||
key=lambda item: item.group_position)
|
||||
if not tasks:
|
||||
return
|
||||
ids = tuple(item.task_id for item in tasks)
|
||||
if self._project_queue_id:
|
||||
existing = {item.task_id: item for item in self.service.tasks()}
|
||||
if all(task_id in existing and existing[task_id].group_id == task.group_id
|
||||
and existing[task_id].status is not TaskStatus.DELETED
|
||||
for task_id in self._project_queue_ids):
|
||||
ids = self._project_queue_ids
|
||||
tasks = [existing[task_id] for task_id in ids]
|
||||
if self.plan_panel.has_unsaved_plan(ids):
|
||||
self._set_operator_message('本批任务有未保存的位号编辑,请先逐个保存。', 'warning')
|
||||
return
|
||||
text = "按以下顺序处理,每次只打开一个工程:\n" + "\n".join(
|
||||
f"{index + 1}. {item.name}" for index, item in enumerate(tasks))
|
||||
if QMessageBox.question(self, "确认顺序执行任务", text + "\n请先保存并关闭已有 CAD 工程。") != QMessageBox.StandardButton.Yes:
|
||||
return
|
||||
from ..task_queue import execute_task_queue
|
||||
token = self._project_queue_id if ids == self._project_queue_ids else None
|
||||
self._project_queue_ids = ids
|
||||
self._batch_stop = Event()
|
||||
stop = self._batch_stop
|
||||
self._active_quick_run_task_id = ids[0]
|
||||
self._quick_run_elapsed.start()
|
||||
self._quick_run_timer.start()
|
||||
self.run_panel.busy_indicator.show()
|
||||
self.run_panel.stop_queue_button.show()
|
||||
self._run_async(lambda: execute_task_queue(self.service, ids, stop_event=stop, queue_id=token),
|
||||
self._project_task_queue_finished, self.run_panel.quick_run_button)
|
||||
|
||||
def _project_task_queue_finished(self, result):
|
||||
self._project_queue_id = result.queue_id if result.paused else None
|
||||
self._stop_quick_run_feedback()
|
||||
self._refresh_task_list()
|
||||
self._load_task_data()
|
||||
completed = sum(entry.state == 'completed' for entry in result.entries)
|
||||
failed = sum(entry.state in {'failed', 'blocked'} for entry in result.entries)
|
||||
detail = '\n'.join(f"{self.service.get_task(entry.task_id).name}: {entry.message}"
|
||||
for entry in result.entries if entry.state in {'failed', 'blocked'})
|
||||
self._set_operator_message(f"任务队列{'已暂停' if result.paused else '已结束'}:完成 {completed},失败/阻断 {failed}。\n{detail}",
|
||||
"warning" if result.paused or failed else "success")
|
||||
|
||||
def _edit_task(self) -> None:
|
||||
if not self._task_id:
|
||||
@@ -1051,7 +1141,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
)
|
||||
return
|
||||
selected = sum(1 for project in self.service.projects(task_id) if project.selected and project.available)
|
||||
enabled = sum(1 for rule in self.service.rules(task_id) if rule.enabled)
|
||||
enabled = sum(1 for rule in self._execution_rules(task_id) if rule.enabled)
|
||||
progress = self.service.quick_run_progress(task_id)
|
||||
self._confirmation_progress = progress
|
||||
copy_value = self.service.get_task(task_id).copy_part_number_to_value
|
||||
@@ -1322,7 +1412,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
return dialog.clickedButton() is confirm
|
||||
|
||||
def _confirmed_rule_value_description(self, progress, value_mode: str) -> str:
|
||||
rules = self.service.rules(self._task_id or "")
|
||||
rules = self._execution_rules(self._task_id or "")
|
||||
rule = next(
|
||||
(
|
||||
item for item in rules
|
||||
@@ -1428,6 +1518,12 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
if self._active_quick_run_task_id is None or not self._quick_run_elapsed.isValid():
|
||||
return
|
||||
seconds = self._quick_run_elapsed.elapsed() // 1000
|
||||
queue_feedback = getattr(self.service, '_task_queue_feedback', None)
|
||||
if queue_feedback is not None:
|
||||
_, task_id, position, total = queue_feedback
|
||||
self._active_quick_run_task_id = task_id
|
||||
self.run_panel.execution_status.setText(f"任务 {position}/{total}:{self.service.get_task(task_id).name} | 已运行 {seconds} 秒")
|
||||
return
|
||||
self._refresh_live_task_log()
|
||||
feedback = self.service.batch_feedback()
|
||||
if feedback is not None and feedback[0] == self._active_quick_run_task_id:
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
"""Directory task creation and optional spreadsheet/direct plan editing."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import Qt, QThreadPool
|
||||
from PySide6.QtWidgets import (QDialog, QDialogButtonBox, QFileDialog, QHBoxLayout, QLabel,
|
||||
QLineEdit, QListWidget, QListWidgetItem, QMessageBox, QPushButton,
|
||||
QVBoxLayout, QWidget)
|
||||
|
||||
from ..errors import TaskCenterError
|
||||
from .target_table import TargetTable
|
||||
from .workers import ServiceWorker
|
||||
|
||||
|
||||
class DirectoryTaskDialog(QDialog):
|
||||
def __init__(self, service, parent=None):
|
||||
super().__init__(parent)
|
||||
self.service = service
|
||||
self.setWindowTitle('从目录创建工程任务')
|
||||
self.resize(700, 450)
|
||||
self.directory = QLineEdit(objectName='taskDirectory')
|
||||
self.directory.setPlaceholderText('选择根目录,每个原理图工程创建一个任务')
|
||||
self.browse = QPushButton('选择目录')
|
||||
self.scan = QPushButton('读取工程', objectName='readTaskProjects')
|
||||
self.projects = QListWidget(objectName='taskProjectCandidates')
|
||||
self.summary = QLabel('先读取工程,再勾选需要创建任务的项目。')
|
||||
self.buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
|
||||
self.buttons.button(QDialogButtonBox.StandardButton.Ok).setText('创建任务')
|
||||
self.buttons.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
|
||||
row = QHBoxLayout()
|
||||
row.addWidget(self.directory, 1)
|
||||
row.addWidget(self.browse)
|
||||
row.addWidget(self.scan)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.addLayout(row)
|
||||
layout.addWidget(self.projects, 1)
|
||||
layout.addWidget(self.summary)
|
||||
layout.addWidget(self.buttons)
|
||||
self._worker = None
|
||||
self._scanned_root = None
|
||||
self.browse.clicked.connect(self._browse)
|
||||
self.scan.clicked.connect(self.read_projects)
|
||||
self.directory.textChanged.connect(self._directory_changed)
|
||||
self.projects.itemChanged.connect(self._update_selection)
|
||||
self.buttons.accepted.connect(self.accept)
|
||||
self.buttons.rejected.connect(self.reject)
|
||||
|
||||
def _browse(self):
|
||||
selected = QFileDialog.getExistingDirectory(self, '工程目录')
|
||||
if selected:
|
||||
self.directory.setText(selected)
|
||||
|
||||
def _directory_changed(self):
|
||||
self.projects.clear()
|
||||
self._scanned_root = None
|
||||
self.buttons.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
|
||||
|
||||
def read_projects(self):
|
||||
if self._worker is not None or not self.directory.text().strip():
|
||||
return
|
||||
root = Path(self.directory.text().strip())
|
||||
self.directory.setEnabled(False)
|
||||
self.browse.setEnabled(False)
|
||||
self.scan.setEnabled(False)
|
||||
self.summary.setText('正在读取工程…')
|
||||
self._worker = ServiceWorker(lambda: self.service.scan_project_directory(root))
|
||||
self._worker.signals.succeeded.connect(self._received)
|
||||
self._worker.signals.failed.connect(self._failed)
|
||||
self._worker.signals.finished.connect(self._finished)
|
||||
QThreadPool.globalInstance().start(self._worker)
|
||||
|
||||
def _received(self, projects):
|
||||
self.projects.clear()
|
||||
self._scanned_root = Path(self.directory.text().strip()).resolve()
|
||||
for path in projects:
|
||||
path = Path(path)
|
||||
item = QListWidgetItem(path.relative_to(self._scanned_root).as_posix())
|
||||
item.setData(Qt.ItemDataRole.UserRole, str(path))
|
||||
item.setFlags(item.flags() | Qt.ItemFlag.ItemIsUserCheckable)
|
||||
item.setCheckState(Qt.CheckState.Checked)
|
||||
self.projects.addItem(item)
|
||||
self._update_selection()
|
||||
|
||||
def _failed(self, error):
|
||||
self._scanned_root = None
|
||||
self.summary.setText(getattr(error, 'message', str(error)))
|
||||
|
||||
def _finished(self):
|
||||
self._worker = None
|
||||
self.directory.setEnabled(True)
|
||||
self.browse.setEnabled(True)
|
||||
self.scan.setEnabled(True)
|
||||
self._update_selection()
|
||||
|
||||
def _update_selection(self):
|
||||
selected = sum(self.projects.item(i).checkState() == Qt.CheckState.Checked
|
||||
for i in range(self.projects.count()))
|
||||
if self._scanned_root is not None:
|
||||
self.summary.setText(f'读取到 {self.projects.count()} 个工程,已选 {selected} 个;一个工程一个任务。')
|
||||
self.buttons.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
|
||||
self._worker is None and self._scanned_root is not None and selected > 0)
|
||||
|
||||
def values(self):
|
||||
return self._scanned_root, tuple(Path(self.projects.item(i).data(Qt.ItemDataRole.UserRole))
|
||||
for i in range(self.projects.count()) if self.projects.item(i).checkState() == Qt.CheckState.Checked)
|
||||
|
||||
def reject(self):
|
||||
if self._worker is not None:
|
||||
self.summary.setText('正在读取,请等当前扫描结束后关闭。')
|
||||
return
|
||||
super().reject()
|
||||
|
||||
def closeEvent(self, event):
|
||||
if self._worker is not None:
|
||||
event.ignore()
|
||||
else:
|
||||
super().closeEvent(event)
|
||||
|
||||
|
||||
class ProjectPlanPanel(QWidget):
|
||||
def __init__(self, window):
|
||||
super().__init__()
|
||||
self.window = window
|
||||
self.task_id = None
|
||||
self._drafts = {}
|
||||
self._editable = False
|
||||
self.table = TargetTable(self)
|
||||
self.collect_button = QPushButton('采集所有匹配位号', objectName='collectTargetInventory')
|
||||
self.save_button = QPushButton('保存位号计划', objectName='saveTargetPlan')
|
||||
self.import_button = QPushButton('导入 Excel', objectName='importTargetPlan')
|
||||
self.export_button = QPushButton('导出 Excel', objectName='exportTargetPlan')
|
||||
self.select_all = QPushButton('全部替换')
|
||||
self.select_none = QPushButton('全部保留')
|
||||
self.bulk_part = QLineEdit(objectName='bulkTargetPart')
|
||||
self.bulk_part.setPlaceholderText('对选中行批量填写新料号')
|
||||
self.bulk_apply = QPushButton('填入选中行')
|
||||
self.summary = QLabel('先添加旧、新料号规则,再采集位号;可直接在这里编辑,也可选用 Excel。')
|
||||
self.summary.setWordWrap(True)
|
||||
actions = QHBoxLayout()
|
||||
for button in (self.collect_button, self.save_button, self.import_button, self.export_button):
|
||||
actions.addWidget(button)
|
||||
actions.addStretch()
|
||||
selection = QHBoxLayout()
|
||||
selection.addWidget(self.select_all)
|
||||
selection.addWidget(self.select_none)
|
||||
selection.addWidget(self.bulk_part, 1)
|
||||
selection.addWidget(self.bulk_apply)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addLayout(actions)
|
||||
layout.addWidget(self.summary)
|
||||
layout.addWidget(self.table, 1)
|
||||
layout.addLayout(selection)
|
||||
self.collect_button.clicked.connect(self.collect)
|
||||
self.save_button.clicked.connect(self.save)
|
||||
self.import_button.clicked.connect(self.import_excel)
|
||||
self.export_button.clicked.connect(self.export_excel)
|
||||
self.select_all.clicked.connect(lambda: self.table.select_all_targets(True))
|
||||
self.select_none.clicked.connect(lambda: self.table.select_all_targets(False))
|
||||
self.bulk_apply.clicked.connect(lambda: self.table.apply_to_selected(self.bulk_part.text()))
|
||||
self.table.changed.connect(self._changed)
|
||||
|
||||
def bind_task(self, task_id):
|
||||
if self.task_id == task_id and self.table.dirty:
|
||||
return
|
||||
if self.task_id and self.table.dirty:
|
||||
self._drafts[self.task_id] = self.table.rows()
|
||||
self.task_id = task_id
|
||||
if task_id in self._drafts:
|
||||
self.table.populate(self._drafts[task_id])
|
||||
self.table.dirty = True
|
||||
self._summary()
|
||||
return
|
||||
rows = self.window.service.target_plan(task_id) if task_id else ()
|
||||
self.table.populate(rows)
|
||||
self._summary()
|
||||
|
||||
def has_unsaved_plan(self, task_ids):
|
||||
return any(task_id in self._drafts or
|
||||
(task_id == self.task_id and self.table.dirty) for task_id in task_ids)
|
||||
|
||||
def _summary(self):
|
||||
rows = self.table.rows()
|
||||
if not rows:
|
||||
self.summary.setText('先添加旧、新料号规则,再采集位号;可直接编辑,Excel 导入导出为可选操作。')
|
||||
if rows:
|
||||
selected = sum(row.enabled for row in rows)
|
||||
suffix = ';有未保存编辑,请先保存' if self.table.dirty else ''
|
||||
self.summary.setText(f'共 {len(rows)} 个位号,替换 {selected} 个、保留 {len(rows)-selected} 个{suffix}。同步 NC 可按行勾选。')
|
||||
|
||||
def _changed(self):
|
||||
self._summary()
|
||||
self.window._update_gates()
|
||||
|
||||
def set_plan_editable(self, editable):
|
||||
self._editable = bool(editable)
|
||||
self.table.set_plan_editable(self._editable)
|
||||
for widget in (self.collect_button, self.save_button, self.import_button,
|
||||
self.select_all, self.select_none, self.bulk_part, self.bulk_apply):
|
||||
widget.setEnabled(self._editable and bool(self.task_id))
|
||||
self.export_button.setEnabled(bool(self.task_id) and bool(self.table.rowCount())
|
||||
and not self.table.dirty)
|
||||
|
||||
def _dispatch(self, operation, callback, button):
|
||||
self.window._run_async(operation, callback, button, expected_task_id=self.task_id)
|
||||
self.window._update_gates()
|
||||
|
||||
def collect(self):
|
||||
if not self.task_id:
|
||||
return
|
||||
if self.table.dirty and QMessageBox.question(
|
||||
self, '重新采集位号', '重新采集会丢弃未保存编辑,并核对已有位号。确认继续?',
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
|
||||
QMessageBox.StandardButton.No) != QMessageBox.StandardButton.Yes:
|
||||
return
|
||||
task_id = self.task_id
|
||||
self._dispatch(lambda: self.window.service.collect_target_inventory(task_id),
|
||||
self._saved, self.collect_button)
|
||||
|
||||
def _saved(self, rows):
|
||||
self._drafts.pop(self.task_id, None)
|
||||
self.table.populate(rows)
|
||||
self.window._load_task_data()
|
||||
self._summary()
|
||||
|
||||
def save(self):
|
||||
if not self.task_id:
|
||||
return
|
||||
task_id = self.task_id
|
||||
rows = self.table.rows()
|
||||
self._dispatch(lambda: self.window.service.replace_target_plan(task_id, rows),
|
||||
self._saved, self.save_button)
|
||||
|
||||
def import_excel(self):
|
||||
if not self.task_id:
|
||||
return
|
||||
path, _ = QFileDialog.getOpenFileName(self, '导入位号计划', '', 'Excel (*.xlsx)')
|
||||
if path:
|
||||
task_id = self.task_id
|
||||
self._dispatch(lambda: self.window.service.preview_target_plan(task_id, Path(path)),
|
||||
self._preview_import, self.import_button)
|
||||
|
||||
def _preview_import(self, rows):
|
||||
self.table.populate(rows)
|
||||
self.table.dirty = True
|
||||
self._changed()
|
||||
|
||||
def export_excel(self):
|
||||
if not self.task_id or self.table.dirty:
|
||||
return
|
||||
path, _ = QFileDialog.getSaveFileName(self, '导出位号计划(可选)', '替换计划.xlsx', 'Excel (*.xlsx)')
|
||||
if path:
|
||||
task_id = self.task_id
|
||||
self._dispatch(lambda: self.window.service.export_target_plan(task_id, Path(path)),
|
||||
lambda result: self.summary.setText(f'已导出:{result}'), self.export_button)
|
||||
@@ -0,0 +1,88 @@
|
||||
"""Editable per-component plans with immutable captured identities."""
|
||||
|
||||
from dataclasses import replace
|
||||
|
||||
from PySide6.QtCore import Qt, Signal, QSignalBlocker
|
||||
from PySide6.QtWidgets import QAbstractItemView, QHeaderView, QTableWidget, QTableWidgetItem
|
||||
|
||||
|
||||
class TargetTable(QTableWidget):
|
||||
changed = Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(0, 10, parent)
|
||||
self.setObjectName('targetPlanTable')
|
||||
self.setHorizontalHeaderLabels(('替换', '原理图', '图页', '位号', '旧料号', '原 Value',
|
||||
'新料号', '自定义 Value', '新 Value', '同步 NC'))
|
||||
self.setEditTriggers(QAbstractItemView.EditTrigger.DoubleClicked
|
||||
| QAbstractItemView.EditTrigger.EditKeyPressed
|
||||
| QAbstractItemView.EditTrigger.SelectedClicked)
|
||||
self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
self.setSortingEnabled(False)
|
||||
self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Interactive)
|
||||
for column, width in enumerate((55, 90, 50, 70, 160, 130, 160, 90, 130, 75)):
|
||||
self.setColumnWidth(column, width)
|
||||
self._plan_rows = ()
|
||||
self._editable = True
|
||||
self.dirty = False
|
||||
self.itemChanged.connect(self._changed)
|
||||
|
||||
def _changed(self, _item):
|
||||
self.dirty = True
|
||||
self.changed.emit()
|
||||
|
||||
def populate(self, rows):
|
||||
self._plan_rows = tuple(rows)
|
||||
with QSignalBlocker(self):
|
||||
self.setRowCount(len(self._plan_rows))
|
||||
for index, row in enumerate(self._plan_rows):
|
||||
target = row.target
|
||||
text = ('', target.schematic_name, target.sheet_number, target.refdes,
|
||||
target.old_part_number, target.old_value, row.new_part_number,
|
||||
'', row.custom_value, '')
|
||||
for column, value in enumerate(text):
|
||||
item = QTableWidgetItem(value)
|
||||
item.setToolTip(f'{target.project_path}\n{target.schematic_name}:{target.sheet_number}'
|
||||
f' | {target.refdes} | UID {target.uid}')
|
||||
self.setItem(index, column, item)
|
||||
for column, checked in ((0, row.enabled), (7, row.custom_value_enabled), (9, row.sync_nc)):
|
||||
self.item(index, column).setCheckState(Qt.CheckState.Checked if checked
|
||||
else Qt.CheckState.Unchecked)
|
||||
self._apply_flags()
|
||||
self.dirty = False
|
||||
|
||||
def rows(self):
|
||||
return tuple(replace(row,
|
||||
enabled=self.item(index, 0).checkState() == Qt.CheckState.Checked,
|
||||
new_part_number=self.item(index, 6).text().strip(),
|
||||
custom_value_enabled=self.item(index, 7).checkState() == Qt.CheckState.Checked,
|
||||
custom_value=self.item(index, 8).text().strip(),
|
||||
sync_nc=self.item(index, 9).checkState() == Qt.CheckState.Checked)
|
||||
for index, row in enumerate(self._plan_rows))
|
||||
|
||||
def set_plan_editable(self, editable):
|
||||
self._editable = bool(editable)
|
||||
with QSignalBlocker(self):
|
||||
self._apply_flags()
|
||||
|
||||
def _apply_flags(self):
|
||||
base = Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled
|
||||
for row in range(self.rowCount()):
|
||||
for column in range(self.columnCount()):
|
||||
flags = base
|
||||
if self._editable:
|
||||
if column in (0, 7, 9):
|
||||
flags |= Qt.ItemFlag.ItemIsUserCheckable
|
||||
elif column in (6, 8):
|
||||
flags |= Qt.ItemFlag.ItemIsEditable
|
||||
self.item(row, column).setFlags(flags)
|
||||
|
||||
def select_all_targets(self, enabled=True):
|
||||
if self._editable:
|
||||
for row in range(self.rowCount()):
|
||||
self.item(row, 0).setCheckState(Qt.CheckState.Checked if enabled else Qt.CheckState.Unchecked)
|
||||
|
||||
def apply_to_selected(self, new_part_number: str):
|
||||
if self._editable:
|
||||
for index in {item.row() for item in self.selectedItems()}:
|
||||
self.item(index, 6).setText(new_part_number.strip())
|
||||
@@ -20,11 +20,17 @@ class TaskList(QWidget):
|
||||
self.edit_button = QPushButton("编辑", objectName="editTaskButton")
|
||||
self.delete_button = QPushButton("删除", objectName="deleteTaskButton")
|
||||
self.restore_button = QPushButton("恢复", objectName="restoreTaskButton")
|
||||
self.queue_button = QPushButton("顺序执行本批任务", objectName="executeProjectTasks")
|
||||
self.up_button = QPushButton("上移任务", objectName="moveTaskUp")
|
||||
self.down_button = QPushButton("下移任务", objectName="moveTaskDown")
|
||||
actions = QGridLayout()
|
||||
actions.addWidget(self.new_button, 0, 0)
|
||||
actions.addWidget(self.edit_button, 0, 1)
|
||||
actions.addWidget(self.delete_button, 1, 0)
|
||||
actions.addWidget(self.restore_button, 1, 1)
|
||||
actions.addWidget(self.up_button, 2, 0)
|
||||
actions.addWidget(self.down_button, 2, 1)
|
||||
actions.addWidget(self.queue_button, 3, 0, 1, 2)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.addWidget(self.filter)
|
||||
@@ -41,7 +47,12 @@ class TaskList(QWidget):
|
||||
with QSignalBlocker(self.list):
|
||||
self.list.clear()
|
||||
for task in tasks:
|
||||
item = QListWidgetItem(str(getattr(task, "name")))
|
||||
group_id = getattr(task, "group_id", None)
|
||||
prefix = f"{getattr(task, 'group_position', 0) + 1:02d}. " if group_id else ""
|
||||
status = getattr(getattr(task, 'status', None), 'value', '')
|
||||
labels = {'draft': '待配置', 'ready': '待执行', 'running': '执行中', 'paused': '已暂停',
|
||||
'completed': '已完成', 'failed': '失败', 'deleted': '已删除'}
|
||||
item = QListWidgetItem(prefix + str(getattr(task, "name")) + f"\n{labels.get(status, status)}")
|
||||
item.setData(Qt.ItemDataRole.UserRole, str(getattr(task, "task_id")))
|
||||
self.list.addItem(item)
|
||||
if getattr(task, "task_id") == selected:
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import os
|
||||
os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
|
||||
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QDialogButtonBox
|
||||
|
||||
from dx_productivity.trial_task_center.ui.project_plan import DirectoryTaskDialog
|
||||
|
||||
|
||||
def test_directory_dialog_selects_individual_projects_and_invalidates_old_scan(qtbot, tmp_path):
|
||||
projects = (tmp_path / 'left' / 'same.prj', tmp_path / 'right' / 'same.prj')
|
||||
service = SimpleNamespace(scan_project_directory=lambda root: projects)
|
||||
dialog = DirectoryTaskDialog(service)
|
||||
qtbot.addWidget(dialog)
|
||||
dialog.directory.setText(str(tmp_path))
|
||||
dialog.read_projects()
|
||||
qtbot.waitUntil(lambda: dialog._worker is None, timeout=3000)
|
||||
assert dialog.projects.count() == 2
|
||||
assert dialog.projects.item(0).text() == 'left/same.prj'
|
||||
dialog.projects.item(0).setCheckState(Qt.CheckState.Unchecked)
|
||||
assert dialog.values() == (tmp_path.resolve(), (projects[1],))
|
||||
assert dialog.buttons.button(QDialogButtonBox.StandardButton.Ok).isEnabled()
|
||||
dialog.directory.setText(str(tmp_path / 'other'))
|
||||
assert dialog.projects.count() == 0
|
||||
assert not dialog.buttons.button(QDialogButtonBox.StandardButton.Ok).isEnabled()
|
||||
|
||||
|
||||
def test_original_window_edits_target_plan_and_nc_without_export(qtbot, tmp_path):
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.target_plan import ComponentTarget, TargetPlanRow
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
|
||||
root = tmp_path / 'projects'
|
||||
root.mkdir()
|
||||
path = root / 'board.prj'
|
||||
path.write_text('KEY FrontEndSnapshot "DxD"\nKEY iCDBDir "database"\n', encoding='ascii')
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_project_tasks(root)[0]
|
||||
service.add_rule(task.task_id, 'OLD', 'NEW')
|
||||
inventory = (
|
||||
TargetPlanRow(ComponentTarget(path, 'MAIN', '1', 'u1', 'R1', 'OLD', '100nF/NC'), False, 'NEW'),
|
||||
TargetPlanRow(ComponentTarget(path, 'MAIN', '1', 'u2', 'R2', 'OLD', '100nF'), False, 'NEW'))
|
||||
store.record_target_inventory(task.task_id, tuple(row.target for row in inventory))
|
||||
service.replace_target_plan(task.task_id, inventory)
|
||||
window = TrialTaskCenterWindow(service)
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
assert '1.1.0' in window.windowTitle()
|
||||
table = window.plan_panel.table
|
||||
table.item(0, 0).setCheckState(Qt.CheckState.Checked)
|
||||
table.item(0, 9).setCheckState(Qt.CheckState.Unchecked)
|
||||
assert not window.run_panel.quick_run_button.isEnabled()
|
||||
window.plan_panel.save()
|
||||
qtbot.waitUntil(lambda: not window._workers, timeout=5000)
|
||||
rows = service.target_plan(task.task_id)
|
||||
assert rows[0].enabled and not rows[0].sync_nc and not rows[1].enabled
|
||||
assert not table.dirty
|
||||
assert not window.directory_path.isEnabled()
|
||||
assert window.run_panel.quick_run_button.isEnabled()
|
||||
assert not (tmp_path / 'plan.xlsx').exists()
|
||||
# Switching tasks must not conceal an unsaved draft from group execution.
|
||||
table.item(0, 6).setText('OTHER')
|
||||
window.plan_panel.bind_task(None)
|
||||
assert window.plan_panel.has_unsaved_plan((task.task_id,))
|
||||
window.close()
|
||||
store.close()
|
||||
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
os.environ.setdefault('QT_QPA_PLATFORM', 'offscreen')
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from dx_productivity.trial_task_center.target_plan import ComponentTarget, TargetPlanRow
|
||||
from dx_productivity.trial_task_center.ui.target_table import TargetTable
|
||||
|
||||
|
||||
def test_edit_targets_and_nc_in_original_view_without_excel():
|
||||
app = QApplication.instance() or QApplication([])
|
||||
table = TargetTable()
|
||||
rows = tuple(TargetPlanRow(ComponentTarget(Path('C:/board.prj'), 'MAIN', '1', uid,
|
||||
refdes, 'OLD', value), False, 'NEW')
|
||||
for uid, refdes, value in [('u1', 'R1', 'A/NC'), ('u2', 'R2', 'B')])
|
||||
table.populate(rows)
|
||||
table.item(0, 0).setCheckState(Qt.CheckState.Checked)
|
||||
table.item(0, 6).setText('NEW-2')
|
||||
table.item(0, 7).setCheckState(Qt.CheckState.Checked)
|
||||
table.item(0, 8).setText('100nF/10V')
|
||||
table.item(0, 9).setCheckState(Qt.CheckState.Unchecked)
|
||||
edited = table.rows()
|
||||
assert edited[0].target == rows[0].target
|
||||
assert edited[0].enabled and edited[0].new_part_number == 'NEW-2'
|
||||
assert edited[0].custom_value == '100nF/10V' and not edited[0].sync_nc
|
||||
assert not edited[1].enabled and edited[1].target.uid == 'u2'
|
||||
assert table.dirty
|
||||
assert not table.item(0, 3).flags() & Qt.ItemFlag.ItemIsEditable
|
||||
table.close()
|
||||
|
||||
|
||||
def test_table_lock_blocks_editing_and_selection():
|
||||
app = QApplication.instance() or QApplication([])
|
||||
table = TargetTable()
|
||||
table.populate((TargetPlanRow(ComponentTarget(Path('C:/board.prj'), 'MAIN', '1',
|
||||
'u1', 'R1', 'OLD', 'A')),))
|
||||
table.set_plan_editable(False)
|
||||
assert not table.item(0, 0).flags() & Qt.ItemFlag.ItemIsUserCheckable
|
||||
assert not table.item(0, 6).flags() & Qt.ItemFlag.ItemIsEditable
|
||||
table.close()
|
||||
@@ -0,0 +1,157 @@
|
||||
"""Offline comparison of installed DxDesigner typelib and a saved makepy wrapper.
|
||||
|
||||
This script loads only the installed .tlb file and reads a saved wrapper. It never
|
||||
attaches to Viewdraw or starts DxDesigner.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import ast
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
DEFAULT_WRAPPER = Path(
|
||||
r"F:\Sync Tool Skyworth\Work Maps\AppTraceRecorder\reference\SiemensEDA_Python_Interface\xpedition_designer\designer_ifc.py"
|
||||
)
|
||||
DEFAULT_TLB = Path(r"D:\Mentor\7.9.5EE\SDD_HOME\wv\win32\bin\viewdraw.tlb")
|
||||
|
||||
|
||||
def sha256(path: Path) -> str:
|
||||
digest = hashlib.sha256()
|
||||
with path.open("rb") as stream:
|
||||
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def extract(wrapper: str) -> dict:
|
||||
wrapper_major = re.search(r"^MajorVersion\s*=\s*(\d+)", wrapper, re.MULTILINE)
|
||||
wrapper_minor = re.search(r"^MinorVersion\s*=\s*(\d+)", wrapper, re.MULTILINE)
|
||||
constants = {}
|
||||
for name in ("SRP_Project", "SRP_Board", "SRP_Schematic", "SRP_Sheet", "SRP_Selection",
|
||||
"PinMT_ByName", "PinMT_ByPinNumber", "PropMT_LibraryOnly",
|
||||
"PropMT_SchematicWins", "PropMT_LibraryWins"):
|
||||
match = re.search(rf"^\s*{name}\s*=\s*(\d+)\s+# from enum", wrapper, re.MULTILINE)
|
||||
if match:
|
||||
constants[name] = int(match.group(1))
|
||||
|
||||
methods = []
|
||||
seen = set()
|
||||
for owner in ast.parse(wrapper).body:
|
||||
if not isinstance(owner, ast.ClassDef):
|
||||
continue
|
||||
for node in owner.body:
|
||||
if not isinstance(node, ast.FunctionDef) or node.name not in {
|
||||
"ReplacePart", "ReplaceSymbol", "ReplaceConnector"
|
||||
}:
|
||||
continue
|
||||
calls = [item for item in ast.walk(node) if isinstance(item, ast.Call)
|
||||
and isinstance(item.func, ast.Attribute) and item.func.attr == "InvokeTypes"]
|
||||
if len(calls) != 1:
|
||||
continue
|
||||
call = calls[0]
|
||||
dispid = ast.literal_eval(call.args[0])
|
||||
key = (owner.name, node.name, dispid)
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
methods.append({
|
||||
"interface": owner.name,
|
||||
"name": node.name,
|
||||
"dispid": dispid,
|
||||
"arguments": [item.arg for item in node.args.args if item.arg != "self"],
|
||||
"makepy_return_type": ast.literal_eval(call.args[3]),
|
||||
"makepy_argument_types": ast.literal_eval(call.args[4]),
|
||||
"wrapper_line": node.lineno,
|
||||
"status": "typelib_candidate",
|
||||
})
|
||||
return {
|
||||
"declared_version": {
|
||||
"major": int(wrapper_major.group(1)) if wrapper_major else None,
|
||||
"minor": int(wrapper_minor.group(1)) if wrapper_minor else None,
|
||||
},
|
||||
"constants": constants,
|
||||
"methods": methods,
|
||||
}
|
||||
|
||||
|
||||
def inspect_installed_typelib(path: Path) -> dict:
|
||||
import pythoncom
|
||||
|
||||
library = pythoncom.LoadTypeLib(str(path))
|
||||
attr = library.GetLibAttr()
|
||||
wanted = {
|
||||
"ExecuteCommand", "ReplacePart", "ReplaceSymbol", "ReplaceConnector",
|
||||
"ChangeComponent", "ChangeComponentPreserveRefdes", "SelectExactSet",
|
||||
"Selected", "_SetSelected", "SelectObject", "SelectComponent",
|
||||
"SelectByName", "DeSelectAll", "QueryPages", "DesignComponents",
|
||||
"GetProjectData", "OpenReplacePartDialog", "ReplacePartCompleted",
|
||||
}
|
||||
interfaces = {}
|
||||
selected_interfaces = {"IVdApp", "IVdAppProtectionProxy", "IVdBlock", "IVdComp", "IVdView", "ICommandsManager"}
|
||||
for index in range(library.GetTypeInfoCount()):
|
||||
name = library.GetDocumentation(index)[0]
|
||||
if name not in selected_interfaces:
|
||||
continue
|
||||
info = library.GetTypeInfo(index)
|
||||
found = []
|
||||
for member_index in range(info.GetTypeAttr()[6]):
|
||||
desc = info.GetFuncDesc(member_index)
|
||||
names = info.GetNames(desc[0])
|
||||
if names[0] not in wanted:
|
||||
continue
|
||||
found.append({
|
||||
"name": names[0],
|
||||
"dispid": desc[0],
|
||||
"parameters": list(names[1:]),
|
||||
"argument_types": [list(arg[:2]) for arg in desc[2]],
|
||||
"return_type": list(desc[8][:2]),
|
||||
})
|
||||
if found:
|
||||
interfaces[name] = found
|
||||
return {
|
||||
"guid": str(attr[0]),
|
||||
"major_version": attr[3],
|
||||
"minor_version": attr[4],
|
||||
"type_count": library.GetTypeInfoCount(),
|
||||
"interfaces": interfaces,
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--wrapper", type=Path, default=DEFAULT_WRAPPER)
|
||||
parser.add_argument("--tlb", type=Path, default=DEFAULT_TLB)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
wrapper_text = args.wrapper.read_text(encoding="utf-8")
|
||||
result = {
|
||||
"format_version": 1,
|
||||
"mode": "offline_installed_typelib_and_wrapper_comparison",
|
||||
"attached_to_viewdraw": False,
|
||||
"mutation_attempted": False,
|
||||
"wrapper": {"path": str(args.wrapper), "sha256": sha256(args.wrapper)},
|
||||
"typelib": {"path": str(args.tlb), "exists": args.tlb.is_file()},
|
||||
"saved_wrapper_candidates": extract(wrapper_text),
|
||||
}
|
||||
if args.tlb.is_file():
|
||||
result["typelib"]["sha256"] = sha256(args.tlb)
|
||||
result["typelib"]["size"] = args.tlb.stat().st_size
|
||||
result["installed_typelib"] = inspect_installed_typelib(args.tlb)
|
||||
result["wrapper_matches_installed_version"] = (
|
||||
result["saved_wrapper_candidates"]["declared_version"] == {
|
||||
"major": result["installed_typelib"]["major_version"],
|
||||
"minor": result["installed_typelib"]["minor_version"],
|
||||
}
|
||||
)
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(json.dumps(result, indent=2, ensure_ascii=True) + "\n", encoding="utf-8")
|
||||
print(json.dumps(result, indent=2, ensure_ascii=True))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user