Files
Support-Agent/maquettes/user/energy_template.html
T
maximeandClaude Opus 5.5 8a32f4d418 Organize the project by domain and name analyses by their rule
Energy code moves to src/energy/ and its docs to docs/energy/; shared code
(CSV loading, venv switch, browser, zoom script) goes to src/common/, and the
AIMsight originals to docs/aimsight/. Analyses are no longer numbered: two
Energy scripts remain, daily.py (delivered state and trend) and
all_analyses.py (comparison of the four). Calculations and pages unchanged (D-026).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:12:37 +02:00

257 lines
15 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AIMsight Energy</title>
<script src="https://cdn.plot.ly/plotly-4.1.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked@12.0.2/marked.min.js"></script>
<style>
/* Maquette côté client : page System Summary + section Diagnostic (D-020 à D-023). Données injectées par energy.py. */
:root {
--sidebar: #2a3f54; --topbar: #ededed; --page: #f7f7f7; --panel-border: #e6e9ed;
--muted: #73879c; --text: #333; --line: #dee2e6;
--green: #008300; --orange: #eda100; --red: #d03b3b; --unknown: #8c8c8c;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--muted);
font: 13px/1.47 "Helvetica Neue", Roboto, Arial, "Droid Sans", sans-serif; }
svg.i { width: 15px; height: 15px; fill: currentColor; vertical-align: -2px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; background: var(--sidebar); color: #fff; }
.brand { height: 57px; padding: 0 10px; display: flex; align-items: center; font-size: 22px; }
.profile { display: flex; align-items: center; gap: 22px; padding: 18px 12px 24px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: #9b59b6; border: 3px solid #fff;
display: grid; place-items: center; font-size: 19px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.profile small { display: block; color: #bab8b8; font-size: 13px; }
.profile span { font-size: 14px; }
.section { padding: 0 23px 18px; font-size: 11px; font-weight: bold; letter-spacing: .3px; }
.nav a { display: flex; align-items: center; gap: 4px; padding: 13px 15px; color: #e7e7e7;
text-decoration: none; font-weight: bold; }
.nav a .chev { margin-left: auto; }
.topbar { margin-left: 230px; height: 52px; background: var(--topbar); border-bottom: 1px solid #d9dee4;
display: flex; align-items: center; justify-content: space-between; padding: 0 15px; }
.topbar .burger { color: #5a738e; width: 26px; height: 26px; }
.user { display: flex; align-items: center; gap: 10px; color: #515356; }
.user .avatar { width: 29px; height: 29px; border-width: 0; font-size: 11px; box-shadow: none; }
main { margin-left: 230px; padding: 10px 28px; }
.panel { background: #fff; border: 1px solid var(--panel-border); padding: 10px 17px 20px; }
.panel-title { display: flex; align-items: center; border-bottom: 2px solid var(--panel-border); padding: 4px 6px 12px; }
.panel-title h2 { margin: 0; font-size: 18px; font-weight: 400; }
.panel-title h2 small { font-size: 14px; margin-left: 10px; }
.panel-title .tools { margin-left: auto; color: #c5c7cb; }
/* Ajout : section Diagnostic, une ligne repliable par diagnostic (ici : énergie). */
.diag { margin: 22px 22px 0; }
.diag > h3 { margin: 0 0 8px; font-size: 12px; font-weight: bold; letter-spacing: .4px; text-transform: uppercase; }
.diag-item { border: 1px solid var(--line); border-radius: 4px; }
.diag-item > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px;
padding: 10px 14px; color: var(--text); font-size: 15px; }
.diag-item > summary::-webkit-details-marker { display: none; }
.status { padding: 2px 12px; border-radius: 999px; font-size: 13px; font-weight: bold; color: #fff; }
.status.GREEN { background: var(--green); } .status.ORANGE { background: var(--orange); color: #1a1a1a; }
.status.RED { background: var(--red); } .status.UNKNOWN { background: var(--unknown); }
.meta { color: var(--muted); font-size: 13px; }
.diag-item > summary .chev { margin-left: auto; width: 13px; height: 13px; transition: transform .15s; }
.diag-item[open] > summary .chev { transform: rotate(180deg); }
.diag-body { border-top: 1px solid var(--line); padding: 14px; }
.headline { margin: 0 0 12px; color: var(--text); font-size: 15px; }
.days { border-collapse: collapse; color: var(--text); }
.days th, .days td { padding: 5px 28px 5px 0; text-align: left; font-weight: normal; vertical-align: top; }
.days th { color: var(--muted); }
/* Échelle de batterie : Off < 10 %, Low < 30 %, OK < 90 %, Full ; le trait marque le niveau de ce matin. */
.gauge { position: relative; display: flex; width: 320px; font-size: 10px; color: var(--muted); }
.gauge span { border-top: 10px solid; padding-top: 2px; text-align: center; }
.gauge span:nth-child(1) { border-color: #f1c0c0; } .gauge span:nth-child(2) { border-color: #f8dca8; }
.gauge span:nth-child(3) { border-color: #e4ebdc; } .gauge span:nth-child(4) { border-color: #bfe0bf; }
.gauge i { position: absolute; top: -3px; height: 16px; width: 3px; margin-left: -1.5px; background: var(--text); border-radius: 2px; }
.gauge-text { margin-top: 6px; }
/* Guide : partie 1 du manuel, rendue depuis le Markdown. */
.guide { max-width: 900px; margin-top: 6px; color: var(--text); }
.guide h3 { margin: 12px 0 6px; font-size: 16px; } .guide h4 { margin: 14px 0 6px; font-size: 14px; }
.guide h5 { margin: 10px 0 4px; font-size: 13px; }
.guide p, .guide ul { margin: 6px 0; }
.guide table { border-collapse: collapse; margin: 6px 0 10px; }
.guide th, .guide td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.guide th { background: #f5f7fa; }
.sub { margin-top: 12px; }
.action { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.action[hidden] { display: none; }
.action button { background: #2a78d6; color: #fff; border: 0; border-radius: 4px; padding: 7px 12px;
font: inherit; font-size: 14px; cursor: pointer; }
.sub > summary { cursor: pointer; color: var(--muted); }
#daily { margin-top: 10px; }
.collapse { margin: 22px 22px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
padding: 9px 0; display: flex; justify-content: space-between; color: var(--text); font-size: 15px; }
.collapse svg { width: 13px; height: 13px; }
#chart { margin: 10px 6px 0; height: 420px; }
.btn { margin: 18px 22px 0; display: inline-block; background: #6c757d; color: #fff; border-radius: 4px;
padding: 8px 13px; font-size: 15px; }
.metrics { margin: 0 22px; width: calc(100% - 44px); border-collapse: collapse; font-size: 15px; }
.metrics td { border: 1px solid var(--line); padding: 9px 8px; color: #212529; }
.metrics td:first-child { font-weight: bold; width: 39%; }
.metrics td:last-child { font-style: italic; }
</style>
</head>
<body>
<svg style="display:none">
<symbol id="home" viewBox="0 0 20 20"><path d="M10 2 1 10h3v8h5v-5h2v5h5v-8h3z"/></symbol>
<symbol id="list" viewBox="0 0 20 20"><path d="M1 3h3v3H1zm5 0h13v3H6zM1 8.5h3v3H1zm5 0h13v3H6zM1 14h3v3H1zm5 0h13v3H6z"/></symbol>
<symbol id="cog" viewBox="0 0 20 20"><circle cx="10" cy="10" r="6" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="2.4 2.3"/><circle cx="10" cy="10" r="5" fill="none" stroke="currentColor" stroke-width="3"/></symbol>
<symbol id="chev" viewBox="0 0 20 20"><path d="M4 7l6 6 6-6" fill="none" stroke="currentColor" stroke-width="2.2"/></symbol>
<symbol id="burger" viewBox="0 0 20 20"><path d="M2 4h16v2.4H2zm0 4.8h16v2.4H2zm0 4.8h16V16H2z"/></symbol>
<symbol id="wrench" viewBox="0 0 20 20"><path d="M13.5 1.5a5 5 0 0 0-4.6 6.9L2 15.3 4.7 18l6.9-6.9a5 5 0 0 0 6.9-4.6l-3 3-2.8-.6-.6-2.8z"/></symbol>
</svg>
<aside class="sidebar">
<div class="brand">AIMsight monitoring</div>
<div class="profile"><div class="avatar">MP</div><div><small>Welcome,</small><span>Maxime Pasquier</span></div></div>
<div class="section">GENERAL</div>
<nav class="nav">
<a><svg class="i"><use href="#home"/></svg>Home</a>
<a><svg class="i"><use href="#list"/></svg>Explore<svg class="i chev"><use href="#chev"/></svg></a>
<a><svg class="i"><use href="#cog"/></svg>Settings<svg class="i chev"><use href="#chev"/></svg></a>
</nav>
</aside>
<header class="topbar">
<svg class="burger"><use href="#burger"/></svg>
<div class="user"><div class="avatar">MP</div>Maxime Pasquier ▾</div>
</header>
<main>
<section class="panel">
<div class="panel-title">
<h2>VERMONT<small>System Summary</small></h2>
<span class="tools"><svg class="i"><use href="#wrench"/></svg> ▾</span>
</div>
<section class="diag">
<h3>Diagnostic</h3>
<details class="diag-item" id="energy">
<summary>
<b>Energy</b>
<span class="status" id="status"></span>
<span class="meta" id="meta"></span>
<svg class="i chev"><use href="#chev"/></svg>
</summary>
<div class="diag-body">
<p class="headline" id="headline"></p>
<table class="days" id="today"></table>
<div class="action" id="action" hidden>
<button type="button" id="save-mode">Activate energy save mode</button>
<span class="meta" id="save-note">The station sleeps between measurements to use less energy.</span>
</div>
<details class="sub" id="history">
<summary>Full history</summary>
<div id="daily"></div>
</details>
<details class="sub" id="guide">
<summary>Guide</summary>
<div class="guide" id="guide-body"></div>
</details>
</div>
</details>
</section>
<div class="collapse">BusVoltage <svg><use href="#chev"/></svg></div>
<div id="chart"></div>
<div class="btn">Download CSV</div>
<table class="metrics" id="table"></table>
</section>
</main>
<script>
const DATA = /*DATA*/null;
const DAILY = /*DAILY*/null; // figure de DAILY_BATTERY_STATE et DAILY_BATTERY_TREND (D-021), telle que le site la reçoit
const R = DATA.rule, E = DATA.energy, cur = E.cur || {};
const NAME = { GREEN: "Green", ORANGE: "Orange", RED: "Red" };
const ACTION = { GREEN: "Nothing to do", ORANGE: "Watch", RED: "Contact support" };
// Une phrase de très haut niveau, sans détail (manuel, partie 1, § 2).
const HEADLINE = {
GREEN: "The station is receiving enough energy.",
ORANGE: "The station's energy supply is uncertain.",
RED: "The station is not receiving enough energy.",
};
const TREND = { BETTER: "↗ Better than the day before", STABLE: "→ Same as the day before", WORSE: "↘ Worse than the day before" };
// Échelle de batterie : niveau de fin de nuit (le meilleur repère du niveau, docs/energy/domaine/comment-se-comporte-la-batterie.md),
// placé en % par la table OCV LiFePO4 du collecteur (docs/aimsight/collecteur_system_info.py, LIFEPO4_OCV_SOC).
// ponytail: sans compensation IR (la nuit, ~0,14 V sous la tension à vide) : repère un peu bas ; compenser avec BusCurrent si besoin.
const OCV = [[10.0, 0], [12.0, 10], [12.5, 20], [12.8, 30], [12.9, 40], [13.0, 50], [13.1, 60], [13.2, 70], [13.3, 80],
[13.4, 90], [13.6, 100]];
const soc = x => {
for (let i = 1; i < OCV.length; i++) {
const [v0, p0] = OCV[i - 1], [v1, p1] = OCV[i];
if (x <= v1) return Math.max(0, p0 + (p1 - p0) * (x - v0) / (v1 - v0));
}
return 100;
};
// Zones, aux points de la table : 10 % = 12,0 V (la station s'éteint dessous), 30 % = coude 12,8 V, 90 % = 13,4 V.
// Pas de % affiché : sur le plateau (30-90 %), 0,1 V vaut ~10 % de charge, la tension n'en dit pas plus.
const ZONES = [[10, "Off", "nearly empty, the station may shut down"], [30, "Low", "low (under 30 %)"],
[90, "OK", "between 30 and 90 %"], [100, "Full", "full"]];
const recharge = d => d.max_v == null ? "" : d.max_v >= R.full_charge_v ? "fully recharged today"
: d.rise_v >= R.min_rise_v ? "partially recharged today" : "not recharged today";
function gauge(d) {
if (d.night_end_v == null) return "Unknown";
const pct = soc(d.night_end_v), zone = ZONES.find(z => pct < z[0]) || ZONES[ZONES.length - 1];
const text = `This morning: ${zone[2]} · ${recharge(d)}`;
return `<div class="gauge" role="img" aria-label="${text}" title="night end ${d.night_end_v.toFixed(3)} V">` +
ZONES.map(([hi, name], i) => `<span style="width:${hi - (i ? ZONES[i - 1][0] : 0)}%">${name}</span>`).join("") +
`<i style="left:${pct}%"></i></div><div class="gauge-text">${text}</div>`;
}
const chip = c => `<span class="status ${c || "UNKNOWN"}">${NAME[c] || "Unknown"}</span>`;
// Bloc Energy : la couleur du jour, l'échelle de batterie et la tendance face à la veille.
document.getElementById("status").outerHTML = chip(cur.color);
document.getElementById("meta").textContent = `${E.label} · ${ACTION[cur.color] || "Check data"}`;
document.getElementById("headline").textContent = HEADLINE[cur.color] || "Not enough data to assess the station's energy.";
document.getElementById("today").innerHTML = [["Battery", gauge(cur)], ["Trend", TREND[cur.trend] || "Unknown"]]
.map(([k, x]) => `<tr><th>${k}</th><td>${x}</td></tr>`).join("");
document.getElementById("guide-body").innerHTML = marked.parse(DATA.guide); // texte du projet, pas une saisie
// Remède proposé au client quand l'énergie manque : veille profonde entre les mesures
// (docs/energy/domaine/comment-se-comporte-la-batterie.md). Action de la plateforme, pas du diagnostic (lecture seule).
// Maquette : le bouton n'envoie rien.
document.getElementById("action").hidden = !["ORANGE", "RED"].includes(cur.color);
document.getElementById("save-mode").onclick = () =>
document.getElementById("save-note").textContent = "Mockup: no command is sent to the station.";
// L'historique complet n'est tracé qu'à la première ouverture (un graphique caché n'a pas de largeur).
document.getElementById("history").addEventListener("toggle", e => {
if (!e.target.open || e.target.dataset.drawn) return;
e.target.dataset.drawn = "1";
Plotly.newPlot("daily", DAILY.data, DAILY.layout, { responsive: true, scrollZoom: true }).then(() => {
/*AUTOSCALE*/
});
});
document.getElementById("table").innerHTML =
DATA.table.map(([k, x]) => `<tr><td>${k}</td><td>${x}</td></tr>`).join("");
const lo = DATA.daily.map(p => p.lo), hi = DATA.daily.map(p => p.hi);
const extremes = (pts, name, fill, line, pos) => ({
x: pts.map(p => p[0]), y: pts.map(p => p[1]), name, mode: "markers+text", type: "scatter",
text: pts.map(p => p[1].toFixed(3)), textposition: pos, textfont: { size: 11, color: "#2a3f54" },
marker: { size: 8, color: fill, line: { color: line, width: 1.5 } }, hoverinfo: "x+y",
});
Plotly.newPlot("chart", [
{ x: DATA.hours.map(h => h[0]), y: DATA.hours.map(h => h[1]), name: "Battery Voltage", mode: "lines",
type: "scatter", line: { color: "#636efa", width: 2 }, connectgaps: false },
extremes(lo, "lowest daily value", "#a9b0fb", "#636efa", "bottom center"),
extremes(hi, "highest daily value", "#1bb38a", "#0b6e55", "top center"),
], {
margin: { l: 70, r: 10, t: 10, b: 40 }, paper_bgcolor: "#fff", plot_bgcolor: "#e5ecf6",
font: { family: "Helvetica Neue, Roboto, Arial, sans-serif", size: 12, color: "#2a3f54" },
xaxis: { type: "date", range: DATA.range, gridcolor: "#fff" },
yaxis: { gridcolor: "#fff", zeroline: false },
legend: { x: 1.02, y: 1, yanchor: "top" },
}, { displayModeBar: false, responsive: true });
</script>
</body>
</html>