piccal/velTableToDataStruct.py
2020-02-29 00:01:58 -05:00

54 lines
1014 B
Python

import json
from common import parse_yaml_cfg
ymlFn = 'p_ac.yml'
ifn = 'velMapD.json'
ofn = 'velMapD.h'
with open(ofn,"wt") as f1:
with open(ifn,"r") as f:
d = json.load(f)
f1.write("{\n");
for key,velL in d.items():
f1.write("{ ")
f1.write( str(key) + ", { " )
for us,x in velL:
f1.write("%5i, " % (us))
f1.write("} },\n")
f1.write("}\n\n");
cfg = parse_yaml_cfg(ymlFn)
d = cfg.calibrateArgs['holdDutyPctD']
n = 0
for key,dutyL in d.items():
n = max(n, len(dutyL))
f1.write("{\n")
for key,dutyL in d.items():
f1.write( str(key)+", {")
for i,(us,duty) in enumerate(dutyL):
f1.write("{ %i, %i }, " % (us,duty))
for j in range(i,n):
f1.write("{ -1, -1 }, ")
f1.write("},\n");
f1.write("}\n");