# -*- coding: utf-8 -*-
"""Genere le rapport sur l'etat du parc batterie, en trois langues.
Les MESURES vivent ici, les MOTS dans tools/rapport_textes.py. Une correction
de traduction ne peut donc jamais toucher un chiffre, ni l'inverse.
python3 tools/gen-rapport-batteries.py
"""
import importlib.util, pathlib
_sp = importlib.util.spec_from_file_location(
"rt", str(pathlib.Path(__file__).with_name("rapport_textes.py")))
rt = importlib.util.module_from_spec(_sp); _sp.loader.exec_module(rt)
MAJ = {"fr": "5 septembre 2026, 17 h", "en": "5 September 2026, 17:00",
"zh": "2026 年 9 月 5 日 17:00"}
# Amplitude min->max de chaque cellule, relevee sur l'historique du BMS. C'est
# LA grandeur qui separe une cellule saine d'une cellule morte sans demontage.
CODES = ["K220803C30160323", "K220803C30160322", "K220803C30160319", "K220803C30160324"]
AMPL = [
[191,188,188,189,190,197,187,190,189,192,191,188,187,192,198],
[182,178,178,178,177,548,371,181,179,179,182,691,178,273,178],
[183,521,184,186,182,318,183,186,184,473,184,443,184,188,424],
[138,124,138,137,139,132,134,142,143,135,136,137,128,135,683],
]
# code-barres, pack, adresse, nb atteintes, lesquelles, HV, OV, ecart median, etat
PARC = [
("K220803C30160322","a","1","4","6 · 7 · 12 · 14", 498, 86,108,"s"),
("K220803C30160323","a","2","0","—", 0, 0, 6,"s"),
("K220803C30160319","a","3","5","2 · 6 · 10 · 12 · 15", 416,179, 45,"s"),
("K220803C30160324","a","4","1","15", 29, 59, 57,"i"),
("Y230202C30371426","r","1","0","—", 1, 1, 2,"s"),
("Y230202C30371425","r","2","0","—", 1, 1, 2,"s"),
("Y230202C30371431","r","3","0","—", 1, 1, 2,"s"),
("Y230202C30371427","r","4","0","—", 1, 0, 2,"s"),
]
def couleur(a):
return ("var(--mort)" if a >= 600 else "var(--grave)" if a >= 400
else "var(--attention)" if a >= 250 else "var(--sain)")
def figure(lang):
LARG, LIGNE, GAUCHE, HAUT, ech = 760, 15, 96, 26, 0.86
out, y = [], 0
for code, place, nrec, amps in zip(CODES, rt.PLACES[lang], rt.RELEVES[lang], AMPL):
out.append(f'
{t['chapeau']}