2020-10-26 18:57:43 +00:00
|
|
|
##| Copyright: (C) 2019-2020 Kevin Larke <contact AT larke DOT org>
|
|
|
|
##| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
|
2020-02-29 05:01:58 +00:00
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|