EV-13 review: compare phase currents per phase; test a late read-back
A phase that drops out or comes back shifted the compressed current_a tuple and read as life, so a frozen charger never armed. ChargerReading.phase_a keeps L1/L2/L3 with None for a missing phase and the life test uses it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -78,11 +78,13 @@ TOOK_S, STUCK_S = CH.TOOK_S, CH.STUCK_S
|
||||
print("1. S: WHAT COUNTS AS LIFE")
|
||||
# =========================================================================== #
|
||||
def rd(e=1.000, p=11040.0, cur=(16.0, 15.9, 16.0), a=16.0, taken=None,
|
||||
state="C"):
|
||||
state="C", ph=None):
|
||||
"""`cur` is `current_a` (a missing phase is left out of it); `ph` is the
|
||||
per-phase `phase_a` (None for a missing phase) the driver also sets."""
|
||||
return CH.ChargerReading(
|
||||
available=True, state=state, charging=state == "C", power_w=p,
|
||||
energy_kwh=e, current_a=cur, allowed_a=a, setpoint_a=a,
|
||||
phases_allowed=3, taken_at=taken)
|
||||
phases_allowed=3, taken_at=taken, phase_a=ph or ())
|
||||
|
||||
|
||||
def steady(changes=None, start=1, end=130, **base):
|
||||
@@ -174,6 +176,21 @@ life("T9 the step at +9, inside the window", {9: dict(e=1.010)})
|
||||
life("T9 the step exactly at +10 (the edge counts)", {10: dict(e=1.010)})
|
||||
life("T12(a) power None, state C, energy rising", {4: dict(e=1.010)},
|
||||
pre=dict(p=None))
|
||||
# P1/P2 (review): a phase that drops out or comes back is no change: the
|
||||
# others must not shift against another phase's old value
|
||||
armed("P1 L1 present before, absent after, all else frozen",
|
||||
steady(cur=(16.0, 16.1)))
|
||||
armed("P2 L1 absent before, present after (current_a only), all else frozen",
|
||||
steady(), pre=dict(cur=(15.9, 16.0)))
|
||||
armed("P1 per phase: L1 present before, absent after (phase_a)",
|
||||
steady(cur=(16.0, 16.1), ph=(None, 16.0, 16.1)),
|
||||
pre=dict(ph=(15.9, 16.0, 16.1)))
|
||||
armed("P2 per phase: L1 absent before, present after (phase_a)",
|
||||
steady(ph=(15.9, 16.0, 16.1)), pre=dict(cur=(16.0, 16.1),
|
||||
ph=(None, 16.0, 16.1)))
|
||||
life("P5 per phase: L1 absent, L2 really changes (phase_a)",
|
||||
{4: dict(cur=(16.2, 16.1), ph=(None, 16.2, 16.1))},
|
||||
pre=dict(cur=(16.0, 16.1), ph=(None, 16.0, 16.1)))
|
||||
armed("T6 present but unchanged: every sample repeats the pre-write values",
|
||||
steady())
|
||||
armed("T9 the step at +11 is outside the window; armed_at is the send, not "
|
||||
@@ -1007,6 +1024,29 @@ for mode in ("live", "ring"):
|
||||
"window runs on and arms at the send", tr.armed_at == TS
|
||||
and first is not None and TS + 59 <= first <= TS + 61)
|
||||
|
||||
# P4 (review): a refusal with no life, and a read-back that arrives late but
|
||||
# inside TOOK_S. The base arms at the send and the moved read-back disarms it
|
||||
# ("it moved: alive"); the window must do the same, not arm on the new value.
|
||||
zero = dict(p=0.0, cur=(0.0, 0.0, 0.0))
|
||||
tr, first, ever = play(steady({5: dict(a=10.0)}, **zero), "live", pre=zero)
|
||||
check(f"P4 [live]: no life, the read-back moves at +5, after the refusal was "
|
||||
f"noted: armed dated the send and disarmed by the move, never stuck, "
|
||||
f"as on the base ({tr.armed_at}, {first})", first is None
|
||||
and tr.armed_at is None and not tr.stuck_now and pend(tr) is None)
|
||||
tr, first, ever = play(steady({5: dict(a=10.0)}, **zero), "ring", pre=zero)
|
||||
check(f"P4 [ring]: the read-back moved inside the window BEFORE the refusal "
|
||||
f"was noted (the write waited): it still arms, dated the send, and is "
|
||||
f"stuck at +60, as on the base (armed {tr.armed_at}, first {first})",
|
||||
tr.armed_at == TS and first == TS + 60)
|
||||
# ... and the same read-back arriving AFTER the window leaves it stuck until
|
||||
# it moves: 12 s in, the base has been armed since the send, so it disarms then
|
||||
tr, first, ever = play(steady({12: dict(a=10.0)}, **zero), "live", pre=zero)
|
||||
check("P4 the read-back moves at +12 (after the window): disarmed then, "
|
||||
"never stuck", first is None and tr.armed_at is None)
|
||||
tr, first, ever = play(steady({70: dict(a=10.0)}, **zero), "live", pre=zero)
|
||||
check(f"P4 the read-back moves at +70: stuck at +60 first, as on the base "
|
||||
f"(first {first}-{TS})", first == TS + 60 and tr.armed_at is None)
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n8. N-IDS")
|
||||
# =========================================================================== #
|
||||
|
||||
Reference in New Issue
Block a user