From 6fbf2600f9193f3bdff55264455a76e4546ff549 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 03:19:19 +0100 Subject: [PATCH] EV-20 C19: a held read does nothing to a phase change under way The C17 branch (end a phase change at its 0 A and pause) ran on a held read too, so one failed read just after a select stopped the car for the 600 s phase gap. A held read now leaves the change alone; it goes on at the next real reading. The silent meter still ends it at its 0 A. Rows: test_ev20_rig section 9. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w --- .../DECISIONS/EV-20-solar-mode.md | 6 +++ goodwe_controller/app/carmode.py | 5 +++ goodwe_controller/test_ev20_rig.py | 40 +++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/goodwe_controller/DECISIONS/EV-20-solar-mode.md b/goodwe_controller/DECISIONS/EV-20-solar-mode.md index c5bb9cf..8203fcb 100644 --- a/goodwe_controller/DECISIONS/EV-20-solar-mode.md +++ b/goodwe_controller/DECISIONS/EV-20-solar-mode.md @@ -171,4 +171,10 @@ one small set of facts and derives every path from them: write a NEW 0 A there (no retry to a charger that is not answering). - **Accepted (PM, P9g):** a frozen charger that also stops answering is flagged only once it answers again; the 15 s safe path covers the gap. +- **A held read during a phase change (SPIKE-06 C19):** a phase change under + way does nothing on a held read (no write, no pause) and goes on at the next + real reading; it ends at its 0 A only while the meter is silent (C17). No + phase change begins on a held cycle; a gap of `stale_input_s` or more takes + the safe path unchanged. Accepted by design (PM): a one-sample partial + reading (only power unavailable, say) still gives the D2 0 A. diff --git a/goodwe_controller/app/carmode.py b/goodwe_controller/app/carmode.py index 429e195..38ea06b 100644 --- a/goodwe_controller/app/carmode.py +++ b/goodwe_controller/app/carmode.py @@ -1146,6 +1146,11 @@ class SolarWriter(ManualWriter): gap = self._gap_ok(now) if self.sent_a == 0.0 and not self.taken: self.plan.ok_since = None # 0 A first, then the start rule + if self.seq is not None and self.held_step: + # SPIKE-06 C19: a held read decides nothing for a phase change + # under way (no write, no pause); it goes on at the next real + # reading. A gap that reaches `stale_input_s` takes the safe path. + return if self.seq is not None and self.nz_block: # C17: a phase change under way ends at its 0 A; no select and no # closing current while the meter is silent. The plan pauses and diff --git a/goodwe_controller/test_ev20_rig.py b/goodwe_controller/test_ev20_rig.py index 3532cf0..d6f0826 100644 --- a/goodwe_controller/test_ev20_rig.py +++ b/goodwe_controller/test_ev20_rig.py @@ -673,4 +673,44 @@ for gap_at in (629, 630): f"629 s: 0 A at {z[:1]} (629-630)", present(nth(z, 0)) and 629 <= nth(z, 0) <= 630) +# =========================================================================== # +print("\n9. SPIKE-06 C19: A READ GAP DURING A PHASE CHANGE") +# =========================================================================== # +# The C17 (b) shape without the silent meter: a 1 -> 3 change, its 0 A at +# 301 s, select 3, closing current at 313 s. One to six failed charger reads +# right after the select change nothing: the closing current comes on time +# and no pause follows (0ef8de2: paused, no current until about 914 s). +def phase_run(events): + return S.drive(const(500.0), const(7600.0), dur=700, first="car", + socs={"a": 100.0, "b": 100.0}, car_phases=3, + events=events) + + +for n in (1, 2, 6): + r = phase_run({305: lambda p, c: p.ch.go_unavailable(), + 305 + n: lambda p, c: p.ch.go_unavailable(False)}) + w = cur_writes(r) + close = [(t, a) for t, a, _ in w if a > 0.0 and 301 < t < 700] + check(f"C19: {n} failed read(s) at 305 s, just after the select: the " + f"closing current on time ({close[:2]}), no pause ({w[:5]})", + present(nth(close, 0)) and 312 <= nth(close, 0)[0] <= 313 + n + and [a for t, a, _ in w if 301 < t < 700 and a == 0.0] == []) + nevers(r, f"C19 gap {n}") +# A gap of stale_input_s or more during the change: the safe path as before. +# The charger is taken as gone: nothing while it is away and no closing +# current; on its return the change is dropped and Solar starts over (0 A +# first, already standing here, so nothing is written; then the start rule, +# which on the 3 phases the select left waits for the phase gap). +r = phase_run({305: lambda p, c: p.ch.go_unavailable(), + 322: lambda p, c: p.ch.go_unavailable(False)}) +w = cur_writes(r) +during = [(t, a) for t, a, _ in w if 305 <= t < 322] +after = [(t, a) for t, a, _ in w if t >= 322] +check(f"C19: a 17 s gap during the change takes the safe path: nothing while " + f"away ({during}), no closing current, nothing non-zero before the " + f"start rule after the return ({after[:2]})", + during == [] and not [1 for t, a in after if a > 0.0 and t < 322 + 115] + and r["c"].car_solar.seq is None) +nevers(r, "C19 long gap") + report()