EV-20: SPIKE-05 decisions C1, C6, C9 (brief v5) with rows for C1, C5, C6, C8, C9
C1: an own 0 A not yet read back is kept with the mode; a start in Off with it writes the 0 A (retried), without it nothing; a start that will not write warns once when the charger still has the add-on's current. C6: Solar's 30 s gate also counts from Manual's latest write. C9: an exit also owes its 0 A when the read-back shows Solar's own value. Rows for C5 and C8 too. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -30,7 +30,7 @@ import ev20_sun as S # noqa: E40
|
||||
from chargersim import SimCharger # noqa: E402
|
||||
from ev20_kit import * # noqa: E402,F401,F403
|
||||
from ev20_kit import LOG, check, fails, report # noqa: E402,F401
|
||||
from named_absence import nth, present # noqa: E402,F401
|
||||
from named_absence import given, nth, present # noqa: E402,F401
|
||||
from ev20_kit import (_dies, _err, _freeze_after_write, _shutdown, # noqa: E402,F401
|
||||
_until)
|
||||
|
||||
@@ -589,6 +589,118 @@ check(f"T37: shutdown while the 0 -> 10 A start write waits for its "
|
||||
and [x[2] for x in sim37.log][-1:] == [0.0]
|
||||
and sim37.setpoint_a == 0.0)
|
||||
|
||||
# C1 (SPIKE-05, brief v5): a start-up after a stop with no release.
|
||||
import opt11_identity as rig # noqa: E402
|
||||
|
||||
|
||||
def _store(mode, pending=None):
|
||||
st = rig._Store()
|
||||
st.data["car_mode"] = mode
|
||||
if pending is not None:
|
||||
st.data[ctl_car.CAR_EXIT_KEY] = pending
|
||||
return st
|
||||
|
||||
|
||||
for pending, name in ((True, "Off, flag set, charger at 10 A -> 0 A written"),
|
||||
(False, "Off, no flag -> nothing")):
|
||||
simc = TSim(setpoint_a=10, windows=[(0.0, 2.5, "error")])
|
||||
rr = std(200, sim=simc, mode="off", store=_store("off", pending))
|
||||
w = cur_writes(rr)
|
||||
if pending:
|
||||
check(f"C1 [{name}]: the 0 A at the first reading, refused, tried "
|
||||
f"again 60 s later and taken; the flag cleared ({w})",
|
||||
[(round(t), a, ok) for t, a, ok in w]
|
||||
in ([(0, 0.0, False), (60, 0.0, True)],
|
||||
[(1, 0.0, False), (61, 0.0, True)])
|
||||
and simc.setpoint_a == 0.0
|
||||
and rr["store"].data.get(ctl_car.CAR_EXIT_KEY) is False)
|
||||
else:
|
||||
check(f"C1 [{name}]: nothing written (N10) ({simc.log})",
|
||||
simc.log == [] and simc.setpoint_a == 10.0)
|
||||
# The PM's shape: Solar at 10 A, Off whose 0 A is refused, a power cut before
|
||||
# the retry; the restart (keep) in Off writes the 0 A.
|
||||
simp = TSim(setpoint_a=0, windows=[(300.0, 1e9, "error")])
|
||||
rp = std(330, sim=simp, events={300: act("car_mode", "off")})
|
||||
flag = rp["store"].data.get(ctl_car.CAR_EXIT_KEY)
|
||||
simp.windows = []
|
||||
n0 = len(simp.log)
|
||||
rq = std(100, sim=simp, store=rp["store"], mode="off")
|
||||
new = [(x[0], x[2]) for x in simp.log[n0:]]
|
||||
check(f"C1: Off whose 0 A was refused, a power cut before its retry: the flag "
|
||||
f"is kept ({flag}), and the restart in Off writes the 0 A at once "
|
||||
f"({new})", flag is True and new[:1] and new[0][1] == 0.0
|
||||
and simp.setpoint_a == 0.0)
|
||||
# Shadow or control stopped at the start: no write, one warning.
|
||||
for stored, opts, ev, warn in (
|
||||
("solar", {"shadow_mode": "on"}, {}, True),
|
||||
("manual", {"shadow_mode": "on"}, {}, True),
|
||||
("solar", {"shadow_mode": "auto"},
|
||||
{0: lambda p, c: setattr(c, "auto", False)}, True),
|
||||
("off", {"shadow_mode": "on"}, {}, False)):
|
||||
n = LOG.mark()
|
||||
simw = SimCharger(setpoint_a=10)
|
||||
rr = std(120, sim=simw, opts=opts, events=ev, mode=stored)
|
||||
wl = [m for m in LOG.since(n, "WARNING") if "CHARGER_START_CURRENT" in m]
|
||||
notes_ = [x for _, x in rr["raised"] if x == messages.ID_CAR_START]
|
||||
check(f"C1 [stored {stored}, {opts.get('shadow_mode')}"
|
||||
f"{', stopped' if ev else ''}]: nothing written; "
|
||||
f"{'one warning' if warn else 'no warning'} "
|
||||
f"({len(wl)} log, {len(notes_)} notice)",
|
||||
simw.log == [] and len(wl) == (1 if warn else 0)
|
||||
and len(notes_) == (1 if warn else 0))
|
||||
check("C1: the warning's words, EN and NL",
|
||||
messages.car_start_current("10").body
|
||||
== "Charger still at 10 A from before the restart."
|
||||
and "10 A" in messages.car_start_current("10").body_nl)
|
||||
|
||||
# C5: each shutdown try waits at most 4 s for its read-back, so three fit in
|
||||
# 15 s against a charger that ignores the write.
|
||||
sim5 = TSim(setpoint_a=0, windows=[(299.5, 1e9, "ignore")])
|
||||
r5 = run("C5", std, 300, sim=sim5, finale=_shutdown)
|
||||
tr5 = [t for t, v in attempts(r5) if t >= 299]
|
||||
check(f"C5: a charger that ignores the 0 A: three tries ({tr5}) about 5 s "
|
||||
f"apart, each waiting 4 s at most, the inverters by 15 s "
|
||||
f"(+{_until(r5, 299.0)})",
|
||||
len(tr5) == 3 and all(4.0 <= b - a <= 6.0 for a, b in zip(tr5, tr5[1:]))
|
||||
and present(given(_until(r5, 299.0)))
|
||||
and _until(r5, 299.0) <= 15.0)
|
||||
|
||||
# C8: a charger outage in the middle of a phase change ends it; the first
|
||||
# write after the return is never a current (N12).
|
||||
for stage, dt in (("zero", 2), ("settle", 6)):
|
||||
sim8 = SimCharger(setpoint_a=0)
|
||||
sim8.ramp_w_s = 600.0
|
||||
rr = std(900, sun=step_fn((400, 600.0 + 4500.0), base=600.0 + 3000.0),
|
||||
sim=sim8, events={580 + dt: lambda p, c: p.ch.go_unavailable(True),
|
||||
620: lambda p, c: p.ch.go_unavailable(False)})
|
||||
w = [(t, a) for t, a, _ in cur_writes(rr) if t >= 620]
|
||||
check(f"C8 [{stage}]: the charger away from 580 + {dt} s to 620 s: the "
|
||||
f"sequence ends, nothing of it resumes: before the start rule's "
|
||||
f"120 s from the return only a 0 A may be written (here the "
|
||||
f"charger came back at the sequence's 0 A) ({w})",
|
||||
not [a for t, a in w if a > 0.0 and t < 740.0]
|
||||
and rr["trace"][625]["sp"] == 0.0)
|
||||
|
||||
# C9: Solar's 6 A lands late, then its 0 A pause is refused, then Off: the
|
||||
# exit 0 A and its retry still come (decided from the read-back).
|
||||
sim9 = SimCharger(setpoint_a=0)
|
||||
r9 = std(500, sim=sim9, sun=step_fn((190, 600.0 + 700.0),
|
||||
base=600.0 + 2300.0),
|
||||
opts={"ev_pause_min": 1},
|
||||
events={185: lambda p, c: setattr(p.ch, "lag_s", 12.0),
|
||||
205: lambda p, c: setattr(p.ch, "lag_s", 0.0),
|
||||
249: lambda p, c: setattr(p.ch, "refuse", "error"),
|
||||
255: act("car_mode", "off"),
|
||||
257: lambda p, c: setattr(p.ch, "refuse", None)})
|
||||
w9 = cur_writes(r9)
|
||||
z9 = [(t, ok) for t, a, ok in w9 if a == 0.0]
|
||||
check(f"C9: the 6 A late, the pause's 0 A refused, then Off: the 0 A is "
|
||||
f"tried again 60 s after the refusal and taken; the charger ends at "
|
||||
f"0 A ({w9})",
|
||||
len(z9) == 2 and present(nth(z9, 0)) and nth(z9, 0)[1] is False
|
||||
and nth(z9, 1)[1] is True and 59 <= nth(z9, 1)[0] - nth(z9, 0)[0] <= 61
|
||||
and sim9.setpoint_a == 0.0)
|
||||
|
||||
# T61: the start-up in Solar after a stop with no release.
|
||||
for k, sp, kw in (("10 A, keep", 10, {}),
|
||||
("16 A by another writer", 16, {}),
|
||||
|
||||
Reference in New Issue
Block a user