R2:底板 / 刀片布局布线脚本、快照、截图与规划文档更新(含外壳、打印件、布线归档)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
这个提交包含在:
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
u"""布线缓存的「方向符合度」:每层按长度算顺 / 逆 / 斜各占多少(L1 优选 x、L4 优选 y,route_base.LAYER_DIR)。
|
||||
|
||||
/c/Python314/python .claude/r2/dir_stats.py [缓存.json ...] # 默认 _base_routes.json
|
||||
"""
|
||||
import io, json, math, os, sys
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
PREF = {1: 'x', 2: 'y'}
|
||||
NAME = {1: 'L1 插槽面(优选 x)', 2: 'L4 器件面(优选 y)'}
|
||||
for path in (sys.argv[1:] or [os.path.join(HERE, '_base_routes.json')]):
|
||||
d = json.load(io.open(path, encoding='utf-8'))
|
||||
print(u'%s:%d 段 / %d 孔 / 未完成 %d' % (os.path.basename(path), len(d['segs']), len(d['vias']), len(d['logs'])))
|
||||
for l in (1, 2):
|
||||
a = {'顺': 0.0, '逆': 0.0, '斜': 0.0}
|
||||
for s in d['segs']:
|
||||
if s[0] != l:
|
||||
continue
|
||||
dx, dy = abs(s[3] - s[1]), abs(s[4] - s[2])
|
||||
L = math.hypot(dx, dy)
|
||||
if dx > 1e-6 and dy > 1e-6:
|
||||
a['斜'] += L
|
||||
elif (dx > dy) == (PREF[l] == 'x'):
|
||||
a['顺'] += L
|
||||
else:
|
||||
a['逆'] += L
|
||||
t = sum(a.values()) or 1.0
|
||||
print(u' %s 总 %7.1f mm:顺 %5.1f%% 逆 %5.1f%% 斜 %5.1f%%'
|
||||
% (NAME[l], t, 100 * a['顺'] / t, 100 * a['逆'] / t, 100 * a['斜'] / t))
|
||||
在新工单中引用
屏蔽一个用户