R2:底板 / 刀片布局布线脚本、快照、截图与规划文档更新(含外壳、打印件、布线归档)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
这个提交包含在:
+33
-12
@@ -1,11 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
u"""补线器:在**板上现有铜**之上只布没接完的那几个网(不动其它任何线)。
|
||||
u"""补线器:在**现有铜**之上只布没接完的那几个网(不动其它任何线)。
|
||||
|
||||
/c/Python314/python .claude/r2/repair_route.py # 只算
|
||||
/c/Python314/python .claude/r2/repair_route.py --push # 追加下发(只推新增的段/孔)
|
||||
# 刀片 90×68 起:只在服务器上算(CLAUDE.md),入口
|
||||
MODE=repair bash .claude/r2/remote_blade.sh +12V_F +5V # `$` 写成 `@`
|
||||
# 服务器上实际跑的是:
|
||||
DCDC_ROUTE_SERVER=1 pypy3 .claude/r2/repair_route.py --cache +12V_F +5V
|
||||
|
||||
现有铜从 `_m6_board_copper.json`(pcb 读回)来,按网名打进占用图 —— 同网可穿,
|
||||
所以 A* 从没接上的焊盘出发,碰到本网已有的铜就算到了。
|
||||
`--cache`:现有铜取 `_blade_routes.json`(布线缓存),补完把**合并后的完整缓存**写到
|
||||
`_blade_routes.repaired.json`(比过再手动拷成 `_blade_routes.json`,然后 `router.py --push`)。
|
||||
不带 `--cache` 是 M6 的老用法:现有铜从 `_m6_board_copper.json`(板上读回)来,结果写 `_m6_repair.json`。
|
||||
|
||||
现有铜按网名打进占用图 —— 同网可穿,所以 A* 从没接上的焊盘出发,碰到本网已有的铜就算到了。
|
||||
"""
|
||||
import io, json, os, sys, math
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
@@ -14,14 +19,21 @@ sys.path.insert(0, os.path.dirname(HERE)); sys.path.insert(0, HERE)
|
||||
import router as RT
|
||||
import pcb_rules as R
|
||||
|
||||
NETS = [a for a in sys.argv[1:] if not a.startswith('--')] or \
|
||||
if not os.environ.get('DCDC_ROUTE_SERVER'):
|
||||
sys.exit(u'⛔ 补线(A*)只在 10.5.5.13 上跑(CLAUDE.md):MODE=repair bash .claude/r2/remote_blade.sh <网名...>')
|
||||
|
||||
CACHE_MODE = '--cache' in sys.argv
|
||||
NETS = [a.replace('@', '$') for a in sys.argv[1:] if not a.startswith('--')] or \
|
||||
['VDAC', '$1N147', '$1N156', 'EFUSE_PG', '$1N165', 'VO', '+3V3', 'VBUS', 'SDA']
|
||||
cp = json.load(io.open(os.path.join(HERE, '_m6_board_copper.json'), encoding='utf-8'))
|
||||
src = '_blade_routes.json' if CACHE_MODE else '_m6_board_copper.json'
|
||||
cp = json.load(io.open(os.path.join(HERE, src), encoding='utf-8'))
|
||||
segs = [tuple(s) for s in cp['segs']]
|
||||
vias = [tuple(v) for v in cp['vias']]
|
||||
pads = RT.load_pads()
|
||||
auto = R.resolve_auto()
|
||||
board_vias = [(v[0], v[1], v[2], RT.VIA_D) for v in vias if v[2] == 'GND']
|
||||
# 固定障碍的过孔:M6 读回的板上只有 GND 缝合孔;缓存里另有 D± 构造的两个孔(plan_all 同样把它们记进 board_vias)
|
||||
fixed = ('GND',) + (RT.DP_NETS if CACHE_MODE else ())
|
||||
board_vias = [(v[0], v[1], v[2], RT.VIA_D) for v in vias if v[2] in fixed]
|
||||
_fs, _fv, launch = RT.finger_escape()
|
||||
bypad = {}
|
||||
for p in pads:
|
||||
@@ -31,6 +43,7 @@ for p in pads:
|
||||
for net, pts in launch.items():
|
||||
for (lay, x, y) in pts:
|
||||
bypad.setdefault(net, []).append(['J1', 'launch', x, y, 0.3, 0.3, lay, net, 'RECT'])
|
||||
print(u'补 %s(现有铜:%s,%d 段 / %d 孔)' % (' '.join(NETS), src, len(segs), len(vias)))
|
||||
n0, v0 = len(segs), len(vias)
|
||||
logs = RT.route_groups(bypad, pads, segs, vias, board_vias, auto,
|
||||
priority=tuple(NETS), only=set(NETS))
|
||||
@@ -39,7 +52,15 @@ print(u'新增 %d 段 / %d 孔' % (len(new_s), len(new_v)))
|
||||
for m in logs:
|
||||
print(u' [!] ' + m)
|
||||
left = RT.check_connected(pads, segs, vias)
|
||||
print(u'连通性复查:%s' % (u'全通' if not left else left))
|
||||
json.dump({'segs': new_s, 'vias': new_v}, io.open(os.path.join(HERE, '_m6_repair.json'), 'w', encoding='utf-8'))
|
||||
if '--push' in sys.argv and new_s:
|
||||
RT.push(new_s, new_v)
|
||||
print(u'连通性复查(布线器口径,会误报,以 blade_conn.py 为准):%s' % (u'全通' if not left else left))
|
||||
if CACHE_MODE:
|
||||
out = {'segs': [list(s) for s in segs], 'vias': [list(v) for v in vias],
|
||||
'logs': list(logs) + [u'[连通性] ' + m for m in left], 'repaired': NETS}
|
||||
json.dump(out, io.open(os.path.join(HERE, '_blade_routes.repaired.json'), 'w', encoding='utf-8'),
|
||||
ensure_ascii=False)
|
||||
print(u'已写 _blade_routes.repaired.json(合并后的完整缓存)')
|
||||
else:
|
||||
json.dump({'segs': new_s, 'vias': new_v},
|
||||
io.open(os.path.join(HERE, '_m6_repair.json'), 'w', encoding='utf-8'))
|
||||
if '--push' in sys.argv and new_s:
|
||||
RT.push(new_s, new_v)
|
||||
|
||||
在新工单中引用
屏蔽一个用户