diff --git a/goodwe_controller/DECISIONS/EV-20-solar-mode.md b/goodwe_controller/DECISIONS/EV-20-solar-mode.md index 8518943..3407b49 100644 --- a/goodwe_controller/DECISIONS/EV-20-solar-mode.md +++ b/goodwe_controller/DECISIONS/EV-20-solar-mode.md @@ -126,9 +126,11 @@ one small set of facts and derives every path from them: - A frozen POWER under an accepted write (the read-back moves) is no longer judged here: the energy meter (EV-18 `contradicted`) and the read-back cap on the trusted figure judge it. -- **Solar after a stuck verdict (C12):** once Solar's own 0 A stands - (written and taken), a stuck verdict no longer holds the car at 0 A; the - start rule runs. Its write moves the reading (the verdict clears) or is +- **Solar after a stuck verdict (C12, C14):** while no current of Solar's + own may stand (its own 0 A stands, or Solar was just chosen), a stuck + verdict no longer holds Solar: it writes its 0 A first over a current that + is not its own, then the start rule runs; at most MAX_TRIES starts per + verdict, then CHARGER_REFUSED until Solar is pressed. Its write moves the reading (the verdict clears) or is refused (EV-04's retries, then CHARGER_REFUSED). - **No amp ping-pong:** after a step down, a step back up needs `UP_HYST_W` (100 W) past the amp boundary. diff --git a/goodwe_controller/app/carmode.py b/goodwe_controller/app/carmode.py index 2996fca..9f2302b 100644 --- a/goodwe_controller/app/carmode.py +++ b/goodwe_controller/app/carmode.py @@ -1044,13 +1044,14 @@ class SolarWriter(ManualWriter): if self.stuck_starts >= MAX_TRIES and self.gave_up: self.gave_up = False # the reading moved: start afresh self.stuck_starts = 0 - if fault == "stuck" and self.taken and self.sent_a is not None \ - and self.sent_a <= TOL_A: - # SPIKE-06 C12 (option 2): Solar's own 0 A stands, so a stuck - # verdict no longer holds the car at 0 A; the start rule runs. Its - # write moves the reading (the verdict clears) or is not taken: - # then the 0 A again, and after MAX_TRIES such starts under one - # verdict, CHARGER_REFUSED and the 0 A stands (EV-04's rule). + if fault == "stuck" and not self.live: + # SPIKE-06 C12/C14 (option 2): no current of Solar's own may stand + # (its own 0 A stands, or Solar was just chosen), so a stuck + # verdict no longer holds the car: Solar's normal step writes its + # 0 A first over a current that is not its own, then the start + # rule. A start moves the reading (the verdict clears) or is not + # taken: then the 0 A again, and after MAX_TRIES such starts under + # one verdict, CHARGER_REFUSED and the 0 A stands (EV-04's rule). if self.stuck_starts < MAX_TRIES: fault = None elif not self.gave_up: diff --git a/goodwe_controller/test_ev13.py b/goodwe_controller/test_ev13.py index f4b71ae..45d4ece 100644 --- a/goodwe_controller/test_ev13.py +++ b/goodwe_controller/test_ev13.py @@ -658,8 +658,13 @@ for TO_A in (8, 6): check(f"T14 [{TO_A} A] ...the write was accepted", res[0][2] is True) if TO_A == 6: check(f"T14 [6 A] the energy meter flags the frozen figure (EV-18) " - f"within 120 s of the write (+{rel})", - rel is not None and rel <= 120) + f"at about +57 s after the write (+{rel})", + rel is not None and 50 <= rel <= 65) + else: + # The frozen figure is exactly 2x the real draw: CORR_RATIO 0.5 is + # not undercut, so EV-18 never flags it (PM accepted, SPIKE-06). + check(f"T14 [8 A] the energy meter does NOT flag the frozen figure " + f"(+{rel}); only the read-back cap bounds it", rel is None) async def t17(): @@ -681,6 +686,9 @@ w, res, cs = run(t17()) T17_S = contra_report("T17 live refusals, then an ACCEPTED write to 12 A " "under a frozen power", res[-1][0], cs, 12 * CH.CEILING_V * 3) +check(f"T17 the energy meter does NOT flag the frozen figure (+{T17_S}); " + f"only the read-back cap bounds it (PM accepted, SPIKE-06)", + T17_S is None) check("T17 ...the last write was accepted, after the refusals", res[-1][2] is True and res[0][2] is False) @@ -704,6 +712,9 @@ w, res, cs = run(t18()) T18_S = contra_report("T18 an ACCEPTED write to 12 A under a frozen power, a " "refusal 20 s later", res[0][0], cs, 12 * CH.CEILING_V * 3) +check(f"T18 the energy meter does NOT flag the frozen figure (+{T18_S}); " + f"only the read-back cap bounds it (PM accepted, SPIKE-06)", + T18_S is None) check("T18 ...the second write was refused", len(res) >= 2 and res[1][2] is False) diff --git a/goodwe_controller/test_ev20_rig.py b/goodwe_controller/test_ev20_rig.py index eb9940b..d1ce379 100644 --- a/goodwe_controller/test_ev20_rig.py +++ b/goodwe_controller/test_ev20_rig.py @@ -378,6 +378,34 @@ check(f"C12 bound: a frozen charger after Solar's own 0 A: at most 3 starts " and [a for t, a, _ in w if t0 <= t < 1200][-1:] == [0.0]) nevers(r, "C12 bound") +# C14: Manual's refused writes leave a stuck verdict on a paused, live car, +# then the user presses Solar. No current of Solar's own may stand, so the +# verdict does not hold Solar: its 0 A first (over Manual's 6 A), then the +# start rule with spare sun; the start moves the reading, the verdict clears. +for name, win, t_s in (("Manual's 12 A refused 3 times, Solar at 400 s", + (99.5, 250.0), 400),): + sim = TSim(setpoint_a=0, windows=[(win[0], win[1], "ignore")]) + sim.car_full() + seen = {} + r = S.drive(const(500.0), const(2900.0), dur=1200, first="car", + socs={"a": 100.0, "b": 100.0}, sim=sim, mode="manual", + events={100: act("car_current", 12), + t_s - 1: lambda p, c: seen.update( + armed=c.car.armed_at, stuck=c.car.stuck_now), + t_s: act("car_mode", "solar")}) + w = cur_writes(r) + nz = [(t, a) for t, a, _ in w if a > 0.0] + check(f"C14 [{name}]: the check armed by Manual's refusal before the " + f"press ({seen})", seen.get("armed") is not None) + check(f"C14 [{name}]: Solar writes 0 A first, then a start within the " + f"start rule, and the verdict clears ({w[:4]}, stuck now " + f"{r['c'].car.stuck_now})", + present(nth(w, 0)) and nth(w, 0)[1] == 0.0 + and nth(w, 0)[0] <= t_s + 2 and present(nth(nz, 0)) + and nth(nz, 0)[0] <= t_s + 125 and not r["c"].car.stuck_now + and r["trace"][-1]["fault"] is None) + nevers(r, f"C14 [{name}]") + # C13: a car that draws less than allowed (an on-board limit of 1380 W, or a # taper). Tracker level: a raise 6 -> 10 A, the post-write reading filed # during the wait (race) or not: never stuck.