33 行
1.4 KiB
Python
33 行
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
u"""服务器上算 GND 缝合孔位(2026-09-11 混合布线收尾):pour_base.stitch_points 默认读 _base_routes.json(脚本布线缓存),
|
|
板上现在是「预布 + EasyEDA 自动布线 + 手改」,所以把它的 routes() 换成板上快照再算。本机只拿结果下发。
|
|
|
|
DCDC_ROUTE_SERVER=1 /root/pypy/bin/pypy3 .claude/r2/stitch_srv.py # 读 _board_for_stitch.json,写 _stitch_pts.json
|
|
"""
|
|
import io
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
if os.environ.get('DCDC_ROUTE_SERVER') != '1':
|
|
sys.exit(u'!! 孔位搜索只在服务器上跑(DCDC_ROUTE_SERVER=1),见 CLAUDE.md')
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, os.path.dirname(HERE))
|
|
sys.path.insert(0, HERE)
|
|
import pour_base as PB # noqa: E402
|
|
|
|
|
|
def main():
|
|
b = json.load(io.open(os.path.join(HERE, '_board_for_stitch.json'), encoding='utf-8'))
|
|
pre = json.load(io.open(os.path.join(HERE, '_base_preroute_0911b.json'), encoding='utf-8'))
|
|
segs = [s[:7] for s in b['segs'] if s[0] in (1, 2, 15, 16)]
|
|
vias = [v[:3] for v in b['vias']]
|
|
PB._ROUTES[0] = (segs, vias, pre.get('v12_patch'))
|
|
pts = PB.stitch_points(PB.plan())
|
|
io.open(os.path.join(HERE, '_stitch_pts.json'), 'w', encoding='utf-8').write(json.dumps(pts))
|
|
print(u'缝合孔 %d 个(板上快照:%d 段 / %d 孔)' % (len(pts), len(segs), len(vias)))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|