easyeda / easyeda/eext-generate-schematic-from-netlist
.enet 文件导入失败:解析器期望 pins,但实际文件使用 components.pinInfoMap
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
# 标准 EasyEDA Pro .enet 文件导入失败:解析器未兼容 components.pinInfoMap 结构
我在尝试导入一个 EasyEDA Pro 导出的标准 `.enet` 网表文件时,发现插件无法正常导入。检查文件结构和插件源码后,发现当前解析逻辑似乎期望的是一种扁平化组件格式:
```json
{
"gge1": {
"props": {
"Designator": "U1",
"device_name": "TPS54302DDCR",
"value": "",
"Supplier Part": "C311983"
},
"pins": {
"1": "gnd",
"2": "net_sw"
}
}
}
```
但 EasyEDA Pro 实际导出的 `.enet` 文件结构是:
```json
{
"version": "2.0.0",
"components": {
"core001": {
"props": {
"Designator": "U1",
"DeviceName": "STM32H563VIT6",
"Supplier Part": "C6937834"
},
"pinInfoMap": {
"1": {
"name": "PE2",
"number": "1",
"net": "GPIO_PE2"
}
}
}
},
"designRule": {
"netRule": {}
}
}
```
因此当前导入逻辑可能会出现两个问题:
1. 将顶层的 `version`、`components`、`designRule` 等字段误认为器件。
2. 查找 `component.pins` 字段,但标准 `.enet` 中实际使用的是 `component.pinInfoMap`。
## 期望行为
希望插件可以兼容标准 EasyEDA Pro `.enet` 文件结构:
- 识别顶层带有 `components` 的 `.enet` 文件。
- 遍历 `data.components`,而不是直接遍历顶层对象。
- 将 `pinInfoMap.*.net` 转换为插件内部使用的引脚-网络映射。
- 对空网络进行安全处理,例如跳过空网络或保留为空连接。
## 测试文件信息
我测试的 `.enet` 文件信息如下:
- `.enet` version: `2.0.0`
- JSON 格式有效
- 器件数:50
- 引脚数:305
- 已连接引脚数:302
- 网络数:95
- `designRule.netRule` 数量:95
其中标准 `.enet` 中的器件结构类似:
```json
{
"props": {
"Designator": "U1",
"DeviceName": "STM32H563VIT6",
"Supplier Part": "C6937834"
},
"pinInfoMap": {
"1": {
"name": "PE2",
"number": "1",
"net": "GPIO_PE2"
}
}
}
```
## 建议
可以在解析阶段增加一个兼容层:
- 如果顶层存在 `components`,则使用 `data.components` 作为器件集合。
- 如果器件存在 `pins`,保持当前逻辑。
- 如果器件存在 `pinInfoMap`,则从 `pinInfoMap` 中提取 `number` 和 `net`,转换为当前插件使用的 `pins` 结构。
- `DeviceName` 可以兼容映射到当前代码使用的 `device_name`。
如果有什么需要我进一步说明的信息可以再跟我说,感谢🙏。
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.