master
John Lauer Preserve BQ independent routing, narration and native copper-retention evidence a4b7711 1mo ago
import json,math,sys,shutil,xml.etree.ElementTree as ET
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]));from call import call
ROOT=Path(__file__).resolve().parent;bundle=ROOT/'live-bundle-06';bundle.mkdir(exist_ok=False)
t=ET.parse(ROOT/'bq25792-unrouted-rule-check.brd');signals={s.get('name'):s for s in t.findall('drawing/board/signals/signal')};items=[]
for q in json.loads((ROOT/'repair-09/candidate-plan.json').read_text())['routes']:
 for p in q['parts']:
  for a,b in zip(p['points'],p['points'][1:]):
   if math.dist(a,b)>1e-7:items.append((q['net'],'wire',dict(x1=f'{a[0]:.6f}',y1=f'{a[1]:.6f}',x2=f'{b[0]:.6f}',y2=f'{b[1]:.6f}',layer=str(p['layer']),width=str(p['width']))))
 for a in q['vias']:items.append((q['net'],'via',dict(x=f'{a[0]:.6f}',y=f'{a[1]:.6f}',extent='1-16',drill='.2',diameter='.45')))
for net,tag,attrs in items[:342]:ET.SubElement(signals[net],tag,attrs)
t.write(bundle/'bq25792-astra-live-06.brd',encoding='utf-8',xml_declaration=True)
for src,dest in [(ROOT/'replay_live.py','replay_live.py'),(ROOT/'repair-09/candidate-plan.json','candidate-plan.json'),(ROOT.parents[2]/'rust/bridge/src/routing_script.py','routing_script.py')]:shutil.copyfile(src,bundle/dest)
r=call('send_files',{'filePaths':[str(x.resolve()) for x in bundle.iterdir()],'dest':'C:/Users/john/Documents/Adom Routing Demos/BQ25792/live-06','reason':'Re-record the damaged middle video section from the verified 342-primitive checkpoint'});assert r.get('success'),r
r=call('fusion_open_board',{'filePath':'C:/Users/john/Documents/Adom Routing Demos/BQ25792/live-06/bq25792-astra-live-06.brd'});assert r.get('success'),r