"""EV-54: the drop rule. A cut value the charger did not take is never sent again once no cut stands: Solar takes the read-back as its own (sent, taken, the plan's current), and the next cut try is a new episode's. `python3 -B test_ev54_drop.py` Rows T14 and T25-T35 of reports/EV-54-test-plan.md (G1-G6, QA, QB, QC) and the writer-level replay of the formal check's C4. The real Controller on `tools/ev20_sun.py` through `tools/ev54_kit.py`; Shape C as in test_ev54.py. Golden values marked bdfd3e6 were taken on that tree with `EV54_GOLDEN=1 python3 -B test_ev54_drop.py`. Mutating a module this file grades? Read MUTATION.md first (purge __pycache__). """ import asyncio import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(HERE, "tools")) import ev20_sun as S # noqa: E402 from app import carmode, messages # noqa: E402 from ev20_kit import LOG, check, fails, act, step_fn # noqa: E402 from ev21_kit import ALARMS, NoGive, refuse_n1, merge, set_resp # noqa: E402 from ev54_kit import (HOLD_TEXT, as_off, cut_writes, dropped, first, # noqa: E402 house_c, key_change, never54, nth, present, refused_by_key, row, rows, run, sun_c, t_lift, twin, window, writes) n_log0 = LOG.mark() TAKE = os.environ.get("EV54_GOLDEN") == "1" CUT = messages.ID_CAR_CUT GOLDEN = { 'T35 (b)': [], 'T35 (c)': ([(1020.0, 0.0, True)], ['Car: set from 10 A to 0 A on 3 phases (peak cut).']), } def golden(name, value): if TAKE: print(f"GOLDEN {name!r}: {value!r},") return GOLDEN.get(name) def refused(r, t0=0, t1=1e9): return [(t, a) for t, a, ok, _why, _k in cut_writes(r, t0, t1) if not ok] def near(t, want, lo, hi): return t is not None and present(t) and want - lo <= t <= want + hi def gave_up_at(r, t0=0, t1=1e9): return [x["t"] for x in rows(r, t0, t1) if x["gave_up"]] def stick(p, c): """The charger's reading freezes and the tracker's stuck check is armed now: a stuck verdict STUCK_S later (chargers.py), as after a write.""" p.ch.freeze() c.car.armed_at = float(p.t) c.car.armed_sig = c.car.sig def unstick(a): """The reading moves again and shows `a` A; the charger takes writes.""" def f(p, c): p.ch.freeze(False) p.ch.refuse = None p.ch.set_current(a) return f def held(t0, t1): """The charger's read fails t0-t1 (under stale_input_s: held reads).""" return {t0: lambda p, c: p.ch.go_unavailable(), t1: lambda p, c: p.ch.go_unavailable(False)} # =========================================================================== # print("\n1. QA + QC: A STUCK READING AND THE LIFT (T14, T34, T35 (a))") # =========================================================================== # # The car's high import is short (960-1010) so the start rule's projection, # with the start power counted while the car figure is untrusted, lifts the # cap inside the stuck spell (from 1100). ev14 = dict(held(1015, 1025)) ev14.update({1040: stick, 1600: unstick(9)}) ev14 = window(ev14, 959, None) r = run(house_c((1010, 900.0)), sun_c((1010, 16000.0), (1600, 4900.0)), dur=1950, events=ev14) w14 = writes(r, 900, 1950) tr = refused(r, 900, 1300) ts = [t for t, _a in tr] heldw = [(t, a) for t, a, _ok, _w in writes(r, 1015, 1025)] tl = t_lift(r, 1100, 1600) stuck_from = first(x["t"] for x in rows(r, 1040) if x["stuck"]) check(f"T14: tries {tr}: 0 A at 960, at the first real read after the held " f"reads 1015-1025, then 60 s on; none while held ({heldw})", len(tr) == 3 and near(nth(ts, 0), 960, 1, 1) and near(nth(ts, 1), 1025, 0, 2) and not heldw and nth(ts, 2) - nth(ts, 1) >= 60 if len(tr) == 3 else False) pre = [(t, a) for t, a, _ok, _w in writes(r, 1090, tl or 1e9)] check(f"T14: stuck from {stuck_from}, the cap standing to {tl}: no 0 A from " f"the stuck path while the tries are used up ({pre})", present(stuck_from) and tl is not None and stuck_from < tl and not pre) sw = [(t, a, ok, why) for t, a, ok, why in writes(r, tl or 1e9, 1600)] hold = [(t, lv) for t, lv, _m in r["w"].lines(HOLD_TEXT)] nodrop = [x["t"] for x in rows(r, (tl or 1e9), 1600) if x["sent"] != 0.0 or x["taken"]] cf = sorted({x["cut_fails"] for x in rows(r, (tl or 1e9), 1600)}, key=str) check(f"T14 (QA b, QC 1): after the lift at {tl}, while stuck: the fault " f"path's 0 A 3 times, 60 s apart, reason Solar, refused ({sw}); not " f"cut tries (count {cf}); at the 3rd gave_up and the hold path's text " f"once ({hold}); no drop while stuck ({nodrop[:3]})", len(sw) == 3 and all(a == 0.0 and not ok and why == "Solar" for _t, a, ok, why in sw) and near(sw[0][0], tl or 0, 0, 2) and near(sw[1][0], sw[0][0], -58, 62) and near(sw[2][0], sw[1][0], -58, 62) and cf == [3] and len(hold) == 1 and near(hold[0][0], sw[2][0], 1, 1) and hold[0][1] == "WARNING" and bool(gave_up_at(r, sw[2][0], 1600)) and not nodrop if len(sw) == 3 else False) d14 = dropped(r, 1600, 9.0) gu = [x["t"] for x in rows(r, d14 or 1e9, 1950) if x["gave_up"]] pause = [(t, a, ok, why) for t, a, ok, why in writes(r, 1890, 1910) if a == 0.0] check(f"T14 (QA a): the first good reading 1600 shows 9 A: the drop at " f"{d14} with sent_a 9 (not the frozen 10), taken, plan 9, gave_up " f"cleared ({gu[:2]}); Solar resumes: the pause 0 A, Solar, taken, at " f"1900+-2 ({pause})", near(d14, 1600, 0, 2) and not gu and len(pause) == 1 and near(pause[0][0], 1900, 2, 2) and pause[0][2] and pause[0][3] == "Solar") never54("T14", r) ev34 = window({1040: stick, 2400: unstick(9)}, 959, None) r = run(house_c((1010, 900.0)), sun_c((1010, 16000.0)), dur=2500, n=2, events=ev34) tl = t_lift(r, 1100, 2400) sw = [(t, a, ok, why) for t, a, ok, why in writes(r, tl or 1e9, 2400)] hold = [(t, lv) for t, lv, _m in r["w"].lines(HOLD_TEXT)] gu = [x["t"] for x in rows(r, (nth(sw, 2)[0] if present(nth(sw, 2)) else 1e9) + 1, 2400) if not x["gave_up"]] d34 = dropped(r, 2400, 9.0) up = [(t, a, why) for t, a, ok, why in writes(r, 2401, 2500) if a > 10.0 and ok] check(f"T34 (QC 1): stuck 1040-2400, across the roll: after the lift at " f"{tl} the stuck 0 A 3 times ({sw}), then gave_up and one hold-path " f"WARNING ({hold}); nothing to 2400, also at the roll; gave_up stands " f"({gu[:2]}); the drop at {d34} (2400+-2, the good reading 9 A); a " f"step-up > 10 A, Solar, in [2430, 2460] ({up[:1]})", len(sw) == 3 and len(hold) == 1 and not gu and near(d34, 2400, 0, 2) and bool(up) and 2430 <= up[0][0] <= 2460 and up[0][1] <= 16.0 and up[0][2] == "Solar" and not [x for x in rows(r, d34 or 0, 2500) if x["gave_up"]]) never54("T34", r) st35 = {"lift": None, "prev": None} def lift_watch(p, c, t): """T35 (a): 30 s after the lift the charger takes writes and its reading follows again (the stuck verdict stands until it moves).""" cap = (getattr(c, "_cut", None) or {}).get("cap") if st35["lift"] is None and st35["prev"] is not None and cap is None \ and t > 1100: st35["lift"] = t st35["prev"] = cap if st35["lift"] is not None and t == st35["lift"] + 29: p.ch.refuse = None p.ch.freeze(False) r = run(house_c((1010, 900.0)), sun_c((1010, 16000.0)), dur=1600, events=window({1040: stick}, 959, None), on_cycle=lift_watch) tl = st35["lift"] sw = [(t, a, ok, why) for t, a, ok, why in writes(r, tl or 1e9, 1600) if a == 0.0] lines = [(t, m) for t, _lv, m in r["w"].lines("Car: set") if t >= 900 and " to 0 A" in m] pk = [(t, m) for t, _lv, m in r["w"].lines("peak cut") if t >= (tl or 0)] check(f"T35 (a) (QC 2): the stuck 0 A after the lift at {tl}: refused, then " f"taken at the 2nd try ({sw}), reason Solar; one 'Car: set from 10 A " f"to 0 A ... (Solar).' ({lines}); no 'peak cut' line after the lift " f"({pk})", len(sw) == 2 and not sw[0][2] and sw[1][2] and all(why == "Solar" for _t, _a, _o, why in sw) and [m for _t, m in lines] == ["Car: set from 10 A to 0 A on 3 phases (Solar)."] and not pk if len(sw) == 2 else False) never54("T35 (a)", r) # =========================================================================== # print("\n2. G1: A NEW QUARTER'S CUT WAIT (T25)") # =========================================================================== # class GiveFrom(S.SunPlant): """The battery gives nothing until 1800, then what it is asked, slowly (its 20 s response from 1790): headroom at the new quarter, not used within its first seconds.""" def batt_of(self, u, at): v = super().batt_of(u, at) return min(v, 0.0) if at < 1800 else v def free(p, c): c.batt_refused = 0 for tag, car_sun, s in (("0 A", 5830.0, 0.0), ("6 A", 7900.0, 1900.0)): a0 = 7.0 if tag == "0 A" else 10.0 ev = {t: refuse_n1 for t in range(0, 1795)} for t in range(1795, 1830): ev = merge(ev, t, free) ev = window(merge(ev, 1790, set_resp(20.0)), 959, 1810) r = run(house_c(h=900.0), step_fn((960, s), base=car_sun), dur=1900, n=1, socs={"a": 60.0}, events=ev, plant_cls=GiveFrom, rows=False) tr = refused(r, 900, 1800) d = dropped(r, 1800, a0) wait = [x["t"] for x in rows(r, 1800, 1830) if x["wait"] is not None] inwait = [(t, a) for t, a, _ok, _w in writes(r, 1800, 1830) if t <= (wait[-1] if wait else 1e9)] cw = [(t, a, ok, why) for t, a, ok, why, _k in cut_writes(r, 1800, 1830)] c1 = nth(cw, 0) rb = [x["t"] for x in rows(r, c1[0] if present(c1) else 1e9) if present(c1) and abs(x["rb"] - c1[1]) < 0.01] cuts = [t for t, n in r["raised"] if n == CUT and t >= 1800] want = 0.0 if tag == "0 A" else 6.0 check(f"T25 [{tag}] (G1): 3 refused tries in 900-1800 ({tr}); the drop " f"at {d} (1800+-2: sent_a {a0}, taken, plan {a0}); the wait " f"{wait[:1]}..{wait[-1:]} with no write in it ({inwait}); then the " f"cut try {c1} ({want} A, peak cut, taken) after the wait, read " f"back by {rb[:1]}, CAR_CUT once ({cuts})", len(tr) == 3 and near(d, 1800, 0, 2) and bool(wait) and not inwait and present(c1) and c1[0] > wait[-1] and c1[0] <= 1817 and c1[1] == want and c1[2] and c1[3] == "peak cut" and bool(rb) and rb[0] <= c1[0] + 2 and len(cuts) == 1 if wait else False) never54(f"T25 [{tag}]", r) # =========================================================================== # print("\n3. G2, G3: THE LIFT (T26, T27, T28) AND THE C4 REPLAY") # =========================================================================== # r = run(house_c((1250, 900.0)), sun_c((1250, 9000.0)), dur=2700, events=window({}, 959, 1300)) tl = t_lift(r, 1100, 1800) d = dropped(r, tl or 0, 10.0) paused = [x["t"] for x in rows(r, tl or 1e9, (tl or 1e9) + 30) if x["plan"] < 6.0 or x["plan_why"] == "paused"] z = [(t, ok) for t, a, ok, _w in writes(r, 1081, 2700) if a == 0.0] up = [(t, a, why) for t, a, ok, why in writes(r, (tl or 1e9) + 30, (tl or 1e9) + 61) if a > 10.0] nxt = first((t, a, why) for t, a, _ok, why in writes(r, 1081, 2700)) check(f"T26 (G2): the lift at {tl} (1370+-2): the drop {d} (plan 10, not " f"paused {paused[:2]}, so '0 A first' does not clear its start count); " f"no 0 A after the 3rd try ({z[:2]}); then the first write {nxt} is a " f"step-up > 10 A, Solar, in [t_lift+30, t_lift+60] ({up[:1]})", near(tl, 1370, 2, 2) and d is not None and not paused and not z and bool(up) and up[0][1] <= 16.0 and up[0][2] == "Solar" and present(nxt) and nxt == up[0]) never54("T26", r) for tag, H in (("6 A", 12500.0), ("0 A", 16000.0)): ev = {t: refuse_n1 for t in range(0, 2701)} ev = window(ev, 1699, 1900) # The period sits near the aim (EV-21's near_end): the house steps at # 1700 for 5 s (100 s left, so the cut is at once), the cut stands; # it lifts only at the period's end, with tries left. house = step_fn((900, 3350.0), (1500, 900.0), (1700, H), (1705, 900.0), base=900.0) sun = step_fn((900, 0.0), (1500, 7900.0), (1700, 7000.0), base=7900.0) r = run(house, sun, dur=2700, n=1, socs={"a": 60.0}, events=ev, plant_cls=NoGive, rows=False) want = 6.0 if tag == "6 A" else 0.0 tr = refused(r, 1690, 1800) d = dropped(r, 1800, 10.0) bad = [(t, a, why) for t, a, ok, why in writes(r, 1800, 2700) if abs(a - want) < 0.01 or why == "peak cut"] nxt = first(x for x in writes(r, 1800, 2700)) check(f"T27 [{tag}] (G3, tries left): {tr} refused ({want} A) before the " f"period's end; the drop at {d} (1800+-2); no re-send of {want} A " f"and no 'peak cut' write in [1800, 2700) ({bad[:3]}); the next " f"write the plan's ({nxt})", 1 <= len(tr) <= 2 and all(a == want for _t, a in tr) and near(d, 1800, 0, 2) and not bad and (not present(nxt) or nxt[3] == "Solar")) never54(f"T27 [{tag}]", r) class Drv: def __init__(self): self.calls = [] async def write_current(self, a, **kw): self.calls.append(a) return False class Trk: obs_at = None def begin_write(self): pass def end_write(self, *a): pass def note_write(self, *a, **k): pass def stuck(self, now): return False async def c4_replay(): w = carmode.SolarWriter() w.engaged, w.sent_a, w.taken, w.last_a = True, 10.0, True, 10.0 drv, trk = Drv(), Trk() w.cut_a, w.cut_on = 6.0, True await w._put(drv, 6.0, 10.0, 1000.0, trk) first_try = list(drv.calls) w.cut_a, w.cut_on = None, False await w._put(drv, 6.0, 10.0, 1070.0, trk) return first_try, drv.calls[len(first_try):], w.sent_why try: c4 = asyncio.run(c4_replay()) except Exception as e: # noqa: BLE001 c4 = (None, ["raised " + repr(e)], None) check(f"T27 (formal C4 replay): a 6 A cut refused once {c4[0]}; with no " f"cut 70 s later `_put(6)` sends nothing ({c4[1]})", c4[0] == [6.0] and c4[1] == []) r = run(house_c((1250, 900.0)), sun_c((1250, 7950.0)), dur=2700, events=window({}, 959, 1900)) tl = t_lift(r, 1100, 1800) d = dropped(r, tl or 0, 10.0) w28 = [(t, a) for t, a, _ok, _w in writes(r, 1081, 2700)] check(f"T28 (G3, tries used up): the lift at {tl}: the drop {d}; no write " f"at all in (1080, 2700) ({w28[:3]}), also not at the roll; gave_up " f"never ({gave_up_at(r, 900)[:2]})", near(tl, 1370, 2, 2) and d is not None and not w28 and not gave_up_at(r, 900)) never54("T28", r) # =========================================================================== # print("\n4. G4, G5, G6: A PARTIAL CUT (T29, T30, T32), A DEEPER CUT (T31)") # =========================================================================== # r = run(house_c((1250, 900.0), h=900.0), sun_c((1250, 9000.0), s=1900.0), dur=1800, events=window({}, 959, 1100)) tr = refused(r, 900, 1800) tl = t_lift(r, 1100, 1800) d = dropped(r, tl or 0, 10.0) six = [(t, a) for t, a, _ok, _w in writes(r, 1081, 1800) if a == 6.0] up = [(t, a, why) for t, a, ok, why in writes(r, (tl or 1e9), (tl or 1e9) + 61) if a > 10.0] check(f"T29 (G4): 6 A refused 3 times ({tr}), no 4th; the lift at {tl}: the " f"drop {d} (sent 10, plan 10); no 6 A after 1080 ({six}); a step-up " f"> 10 A, Solar, within t_lift+60 ({up[:1]})", [a for _t, a in tr] == [6.0, 6.0, 6.0] and near(tl, 1370, 2, 2) and d is not None and not six and bool(up) and up[0][1] <= 16.0 and up[0][2] == "Solar") never54("T29", r) as_off("T29", r, twin(r), ALARMS, refused=(961, (tl or 1371) - 1)) pre = [(t, a) for t, a, _ok, _w in writes(r, 1081, (tl or 1e9) - 2)] hi = [(x["t"], x["plan"]) for x in rows(r, 1081, tl or 1e9) if x["plan"] > 6.0] check(f"T32 (G6): the tries used up, the spare about 16 A from 1250, the cap " f"to {tl}: no write in (1080, t_lift-2) ({pre}); the plan at most 6 A " f"until the lift ({hi[:3]})", tl is not None and not pre and not hi) for n in (1, 2): for tag, s2 in (("6 A", 1900.0), ("under 6 A", 1200.0)): r = run(house_c(h=900.0), sun_c((1800, s2), s=1900.0), dur=1900, n=n, events=window({}, 959, 1790)) tr = refused(r, 900, 1795) hold_s = r["c"].p1.averager.max_hold_s kc = key_change(r, 1700, 1900) c2 = first((t, a, ok) for t, a, ok, _w, _k in cut_writes(r, 1800 - hold_s - 1)) lo = 1800 - (hold_s if n == 2 else 0) - 1 x2 = row(r, c2[0]) if present(c2) else None cap2 = x2["cap"] if present(x2) and x2 is not None else None rb = [x["t"] for x in rows(r, c2[0] if present(c2) else 1e9) if present(c2) and abs(x["rb"] - c2[1]) < 0.01] cuts = [t for t, nn in r["raised"] if nn == CUT and t >= 1790] # The value is the new quarter's cut, or lower when Solar's own plan # is lower (here its pause: the spare stayed under 6 A worth). check(f"T30 [N={n}, {tag}] (G4): 3 refused tries of 6 A ({tr}); the " f"new key ({kc}) tried in its first cycle ({c2}, bound " f"[{lo}, 1801]) at or under the new quarter's sized cut " f"({cap2} A), 0 A or 6 A and more, never 1-5 A, taken, read " f"back by {rb[:1]}; CAR_CUT once ({cuts})", [a for _t, a in tr] == [6.0, 6.0, 6.0] and present(c2) and c2 is not None and lo <= c2[0] <= 1801 and cap2 is not None and c2[1] <= cap2 + 0.01 and (c2[1] == 0.0 or c2[1] >= 6.0) and c2[2] and bool(rb) and rb[0] <= c2[0] + 2 and len(cuts) == 1) never54(f"T30 [N={n}, {tag}]", r) if n == 2 and tag == "6 A": as_off("T30 [N=2, 6 A]", r, twin(r), ALARMS, refused=(961, 1790)) r = run(house_c((1030, 3000.0), h=900.0), sun_c((1030, 0.0), s=1900.0), dur=1950, events=window({}, 959, 1830)) tr = refused(r, 900, 1795) check(f"T31 (G5): 6 A refused at 960 and 1020, the cut deepens at 1030: 0 A " f"at once, refused, try 3 ({tr}); no 4th refused try in 900-1800; " f"gave_up never ({gave_up_at(r, 900, 1800)[:2]})", [a for _t, a in tr] == [6.0, 6.0, 0.0] and near(nth(tr, 2)[0] if present(nth(tr, 2)) else None, 1030, 0, 2) and not gave_up_at(r, 900, 1800)) hold_s = r["c"].p1.averager.max_hold_s kc = key_change(r, 1700, 1900) w2 = [(t, a, ok) for t, a, ok, _w, _k in cut_writes(r, 1800 - hold_s - 1)] check(f"T31: the new key ({kc}) tried in its first cycle and refused, the " f"next 60 s or more later taken ({w2[:2]})", len(w2) >= 2 and not w2[0][2] and w2[1][2] and w2[1][0] - w2[0][0] >= 60 and present(kc) and kc is not None and abs(w2[0][0] - kc) <= 1) never54("T31", r) # =========================================================================== # print("\n5. QB: NO READ-BACK AT THE LIFT (T33)") # =========================================================================== # def rb_none(on): """The charger answers, but neither its setpoint nor its read-back is a number: `allowed_a` and `setpoint_a` are both None.""" def f(p, c): ch = p.ch if on: orig = ch.states def st(): d = dict(orig()) for k in list(d): if k.endswith("_power_connector_max_current_socket_1") \ or k.endswith("_main_active_max_current_socket_1"): d[k] = dict(d[k], state="-") return d ch._ev54_states = orig ch.states = st else: ch.states = ch._ev54_states return f seen33 = [] def rd33(p, c, t): rd = c.car.reading if rd is not None and 1340 <= t < 1400: seen33.append((rd.available, rd.allowed_a, rd.setpoint_a)) r = run(house_c((1250, 900.0)), sun_c((1250, 7950.0)), dur=2700, events=window({1340: rb_none(True), 1400: rb_none(False)}, 959, 1900), on_cycle=rd33) tl = t_lift(r, 1100, 1800) w33 = [(t, a) for t, a, _ok, _w in writes(r, 1081, 2700)] nod = [x["t"] for x in rows(r, 1340, 1400) if x["sent"] != 0.0 or x["taken"]] d = dropped(r, 1400, 10.0) check(f"T33 (QB): the read-back unknown 1340-1400 ({sorted(set(seen33))}), " f"the lift at {tl} inside it: no write ({w33[:3]}), no drop and " f"sent_a 0 untaken, not None ({nod[:3]}); the drop at {d} (1400+-2) " f"with 10 A; then no write to 2700", sorted(set(seen33)) == [(True, None, None)] and present(tl) and tl is not None and 1340 < tl < 1400 and not w33 and not nod and near(d, 1400, 0, 2)) never54("T33", r) # The variant: the charger away 1100-1400, the cap lifted while it is away # (T14's short import spell, so the start rule's projection lifts it without # a car figure). ev = window({1100: lambda p, c: p.ch.go_unavailable(), 1400: lambda p, c: p.ch.go_unavailable(False)}, 959, 1900) r = run(house_c((1010, 900.0)), sun_c((1010, 16000.0)), dur=1500, events=ev) tl = t_lift(r, 1100, 1400) away = [(t, a) for t, a, _ok, _w in writes(r, 1100, 1400)] back = [(t, a, why) for t, a, _ok, why in writes(r, 1400, 1500)] keys = [k for k in r["store"].data if "cut" in str(k).lower()] check(f"T33 [charger away 1100-1400, the lift at {tl}]: nothing while away " f"({away}); on return D2's 0 A as bdfd3e6 ({back[:1]}), not a re-send " f"of the cut; no store key ({keys})", present(tl) and tl is not None and 1100 < tl < 1400 and not away and bool(back) and near(back[0][0], 1400, 0, 1) and back[0][1] == 0.0 and back[0][2] != "peak cut" and not keys) never54("T33 [away]", r) # =========================================================================== # print("\n6. QC 2: THE WAY-OUT REASON WITH OFF (T35 (b), (c))") # =========================================================================== # r = run(house_c((1250, 900.0)), sun_c((1250, 9000.0)), dur=1500, events=window({1400: act("car_mode", "off")}, 959, 1380)) wb = [(t, a, ok) for t, a, ok, _w in writes(r, 1395)] lb = [m for t, _lv, m in r["w"].lines("Car: set") if t >= 1395] whyb = [why for t, _a, _ok, why in writes(r, 1395)] # bdfd3e6 writes nothing here: it is frozen with `gave_up` after the lift (C3) # and Off does not clear it. After the drop the car's 10 A is Solar's, so Off # writes EV-20's way-out 0 A once, at the press, as Solar's. want = golden("T35 (b)", wb) check(f"T35 (b): Off at 1400 after the lift: its way-out 0 A {wb} once at " f"the press (bdfd3e6: {want}, frozen), reason Solar ({whyb}); one line " f"({lb})", wb == [(1400.0, 0.0, True)] and whyb == ["Solar"] and lb == ["Car: set from 10 A to 0 A on 3 phases (Solar)."]) r = run(house_c(), sun_c(), dur=1200, events=window({1000: act("car_mode", "off")}, 959, 999)) wc = [(t, a, ok) for t, a, ok, _w in writes(r, 995)] lc = [m for t, _lv, m in r["w"].lines("Car: set") if t >= 995] want = golden("T35 (c)", (wc, lc)) check(f"T35 (c): Off at 1000 while the cut stands: writes {wc} and lines " f"{lc} as bdfd3e6's ({want})", (wc, lc) == want and bool(wc)) tb_all = LOG.tracebacks(n_log0) check(f"N13: no traceback in this file's runs ({tb_all[:1]})", not tb_all) if TAKE: print("(golden taken; no checks graded)") sys.exit(0) print(f"\n{'FAILED: ' + str(len(fails)) if fails else 'ALL PASSED'}") sys.exit(1 if fails else 0)