app: stacked_cores: allow 40xx_db.py to update itself
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from inverter_characteristics import Piecewise
|
from inverter_characteristics import Piecewise
|
||||||
|
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sims = [
|
sims = [
|
||||||
@@ -25,11 +26,24 @@ sims = [
|
|||||||
|
|
||||||
measurements = { real: [human, norm, None, None] for (real, human, norm) in sims }
|
measurements = { real: [human, norm, None, None] for (real, human, norm) in sims }
|
||||||
|
|
||||||
def set_meas(name: str, expr: str):
|
def set_meas(real: str, expr: str):
|
||||||
pw = eval(expr)
|
pw = eval(expr)
|
||||||
measurements[name][2] = expr
|
measurements[real][2] = expr
|
||||||
human, norm, _, _ = measurements[name]
|
human, norm, _, _ = measurements[real]
|
||||||
globals()[human] = measurements[name][3] = pw.normalized(norm)
|
globals()[human] = measurements[real][3] = pw.normalized(norm)
|
||||||
|
|
||||||
|
def try_measure(real: str):
|
||||||
|
new_value = subprocess.check_output(
|
||||||
|
[
|
||||||
|
"./stacked_cores_39xx.py",
|
||||||
|
f"../../../../out/applications/stacked_cores/{real}"
|
||||||
|
]
|
||||||
|
).decode()
|
||||||
|
set_meas(real, "\n" + new_value)
|
||||||
|
|
||||||
|
def update_all():
|
||||||
|
for (real, _human, _norm) in sims:
|
||||||
|
try_measure(real)
|
||||||
|
|
||||||
def dump(path: str):
|
def dump(path: str):
|
||||||
orig = open(path).read()
|
orig = open(path).read()
|
||||||
@@ -42,7 +56,11 @@ def dump(path: str):
|
|||||||
encoded = measurements[real][2]
|
encoded = measurements[real][2]
|
||||||
f.write(f"\n\nset_meas(\"{real}\", \"\"\"{encoded}\"\"\")")
|
f.write(f"\n\nset_meas(\"{real}\", \"\"\"{encoded}\"\"\")")
|
||||||
|
|
||||||
f.write("\n\nif __name__ == '__main__': dump(__file__)\n")
|
f.write("\n\nif __name__ == '__main__': main()\n")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
update_all()
|
||||||
|
dump(__file__)
|
||||||
|
|
||||||
|
|
||||||
## AUTOGENERATED
|
## AUTOGENERATED
|
||||||
@@ -542,4 +560,4 @@ Piecewise(
|
|||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
||||||
if __name__ == '__main__': dump(__file__)
|
if __name__ == '__main__': main()
|
||||||
|
Reference in New Issue
Block a user