EV-20 review round 2: one write clock for every non-zero current (C6, N5)
checks / unit (pull_request) Successful in 30m56s
infra-pin / fresh (pull_request) Successful in 2s

ManualWriter._write, the one write_current call, stamps every non-zero
current either writer sends; Solar's 30 s gate reads that stamp (its own and
Manual's), so the step back up after a phase change's closing write waits 30
s on every path. The closing current is fixed once per sequence, retries too.
Rows: every select shape (refused, ignored, late; settle refused three times;
T7 1 -> 3 and T22 3 -> 1) with nevers().

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
Claude
2026-11-23 01:25:06 +01:00
parent 9c82bc816a
commit cd8c393161
3 changed files with 81 additions and 8 deletions
+58
View File
@@ -728,6 +728,64 @@ for how, sim_ in (("settle write refused once",
and rm1["sim"].phases_allowed == 3
and rm1["sim"].setpoint_a == 10.0)
nevers(rm1, f"T19/T33 [{how}]")
# Review round 2 (C6, N5): every select shape, 1 -> 3 (T7) and 3 -> 1 (T22):
# no current meant for fewer phases than the charger has, and never two
# different non-zero currents under 30 s apart (the one write clock).
class PhSim(TSim):
"""The phases select: 'lag' (read-back 12 s late), 'error' (HA refuses
it), 'ignore' (HA says yes, the charger keeps its phases)."""
ph_mode = None
def request_phases(self, n):
if self.ph_mode == "lag":
keep, self.lag_s = self.lag_s, 12.0
try:
return super().request_phases(n)
finally:
self.lag_s = keep
keep, self.refuse = self.refuse, self.ph_mode or self.refuse
try:
return super().request_phases(n)
finally:
self.refuse = keep
def _phsim(windows=(), ph=None):
s_ = PhSim(setpoint_a=0, windows=list(windows))
s_.ph_mode = ph
return s_
sun31 = step_fn((300, 600.0 + 4600.0), (700, 600.0 + 3700.0),
base=600.0 + 3000.0)
for how, shape, sim_, back in (
("select refused", "T7", _phsim(ph="error"), 16.0),
("select ignored", "T7", _phsim(ph="ignore"), 16.0),
("select late", "T7", _phsim(ph="lag"), 10.0),
("settle refused 3 times", "T7", _phsim([(313, 330, "error")]), None),
("normal", "T22", _phsim(), None),
("select refused", "T22", _phsim(ph="error"), None),
("select ignored", "T22", _phsim(ph="ignore"), None),
("select late", "T22", _phsim(ph="lag"), None)):
if shape == "T7":
rs_ = S.drive(const(900.0), const(7900.0), dur=900, sim=sim_,
first="car", socs={"a": 71.0, "b": 100.0})
cap3 = 10.0
else:
rs_ = S.drive(const(600.0), sun31, dur=1500, sim=sim_, first="car",
socs={"a": 19.0, "b": 19.0})
cap3 = 5.0 # 3700 - 600 - 100 W on 3 phases, under 6 A
over = [(x["t"], x["sp"]) for x in rs_["trace"]
if x["ph"] == 3 and x["sp"] > max(cap3, 6.0) and x["t"] > 300]
bad_ = nevers(rs_, f"round 2 [{shape}, {how}]")
end = rs_["trace"][-1]
check(f"round 2 [{shape}, {how}]: no current meant for fewer phases on "
f"the charger's ({over[:3]}); end {end['sp']} A on {end['ph']} "
f"phases ({[(x[0], x[1], x[2]) for x in rs_['sim'].log]})",
not over and not bad_
and (back is None or (end["sp"] == back)))
r19a = std(1800, sun=const(600.0 + 6900.0), opts={"ev_phases": "1"})
check(f"T19: fixed 1 with 6.9 kW for 30 min: no select, 16 A "
f"({cur_writes(r19a)})", selects(r19a) == []