EV-21 fix round 1 (formal round 4): C14 cut due while batteries charge; C15 grace once per value
C14 (PM Q2): slowing a battery charge counts as the batteries taking more, so the cut is due whatever the batteries do; their charge counts only as headroom for the 15 s wait. C15 (PM Q1): sent_at is renewed only for a new value, so a retry of a refused cut gets no new 2 s grace. test_ev21_fix1.py: both red on 36e9dd7; C16, C18 and Q1's other writer pinned as the code has them. Test shapes: slow batteries and refusals start after Solar's own start, which C14 would otherwise cut on its start blip; T38 cover off from 300 s; T46 bounds the excess; T39 counts writes after the cut. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -126,7 +126,10 @@ def shape(kind, *, step=960, mode="solar", first="car", n=2, cover=True,
|
||||
o = dict({"ev_phases": "3", "ev_batt_cover": cover}, **(opts or {}))
|
||||
ev = dict(events or {})
|
||||
if kind in ("W", "S"):
|
||||
ev = merge(ev, 0, set_resp(20.0))
|
||||
# Slow batteries from 60 s before the step: Solar's own start at
|
||||
# 120 s runs on quick ones (with slow ones its own start blip lasts
|
||||
# past the 15 s wait and is cut, PM Q2 / formal C14).
|
||||
ev = merge(ev, max(0, int(step) - 60), set_resp(20.0))
|
||||
sp = setpoint if setpoint is not None else (car_a if mode != "solar"
|
||||
else 0)
|
||||
if kind == "F" and sun_w is None:
|
||||
@@ -168,6 +171,13 @@ def _mode(units, on):
|
||||
return f
|
||||
|
||||
|
||||
class NoGive(S.SunPlant):
|
||||
"""Every battery refuses to give: the plant gives min(command, 0)."""
|
||||
|
||||
def batt_of(self, u, at):
|
||||
return min(super().batt_of(u, at), 0.0)
|
||||
|
||||
|
||||
def refuse_n1(p, c):
|
||||
"""N=1: the sole battery refuses to give (SAFETY-73's latch, held)."""
|
||||
c.batt_refused, c.batt_refused_at = 1, p.t
|
||||
@@ -180,9 +190,11 @@ def near_end(step, *, n=2, house_after=3000.0, sun_back=None, dur=1800,
|
||||
modes until 1500; N=1: the battery refuses to give throughout), then the
|
||||
sun is back and Solar starts the car at 10 A on 3 phases; at `step` the
|
||||
sun goes and the house is `house_after`. The batteries (N=2: 60 %) take
|
||||
20 s to respond. `sun_back`: the sun returns then."""
|
||||
20 s to respond from 30 s before the step (Solar's own start runs on
|
||||
quick ones: PM Q2 / formal C14 would cut its own start blip otherwise).
|
||||
`sun_back`: the sun returns then."""
|
||||
ev = dict(kw.pop("events", None) or {})
|
||||
ev = merge(ev, 0, set_resp(20.0))
|
||||
ev = merge(ev, max(0, int(step) - 30), set_resp(20.0))
|
||||
if n == 2:
|
||||
ev = merge(merge(ev, 899, _mode("ab", False)), 1500,
|
||||
_mode("ab", True))
|
||||
@@ -192,6 +204,9 @@ def near_end(step, *, n=2, house_after=3000.0, sun_back=None, dur=1800,
|
||||
ev = merge(ev, t, refuse_n1)
|
||||
ratings = {"a": 5000.0}
|
||||
kw.setdefault("rows", False)
|
||||
# The harness plant gives what it is asked; a refusing battery
|
||||
# gives nothing (it still takes a charge).
|
||||
kw.setdefault("plant_cls", NoGive)
|
||||
house = step_fn((900, 3350.0), (1500, 900.0), (step, house_after),
|
||||
*house_more, base=900.0)
|
||||
pairs = [(900, 0.0), (1500, 7900.0), (step, 0.0)]
|
||||
|
||||
Reference in New Issue
Block a user