Add per-area alarm breakdown (Areas tab + AreaCard), disable sim tick

New area_breakdown() calc groups top-5 alarm sources by plant area for
a new Areas tab / AreaCard component. Disabled AlarmSimTick so it stops
generating data during dev.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 07:38:02 -05:00
parent 4b07272556
commit 5f8c06ca80
9 changed files with 439 additions and 2 deletions

View File

@@ -310,6 +310,31 @@ def test_build_bundle_filters():
assert 0 < b["meta"]["event_count"] < b_all["meta"]["event_count"]
def test_area_breakdown_top5_per_area():
rows = []
# AreaA: 3 sources with 7/2/1 activations; AreaB: 6 sources with 6..1
for i, n in enumerate((7, 2, 1)):
src = "prov:default:/tag:Plant/AreaA/T%d:/alm:T%d" % (i, i)
for j in range(n):
rows += lifecycle("a%d_%d" % (i, j), src, T0 + (i * 50 + j) * M, dur_ms=M)
for i in range(6):
src = "prov:default:/tag:Plant/AreaB/S%d:/alm:S%d" % (i, i)
for j in range(6 - i):
rows += lifecycle("b%d_%d" % (i, j), src, T0 + (i * 40 + j) * M, dur_ms=M)
out = calc.area_breakdown(calc.correlate_instances(rows)[0])
assert [a["area"] for a in out] == ["AreaB", "AreaA"] # 21 vs 10 activations
b = out[0]
assert b["total"] == 21 and len(b["top"]) == 5 # capped at 5 of 6
assert [t["count"] for t in b["top"]] == [6, 5, 4, 3, 2]
assert b["top"][0]["rank"] == 1
assert abs(b["top"][0]["pct"] - 100.0 * 6 / 21) < 0.01 # share of AREA total
a = out[1]
assert a["total"] == 10 and len(a["top"]) == 3
# bundle carries it
bundle = calc.build_bundle(rows, [], None, T0, T0 + 4 * H, T0 + 4 * H)
assert [x["area"] for x in bundle["areas_top"]] == ["AreaB", "AreaA"]
def test_build_bundle_overview_stays_unfiltered():
start, end = T0, T0 + 4 * H
b_all = calc.build_bundle(synth_rows(), [], None, start, end, end)