Fiabilite Canon : veille/reveil relais, sequence boot, stats diagnostic, fin evenement, compteur consommables

- Preview thread : poll uniquement quand ecran capture actif, keepalive 30s sinon
- Sequence boot Canon : power cycle relais si absent USB au demarrage
- Veille auto 30min : Canon coupe par relais apres inactivite, reveil au preview_start
- Stats diagnostic /api/canon/stats : keepalive, preview, captures, connexions
- Escalade reconnexion adoucie : pas d'USB reset les 2 premieres tentatives
- Hard reset relais 10s (resistance decharge 990ohm sur dummy battery 8V)
- Gestion fin evenement : date_fin + bouton terminer + guard 403 impression
- Compteur base sur min(papier, ruban) avec cap evenement optionnel
- Pre-eclairage countdown : projecteurs ON 3s avant capture pour mesure expo
- Canon _configurer_init() : ISO 800, drivemode Single, viewfinder, EXIF preserve
- Admin : detail evenement, compteur consommables, galerie impression

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WyN9xFp84P9VaWT3Qe2DXu
This commit is contained in:
2026-08-14 19:33:28 +02:00
parent a6766f529e
commit 4e267492c2
16 changed files with 1424 additions and 162 deletions

View File

@@ -203,16 +203,28 @@ def detecter_usb() -> list[str]:
def compteur_restant() -> dict:
"""Retourne l'etat du compteur."""
"""Retourne l'etat du compteur, basé sur les consommables restants."""
config = charger_config()
compteur = config.get("compteur", {})
limite = compteur.get("limite", 400)
conso = config.get("consommables", {})
prises = compteur.get("photos_prises", 0)
papier_rest = max(0, conso.get("papier_capacite", 400) - conso.get("papier_utilise", 0))
ruban_rest = max(0, round(conso.get("ruban_capacite", 400) - conso.get("ruban_utilise", 0), 1))
restantes = int(min(papier_rest, ruban_rest))
limite_event = compteur.get("limite", 0)
if compteur.get("actif") and limite_event > 0:
restantes = min(restantes, max(0, limite_event - prises))
papier_cap = conso.get("papier_capacite", 400)
ruban_cap = conso.get("ruban_capacite", 400)
capacite_conso = int(min(papier_cap, ruban_cap))
return {
"actif": compteur.get("actif", False),
"limite": limite,
"limite": limite_event,
"photos_prises": prises,
"restantes": max(0, limite - prises),
"restantes": restantes,
"capacite": capacite_conso,
"papier_restant": papier_rest,
"ruban_restant": int(ruban_rest),
}