EV-05 round 3: a refused way-out 0 A is tried again; one cut per excess
Review of 17a7b29:
- Critical: every way out of Solar (Off, Stop, shadow, safety stop, charger
error, stuck reading, no car) now owes a 0 A until the charger takes it:
tried again 60 s apart, 3 times (EV-04's rule), then the gave-up row and
CHARGER_REFUSED; never over another writer. Shutdown does not trust last_a
while a write of ours is unconfirmed. The card no longer says paused while
the 0 A is not taken.
- Major: an excess episode is taken off the car once, measured from the car's
power when it began, until the car shows it and 15 s more.
Tests: refused-then-accepted 0 A for each exit, a 0 A never taken, shutdown
during a start write's read-back, a cut from 16 A with a slow car; the fuzz
checks refused exits of every kind (N9).
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -271,14 +271,18 @@ def fuzz(seed):
|
||||
st = {"sun": rnd.uniform(0, 9000), "house": rnd.uniform(200, 3000),
|
||||
"n": {}, "acts": [], "undo": [], "exits": []}
|
||||
|
||||
def exit_check(p, c):
|
||||
"""N9: Solar to Off with the charger above 0 A, reachable, taking
|
||||
writes and not held by another writer: a 0 A must follow."""
|
||||
def exit_check(p, c, kind="off"):
|
||||
"""N9: a way out of Solar (Off, Stop, shadow) with the charger above
|
||||
0 A, reachable and not held by another writer. Round 3: also while
|
||||
the charger refuses writes (judged after the refusal ends)."""
|
||||
ch = p.ch
|
||||
if c.car_mode == "solar" and not c.car_solar.hold \
|
||||
and not ch.unavailable and ch.refuse is None \
|
||||
and ch.readback_a > 0.5 and not p.ha_down:
|
||||
st["exits"].append(p.t)
|
||||
if c.car_mode == "solar" and c.car_writing() and not c.car_solar.hold \
|
||||
and not ch.unavailable and ch.readback_a > 0.5 \
|
||||
and not p.ha_down:
|
||||
st["exits"].append((p.t, kind, ch.refuse))
|
||||
|
||||
def at(t, fn):
|
||||
st["undo"].append((t, fn))
|
||||
|
||||
def later(p, fn):
|
||||
st["undo"].append((p.t + rnd.randint(10, 40), fn))
|
||||
@@ -325,10 +329,12 @@ def fuzz(seed):
|
||||
later(p, lambda: setattr(p, "meter_on", True))
|
||||
st["n"]["meter"] = st["n"].get("meter", 0) + 1
|
||||
elif r < 0.093:
|
||||
exit_check(p, c, "out")
|
||||
c.o["shadow_mode"] = "on"
|
||||
later(p, lambda: c.o.__setitem__("shadow_mode", "off"))
|
||||
st["n"]["shadow"] = st["n"].get("shadow", 0) + 1
|
||||
elif r < 0.095:
|
||||
exit_check(p, c, "out")
|
||||
c.auto = False
|
||||
later(p, lambda: setattr(c, "auto", True))
|
||||
st["n"]["stop"] = st["n"].get("stop", 0) + 1
|
||||
@@ -341,6 +347,28 @@ def fuzz(seed):
|
||||
return c.handle_action("car_mode", value=m)
|
||||
elif r < 0.1:
|
||||
ch.station_a = rnd.choice(stations)
|
||||
elif r < 0.1015 and c.car_mode == "solar" and c.car_writing() \
|
||||
and p.ch.readback_a > 0.5 and st.get("back") is None \
|
||||
and not p.ch.unavailable and p.ch.refuse is None:
|
||||
# Round 3: the charger refuses for 5 s, and a way out comes now
|
||||
# and stands 100-150 s.
|
||||
kind = rnd.choice(["off", "stop", "shadow"])
|
||||
p.ch.refuse = rnd.choice(["error", "ignore"])
|
||||
at(p.t + 5, lambda: setattr(p.ch, "refuse", None))
|
||||
exit_check(p, c, "off" if kind == "off" else "out")
|
||||
stay = rnd.randint(100, 150)
|
||||
st["n"]["refused_exit_made"] = \
|
||||
st["n"].get("refused_exit_made", 0) + 1
|
||||
if kind == "stop":
|
||||
c.auto = False
|
||||
at(p.t + stay, lambda: setattr(c, "auto", True))
|
||||
elif kind == "shadow":
|
||||
c.o["shadow_mode"] = "on"
|
||||
at(p.t + stay, lambda: c.o.__setitem__("shadow_mode", "off"))
|
||||
else:
|
||||
st["acts"].append(p.t)
|
||||
st["back"] = p.t + stay
|
||||
return c.handle_action("car_mode", value="off")
|
||||
elif r < 0.103 and c.car_mode == "solar" and p.ch.readback_a > 0.5 \
|
||||
and st.get("back") is None:
|
||||
exit_check(p, c) # leave Solar while it charges
|
||||
@@ -355,6 +383,7 @@ def fuzz(seed):
|
||||
|
||||
def note(p, c, t):
|
||||
ctx.append((t, c.car_mode, c.car_writing(), c.car_solar.single,
|
||||
p.ch.refuse, p.ch.unavailable, p.ch.setpoint_a,
|
||||
c.car_solar.hold, p.ch.station_a))
|
||||
r = S.drive(house=lambda t: st["house"], sun=lambda t: st["sun"],
|
||||
first="car", opts={"ev_margin_w": 0, "ev_start_min": 1,
|
||||
@@ -370,7 +399,7 @@ def fuzz(seed):
|
||||
# A write logged at second t comes after that second's actions.
|
||||
x = by_t.get(t) or by_t.get(t - 1)
|
||||
mode = x[1] if x else "?"
|
||||
if what == "current" and v > min(16.0, x[5] if x else 16.0) + 1e-9:
|
||||
if what == "current" and v > min(16.0, x[8] if x else 16.0) + 1e-9:
|
||||
bad.append(("N1 over the clamp", t, v))
|
||||
if what == "phases":
|
||||
if sp != 0.0:
|
||||
@@ -388,10 +417,27 @@ def fuzz(seed):
|
||||
if last_nz is not None and t - last_nz < 30 and not near_act:
|
||||
bad.append(("N5 two non-zero writes under 30 s", t, v))
|
||||
last_nz = t
|
||||
for te in st["exits"]:
|
||||
if not any(x[1] == "current" and x[2] == 0.0 and te <= x[0] <= te + 3
|
||||
for x in log):
|
||||
bad.append(("N9 Solar to Off left the current up", te))
|
||||
for te, kind, ref in st["exits"]:
|
||||
if ref is None:
|
||||
if not any(x[1] == "current" and x[2] == 0.0
|
||||
and te <= x[0] <= te + 3 for x in log):
|
||||
bad.append(("N9 a way out left the current up", te, kind))
|
||||
continue
|
||||
# Round 3: the charger refused when the way out came. Judged when the
|
||||
# refusal ended within 60 s and the way out still stands 80 s on (the
|
||||
# 0 A is tried again 60 s after the first try, +10 s read-back).
|
||||
span = [x for x in ctx if te <= x[0] <= te + 80]
|
||||
ends = next((x[0] for x in span if x[4] is None), None)
|
||||
still = len(span) >= 80 and all(
|
||||
(x[1] == "off" if kind == "off" else
|
||||
(x[1] == "solar" and not x[2])) and not x[5] and not x[7]
|
||||
for x in span)
|
||||
if ends is None or ends > te + 60 or not still:
|
||||
continue
|
||||
st["n"]["refused_exits"] = st["n"].get("refused_exits", 0) + 1
|
||||
if not any(x[6] <= 0.5 for x in span): # reached 0 A in it
|
||||
bad.append(("N9 a refused way-out 0 A was not tried again", te,
|
||||
kind))
|
||||
if r["c"].charger.clamp_faults:
|
||||
bad.append(("N1 clamp fault", r["c"].charger.clamp_faults))
|
||||
st["n"]["exits"] = len(st["exits"])
|
||||
@@ -412,10 +458,12 @@ check(f"T45: {fz_n} charger writes over 14 random Solar sites and 16800 steps "
|
||||
f"non-zero write in Off, in shadow "
|
||||
f"or stopped, none under 30 s apart ({fz_bad[:3]})",
|
||||
not fz_bad and fz_n > 100)
|
||||
check(f"T45: each disturbance happened ({fz_counts})",
|
||||
check(f"T45: each disturbance happened, and exits while the charger refused "
|
||||
f"were judged ({fz_counts})",
|
||||
all(fz_counts.get(k, 0) > 2 for k in ("plug", "down", "other", "meter",
|
||||
"shadow", "stop", "mode",
|
||||
"exits")))
|
||||
"exits"))
|
||||
and fz_counts.get("refused_exits", 0) >= 1)
|
||||
|
||||
print()
|
||||
if fails:
|
||||
|
||||
Reference in New Issue
Block a user