EV-20 review r3: a held read moves no plan count; only the meter-age pause may fire
On a held charger read no writer steps and the Solar plan does nothing: no phase change or switching start begins, no _set or end_switch, ok_since, up_since, down_since, low_since and set_at stay, and the hold pause does not fire; a decision due then runs on the next real reading. The one exception is the pause by the meter's age (C18, SolarWriter.held_pause). Rows: the reviewer's three shapes with 1- and 2-read gaps on and before the decision cycle, and the hold pause on a held cycle. DECISIONS wording fixed. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -713,4 +713,78 @@ check(f"C19: a 17 s gap during the change takes the safe path: nothing while "
|
||||
and r["c"].car_solar.seq is None)
|
||||
nevers(r, "C19 long gap")
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n10. REVIEW R3: A HELD READ ON A DECISION CYCLE (PM design)")
|
||||
# =========================================================================== #
|
||||
# The reviewer's three shapes (house 500 W, Car first, 3-phase car). A 1- or
|
||||
# 2-sample read gap on the cycle a phase change or a switching start is due,
|
||||
# or on the cycle before it: the decision waits for the next real reading and
|
||||
# every write lands within 2 s of the run without the gap (a60ebd3: the wait
|
||||
# restarted, and 3 -> 1 became a 0 A pause in full sun).
|
||||
def sun_b(t):
|
||||
return 7600.0 if t < 1000 else (300.0 if t < 1400 else 2600.0)
|
||||
|
||||
|
||||
SHAPES = (("A 1 -> 3", const(7600.0), 700, 301),
|
||||
("B a start that needs 3 -> 1", sun_b, 1900, 1521),
|
||||
("C 3 -> 1", lambda t: 7600.0 if t < 1000 else 4300.0, 1700, 1301))
|
||||
|
||||
|
||||
def shape_run(sunf, dur, events=None):
|
||||
return S.drive(const(500.0), sunf, dur=dur, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, car_phases=3,
|
||||
events=events or {})
|
||||
|
||||
|
||||
def after(r, t0, t1):
|
||||
return [(t, a) for t, a, _ in cur_writes(r) if t0 <= t < t1]
|
||||
|
||||
|
||||
for name, sunf, dur, d in SHAPES:
|
||||
twin = after(shape_run(sunf, dur), d - 5, d + 200)
|
||||
for off in (-1, 0):
|
||||
for n in (1, 2):
|
||||
g = d + off
|
||||
r = shape_run(sunf, dur,
|
||||
{g: lambda p, c: p.ch.go_unavailable(),
|
||||
g + n: lambda p, c: p.ch.go_unavailable(False)})
|
||||
got = after(r, d - 5, d + 200)
|
||||
same = (len(got) == len(twin) and all(
|
||||
a1 == a2 and abs(t1 - t2) <= 2.0
|
||||
for (t1, a1), (t2, a2) in zip(got, twin)))
|
||||
check(f"review r3 [{name}] {n}-read gap at {g} (decision due "
|
||||
f"{d}): the writes of the run without the gap, within 2 s "
|
||||
f"({got[:4]} vs {twin[:4]})", same and bool(twin))
|
||||
nevers(r, f"review r3 [{name}] gap {n} at {g}")
|
||||
|
||||
# The hold's pause (low_since past ev_pause_min) never fires on a held cycle:
|
||||
# it comes on the next real reading, and only if that reading still says low.
|
||||
base = S.drive(const(500.0), lambda t: 900.0 if t >= 400 else 2900.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_phases": "1"})
|
||||
z0 = nth([t for t, a, _ in cur_writes(base) if a == 0.0 and t > 400], 0)
|
||||
check(f"hold twin: 0 A at {z0} (300 s from the drop at 400, +2)",
|
||||
present(z0) and 699 <= z0 <= 702)
|
||||
if present(z0):
|
||||
zi = int(z0)
|
||||
r = S.drive(const(500.0), lambda t: 900.0 if t >= 400 else 2900.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_phases": "1"},
|
||||
events={zi: lambda p, c: p.ch.go_unavailable(),
|
||||
zi + 1: lambda p, c: p.ch.go_unavailable(False)})
|
||||
z = [t for t, a, _ in cur_writes(r) if a == 0.0 and t > 400]
|
||||
check(f"hold pause due on a held read ({zi}): 0 A on the next real "
|
||||
f"reading ({z[:1]}), not on the held cycle",
|
||||
present(nth(z, 0)) and nth(z, 0) == zi + 1)
|
||||
r = S.drive(const(500.0),
|
||||
lambda t: 900.0 if 400 <= t < zi else 2900.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_phases": "1"},
|
||||
events={zi: lambda p, c: p.ch.go_unavailable(),
|
||||
zi + 1: lambda p, c: p.ch.go_unavailable(False)})
|
||||
z = [t for t, a, _ in cur_writes(r) if a == 0.0 and t > 400]
|
||||
check(f"hold pause due on a held read ({zi}), the sun back from that "
|
||||
f"second, so the next real reading ({zi + 1}) is not low: no pause "
|
||||
f"({z[:1]})", z == [])
|
||||
|
||||
report()
|
||||
|
||||
Reference in New Issue
Block a user