EV-20: SPIKE-05 decisions C1, C6, C9 (brief v5) with rows for C1, C5, C6, C8, C9
C1: an own 0 A not yet read back is kept with the mode; a start in Off with it writes the 0 A (retried), without it nothing; a start that will not write warns once when the charger still has the add-on's current. C6: Solar's 30 s gate also counts from Manual's latest write. C9: an exit also owes its 0 A when the read-back shows Solar's own value. Rows for C5 and C8 too. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -88,3 +88,23 @@ one small set of facts and derives every path from them:
|
||||
today's kWh; stored with its day, reset at the day's change.
|
||||
- **Rollback.** An older build reads a stored `car_mode = solar` as Off
|
||||
(`start_mode`) and writes nothing; no state migration.
|
||||
|
||||
## SPIKE-05 decisions (brief v4/v5)
|
||||
|
||||
- **C1.** An own 0 A that is out and not read back is kept in the store with
|
||||
the mode (`car_exit_0a_pending`). A start in Off with that flag writes the
|
||||
0 A (when it may write), retried by the exit rule; Off without it writes
|
||||
nothing (N10). A start that will not write (shadow, control stopped) after
|
||||
Manual or Solar, with the charger showing a current, writes nothing and
|
||||
raises one warning, *Charger kept its current*, taken down at 0 A.
|
||||
- **C5.** Each shutdown try waits 4 s for its read-back (D3 above).
|
||||
- **C6.** One write clock: Solar's 30 s gate also counts from Manual's latest
|
||||
non-zero write, the start included. Solar's first write after Manual is its
|
||||
0 A, which is never gated.
|
||||
- **C8.** A charger or HA outage ends a phase change: the return restarts the
|
||||
plan paused, so nothing of the sequence resumes; only a 0 A may come before
|
||||
the start rule.
|
||||
- **C9.** An exit owes its 0 A while Solar's own value may stand: by its own
|
||||
bookkeeping (a 0 A not read back counts) or by the read-back showing a value
|
||||
it sent, confirmed, tried or saw at a refused try.
|
||||
- **C3** is T43-T45; **C7** is EV-22's.
|
||||
|
||||
@@ -3573,6 +3573,14 @@ alarm. It is raised once per charging session. To stay under the limit, lower th
|
||||
current. In Solar it says "Solar charges the car at {a} A, which sets the
|
||||
peak.": the same case, with the current the charger has.
|
||||
|
||||
### Charger kept its current
|
||||
|
||||
The add-on started without writing to the charger (shadow mode, or control
|
||||
not started yet), and the charger still has the current the add-on set before
|
||||
it stopped, in Manual or Solar. Nothing changes the charger until you start
|
||||
control or turn shadow mode off. Check the charger if the car should not be
|
||||
charging. The notification goes once the charger shows 0 A.
|
||||
|
||||
### Car may still be charging
|
||||
|
||||
The add-on stopped in Solar mode, and the charger did not take the 0 A it sent
|
||||
|
||||
@@ -515,6 +515,7 @@ class SolarPlan:
|
||||
self.why = why
|
||||
self.target_w = None
|
||||
self._before = None # the state before a phase change
|
||||
self.ext_at = None # C6: Manual's latest non-zero write
|
||||
|
||||
def pause(self, why="paused"):
|
||||
self.a = 0.0
|
||||
@@ -524,7 +525,9 @@ class SolarPlan:
|
||||
self.why = why
|
||||
|
||||
def _gate(self, now) -> bool:
|
||||
return self.set_at is None or now - self.set_at >= SOLAR_WRITE_S
|
||||
"""30 s since the latest non-zero write, Solar's or (C6) Manual's."""
|
||||
return all(t is None or now - t >= SOLAR_WRITE_S
|
||||
for t in (self.set_at, self.ext_at))
|
||||
|
||||
def _set(self, a, now, n=None):
|
||||
if n is not None and n != self.n:
|
||||
@@ -584,7 +587,7 @@ class SolarPlan:
|
||||
if self.ok_since is None:
|
||||
self.ok_since = now
|
||||
self.why = "start"
|
||||
if now - self.ok_since >= start_s \
|
||||
if now - self.ok_since >= start_s and self._gate(now) \
|
||||
and (n0 == self.n or gap_ok):
|
||||
a = amps_for(target_w, n0, clamp)
|
||||
if a is not None and a >= CH.MIN_A:
|
||||
@@ -691,6 +694,19 @@ class SolarWriter(ManualWriter):
|
||||
self._would_switch = None # ... and when it last changed them
|
||||
self.released = None # D3: True / False once shutdown tried
|
||||
self.mode_was = None # the mode of the previous step
|
||||
self.start_owed = False # C1: a start in Off with a 0 A pending
|
||||
self.other_at = None # C6: Manual's latest non-zero write
|
||||
self.on_owed = None # C1: told when an own 0 A is out / back
|
||||
|
||||
def owe_start(self) -> None:
|
||||
"""C1: the add-on starts in Off while an exit 0 A of its own was still
|
||||
pending at the stop: the current the charger shows is the add-on's,
|
||||
so the 0 A is owed (once it may write), retried by the exit rule."""
|
||||
self.start_owed = self.engaged = True
|
||||
|
||||
def _owed(self, pending: bool) -> None:
|
||||
if self.on_owed is not None:
|
||||
self.on_owed(pending)
|
||||
|
||||
# ------------------------------------------------------------- state
|
||||
@property
|
||||
@@ -735,6 +751,7 @@ class SolarWriter(ManualWriter):
|
||||
zero = float(a) <= TOL_A
|
||||
if zero:
|
||||
self.zero_at = self.zero_sent_at = now
|
||||
self._owed(True) # C1: kept with the mode until back
|
||||
try:
|
||||
ok = await super()._write(drv, a, was, now, tracker, **kw)
|
||||
finally:
|
||||
@@ -743,6 +760,8 @@ class SolarWriter(ManualWriter):
|
||||
if ok:
|
||||
self.taken = True
|
||||
self.fails, self.fail_at, self.gave_up = 0, None, False
|
||||
if zero:
|
||||
self._owed(False)
|
||||
else:
|
||||
self._failed(now)
|
||||
return ok
|
||||
@@ -758,6 +777,8 @@ class SolarWriter(ManualWriter):
|
||||
|
||||
def _adopt(self, cur) -> None:
|
||||
"""The read-back shows what Solar sent: taken, however late."""
|
||||
if self.sent_a is not None and self.sent_a <= TOL_A:
|
||||
self._owed(False)
|
||||
self.taken = True
|
||||
self.last_a = cur
|
||||
self.attempted_a = self.prior_a = None
|
||||
@@ -787,11 +808,23 @@ class SolarWriter(ManualWriter):
|
||||
return
|
||||
await self._write(drv, want, cur, now, tracker)
|
||||
|
||||
def _own_readback(self, cur) -> bool:
|
||||
"""C9: does the read-back show a current of Solar's own (sent,
|
||||
confirmed, tried, or shown when a try was refused)?"""
|
||||
if cur is None or cur <= TOL_A:
|
||||
return False
|
||||
return any(k is not None and k > TOL_A and abs(cur - k) <= TOL_A
|
||||
for k in (self.sent_a, self.last_a, self.attempted_a,
|
||||
self.prior_a))
|
||||
|
||||
async def _zero(self, drv, cur, now, tracker, stuck=False) -> None:
|
||||
"""A way out: 0 A while Solar's own current may stand, never over
|
||||
"""A way out: 0 A while Solar's own current may stand (its own
|
||||
bookkeeping, or C9 the read-back showing its value), never over
|
||||
another writer's hold."""
|
||||
self.seq = None
|
||||
self.plan.end_switch(False)
|
||||
if not self.live and self._own_readback(cur) and not stuck:
|
||||
self.taken = False # C9: a 0 A is owed
|
||||
if self.live and not self.hold:
|
||||
await self._put(drv, 0.0, cur, now, tracker, stuck)
|
||||
|
||||
@@ -830,6 +863,7 @@ class SolarWriter(ManualWriter):
|
||||
def _leave(self) -> None:
|
||||
"""Solar is no longer the mode and owes nothing."""
|
||||
self.engaged, self.seq, self.would = False, None, None
|
||||
self.start_owed = False
|
||||
self.out, self.fault = False, None
|
||||
self.restart = True
|
||||
self.mismatch_since = None
|
||||
@@ -840,6 +874,7 @@ class SolarWriter(ManualWriter):
|
||||
>= PHASE_GAP_S
|
||||
|
||||
def _plan_step(self, sun, now, clamp, n_now, gap_ok) -> None:
|
||||
self.plan.ext_at = self.other_at
|
||||
self.plan.step(
|
||||
now, target_w=sun.target_w, hold=sun.hold, n_now=n_now,
|
||||
auto=sun.auto and not self.single and not self.phases_gave_up,
|
||||
@@ -932,6 +967,14 @@ class SolarWriter(ManualWriter):
|
||||
self._mark(r, now)
|
||||
if mode != SOLAR:
|
||||
self.would = None
|
||||
if mode == OFF and self.start_owed:
|
||||
if not writing:
|
||||
return # C1: waits; the start warning says so
|
||||
self.start_owed = False
|
||||
if cur is not None and cur > TOL_A and not self.hold:
|
||||
self.sent_a, self.taken = cur, True # ours, from before
|
||||
else:
|
||||
self._owed(False)
|
||||
if mode == OFF: # 0 A while owed, then nothing
|
||||
await self._zero(drv, cur, now, tracker, stuck)
|
||||
if self.live and not self.hold:
|
||||
|
||||
@@ -41,6 +41,9 @@ RISE_STILL_W = 50.0
|
||||
# charger did not take (D3), so the next start can take its notice down.
|
||||
CAR_SUN_KEY = "car_sun"
|
||||
CAR_RELEASE_KEY = "car_release_failed"
|
||||
# C1 (SPIKE-05): an own 0 A of Solar's is out and not read back yet, kept with
|
||||
# the mode, so a start in Off after a power cut still writes it.
|
||||
CAR_EXIT_KEY = "car_exit_0a_pending"
|
||||
# EV-20 (D3): at shutdown in Solar the charger's 0 A waits at most this long,
|
||||
# then the inverters are released whatever the charger did.
|
||||
RELEASE_WAIT_S = 15.0
|
||||
@@ -53,6 +56,13 @@ class CarMixin:
|
||||
restart does with the mode. A site with no charger keeps defaults and
|
||||
writes nothing."""
|
||||
data = getattr(store, "data", None) or {}
|
||||
# C1: the mode before the stop, and an exit 0 A still pending then.
|
||||
stored = data.get(carmode.KEY_MODE)
|
||||
self._car_stored_mode = stored if stored in carmode.MODES \
|
||||
else carmode.OFF
|
||||
self._car_exit_pending = bool(data.get(CAR_EXIT_KEY))
|
||||
self._car_start_seen = False
|
||||
self._car_start_warned = False
|
||||
self.car_mode = carmode.start_mode(opts, data.get(carmode.KEY_MODE))
|
||||
if carmode.start_mode(opts, carmode.MANUAL) == carmode.OFF \
|
||||
and data.get(carmode.KEY_MODE) not in (None, carmode.OFF):
|
||||
@@ -66,6 +76,9 @@ class CarMixin:
|
||||
self.car_rev = 0
|
||||
self.car_writer = carmode.ManualWriter()
|
||||
self.car_solar = carmode.SolarWriter() # EV-20
|
||||
self.car_solar.on_owed = self._car_owed
|
||||
if self.car_mode == carmode.OFF and self._car_exit_pending:
|
||||
self.car_solar.owe_start() # C1
|
||||
first = data.get(carmode.KEY_FIRST)
|
||||
self.car_first = first if first in carmode.FIRSTS \
|
||||
else carmode.DEFAULT_FIRST
|
||||
@@ -116,6 +129,40 @@ class CarMixin:
|
||||
return (self.charger.configured()
|
||||
and self.car_mode == carmode.MANUAL)
|
||||
|
||||
def _car_owed(self, pending) -> None:
|
||||
"""C1: keep "an own 0 A is out, not read back" with the mode."""
|
||||
pending = bool(pending)
|
||||
if pending != self._car_exit_pending:
|
||||
self._car_exit_pending = pending
|
||||
self.store.set(CAR_EXIT_KEY, pending)
|
||||
|
||||
async def check_car_start(self) -> None:
|
||||
"""C1: the first reading after a start that will not write (shadow,
|
||||
control stopped) shows a current the add-on set before the stop
|
||||
(Manual or Solar then): one warning, taken down once it is 0 A."""
|
||||
r = self.car.reading
|
||||
if r is None or not r.available or not self.charger.configured():
|
||||
return
|
||||
cur = r.allowed_a if r.allowed_a is not None else r.setpoint_a
|
||||
if not self._car_start_seen:
|
||||
self._car_start_seen = True
|
||||
if self._car_stored_mode in (carmode.MANUAL, carmode.SOLAR) \
|
||||
and not self.car_writing() and cur is not None \
|
||||
and cur > carmode.TOL_A:
|
||||
self._car_start_warned = True
|
||||
_LOG.warning("The charger still has a current from before "
|
||||
"the restart, and the add-on does not write "
|
||||
"now: CHARGER_START_CURRENT.")
|
||||
_LOG.debug("The charger shows %.0f A at the start.", cur)
|
||||
await self.hass.call("persistent_notification", "create",
|
||||
messages.car_start_current(
|
||||
f"{cur:.0f}").data())
|
||||
elif self._car_start_warned and cur is not None \
|
||||
and cur <= carmode.TOL_A:
|
||||
self._car_start_warned = False
|
||||
await self.hass.call("persistent_notification", "dismiss",
|
||||
messages.car_start_current_gone().data())
|
||||
|
||||
def car_solar_mode(self) -> bool:
|
||||
"""EV-20: a charger is set up and the mode is Solar."""
|
||||
ch = getattr(self, "charger", None)
|
||||
@@ -331,6 +378,10 @@ class CarMixin:
|
||||
status=self.car.status(now, True), clock=self.car_now)
|
||||
w = self.car_solar
|
||||
if self.car_mode == carmode.SOLAR or w.engaged:
|
||||
# C6: one write clock: Manual's latest non-zero write counts.
|
||||
w.other_at = max((t for kind, a, t, ok in self.car_writer.log
|
||||
if kind == "current" and a > carmode.TOL_A),
|
||||
default=None)
|
||||
sun = None
|
||||
if self.car_mode == carmode.SOLAR:
|
||||
sun = getattr(self, "_car_sun_now", None) \
|
||||
|
||||
@@ -1070,6 +1070,7 @@ class CycleMixin:
|
||||
await self.check_charger()
|
||||
await self.check_car_over()
|
||||
await self.check_car_release() # EV-20 (D3)
|
||||
await self.check_car_start() # EV-20 (C1)
|
||||
self.car_kick() # EV-04/20: in the background
|
||||
await self.check_fixed_note()
|
||||
|
||||
|
||||
@@ -191,6 +191,8 @@ T_CHARGER_UNREACH_NL = "Laadpaal onbereikbaar"
|
||||
T_CAR_OVER = "Car over the peak limit"
|
||||
T_CAR_OVER_NL = "Auto boven de piekgrens"
|
||||
T_CAR_RELEASE = "Car may still be charging"
|
||||
T_CAR_START = "Charger kept its current"
|
||||
T_CAR_START_NL = "Laadpaal hield haar stroom"
|
||||
T_CAR_RELEASE_NL = "Auto laadt mogelijk nog"
|
||||
T_NO_PRICES = "No prices"
|
||||
T_NO_PRICES_NL = "Prijzen ontbreken"
|
||||
@@ -207,6 +209,7 @@ ID_NO_PRICES = "goodwe_no_prices"
|
||||
ID_CHARGER_UNREACH = "goodwe_charger_unreachable"
|
||||
ID_CAR_OVER = "goodwe_car_over"
|
||||
ID_CAR_RELEASE = "goodwe_car_release"
|
||||
ID_CAR_START = "goodwe_car_start_current"
|
||||
# PRICE-01: an earlier build raised a card with this id. Nothing raises it now;
|
||||
# the add-on only dismisses it at start.
|
||||
OLD_FIXED_CARD_ID = "goodwe_fixed_tariff_unused"
|
||||
@@ -554,6 +557,21 @@ def car_release_failed() -> Notice:
|
||||
body_nl=f"{T_CAR_RELEASE_NL}. {nl}")
|
||||
|
||||
|
||||
def car_start_current(a_text) -> Notice:
|
||||
"""EV-20 (C1): the add-on starts without writing (shadow mode, control
|
||||
stopped) and the charger still has a current the add-on set before the
|
||||
stop. Taken down once the charger shows 0 A."""
|
||||
return Notice(ID_CAR_START, WARNING, T_CAR_START,
|
||||
f"Charger still at {a_text} A from before the restart.",
|
||||
body_nl=f"{T_CAR_START_NL}. Laadpaal staat nog op {a_text} A "
|
||||
f"van voor de herstart.")
|
||||
|
||||
|
||||
def car_start_current_gone() -> Dismiss:
|
||||
"""EV-20 (C1): takes the 'Charger kept its current' notice down."""
|
||||
return Dismiss(ID_CAR_START)
|
||||
|
||||
|
||||
def car_release_gone() -> Dismiss:
|
||||
"""EV-20 (D3): takes the 'Car may still be charging' notice down."""
|
||||
return Dismiss(ID_CAR_RELEASE)
|
||||
@@ -1877,6 +1895,7 @@ def samples() -> list:
|
||||
car_over("16"),
|
||||
car_over_solar("8"),
|
||||
car_release_failed(),
|
||||
car_start_current("10"),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import ev20_sun as S # noqa: E40
|
||||
from chargersim import SimCharger # noqa: E402
|
||||
from ev20_kit import * # noqa: E402,F401,F403
|
||||
from ev20_kit import LOG, check, fails, report # noqa: E402,F401
|
||||
from named_absence import nth, present # noqa: E402,F401
|
||||
from named_absence import given, nth, present # noqa: E402,F401
|
||||
from ev20_kit import (_dies, _err, _freeze_after_write, _shutdown, # noqa: E402,F401
|
||||
_until)
|
||||
|
||||
@@ -426,6 +426,29 @@ check("T5 (iv): a charger reading older than 15 s (this driver: the charger "
|
||||
r5d["trace"][330]["spare"] is None
|
||||
and [a for _, a, _ in cur_writes(r5d)] == [10.0])
|
||||
|
||||
# C6: one write clock. A plan whose start dwell is done waits 30 s from
|
||||
# Manual's latest non-zero write (`ext_at`), and from its own.
|
||||
p6 = SolarPlan(1)
|
||||
starts6 = []
|
||||
for k in range(300):
|
||||
p6.ext_at = 150.0
|
||||
p6.step(float(k), target_w=3000.0, n_now=1, auto=False, clamp=16,
|
||||
start_s=120.0, pause_s=300.0)
|
||||
if p6.a > 0.0 and not starts6:
|
||||
starts6.append(k)
|
||||
check(f"C6: Manual wrote at 150 s; Solar's start dwell is done at 120 s but "
|
||||
f"its first current waits for 180 s ({starts6})", starts6 == [180])
|
||||
r6m = std(400, mode="manual", sim=SimCharger(setpoint_a=0),
|
||||
opts={"ev_start_min": 1},
|
||||
events={100: act("car_current", 12), 105: act("car_mode", "solar")})
|
||||
w6m = [(t, a) for t, a, _ in cur_writes(r6m)]
|
||||
man = [x[0] for x in r6m["sim"].log if x[2] > 0.0 and x[0] <= 106]
|
||||
check(f"C6: Manual writes 12 A, then Solar is chosen: Solar's own first "
|
||||
f"write is 0 A, and no current of Solar's within 30 s of Manual's "
|
||||
f"({man}, Solar {w6m})",
|
||||
w6m[:1] and w6m[0][1] == 0.0 and present(nth(man, -1))
|
||||
and not [t for t, a in w6m if a > 0.0 and t - nth(man, -1) < 30.0])
|
||||
|
||||
# T13: the start rule.
|
||||
for race in (False, True):
|
||||
tag = "race" if race else "step"
|
||||
|
||||
@@ -30,7 +30,7 @@ import ev20_sun as S # noqa: E40
|
||||
from chargersim import SimCharger # noqa: E402
|
||||
from ev20_kit import * # noqa: E402,F401,F403
|
||||
from ev20_kit import LOG, check, fails, report # noqa: E402,F401
|
||||
from named_absence import nth, present # noqa: E402,F401
|
||||
from named_absence import given, nth, present # noqa: E402,F401
|
||||
from ev20_kit import (_dies, _err, _freeze_after_write, _shutdown, # noqa: E402,F401
|
||||
_until)
|
||||
|
||||
@@ -589,6 +589,118 @@ check(f"T37: shutdown while the 0 -> 10 A start write waits for its "
|
||||
and [x[2] for x in sim37.log][-1:] == [0.0]
|
||||
and sim37.setpoint_a == 0.0)
|
||||
|
||||
# C1 (SPIKE-05, brief v5): a start-up after a stop with no release.
|
||||
import opt11_identity as rig # noqa: E402
|
||||
|
||||
|
||||
def _store(mode, pending=None):
|
||||
st = rig._Store()
|
||||
st.data["car_mode"] = mode
|
||||
if pending is not None:
|
||||
st.data[ctl_car.CAR_EXIT_KEY] = pending
|
||||
return st
|
||||
|
||||
|
||||
for pending, name in ((True, "Off, flag set, charger at 10 A -> 0 A written"),
|
||||
(False, "Off, no flag -> nothing")):
|
||||
simc = TSim(setpoint_a=10, windows=[(0.0, 2.5, "error")])
|
||||
rr = std(200, sim=simc, mode="off", store=_store("off", pending))
|
||||
w = cur_writes(rr)
|
||||
if pending:
|
||||
check(f"C1 [{name}]: the 0 A at the first reading, refused, tried "
|
||||
f"again 60 s later and taken; the flag cleared ({w})",
|
||||
[(round(t), a, ok) for t, a, ok in w]
|
||||
in ([(0, 0.0, False), (60, 0.0, True)],
|
||||
[(1, 0.0, False), (61, 0.0, True)])
|
||||
and simc.setpoint_a == 0.0
|
||||
and rr["store"].data.get(ctl_car.CAR_EXIT_KEY) is False)
|
||||
else:
|
||||
check(f"C1 [{name}]: nothing written (N10) ({simc.log})",
|
||||
simc.log == [] and simc.setpoint_a == 10.0)
|
||||
# The PM's shape: Solar at 10 A, Off whose 0 A is refused, a power cut before
|
||||
# the retry; the restart (keep) in Off writes the 0 A.
|
||||
simp = TSim(setpoint_a=0, windows=[(300.0, 1e9, "error")])
|
||||
rp = std(330, sim=simp, events={300: act("car_mode", "off")})
|
||||
flag = rp["store"].data.get(ctl_car.CAR_EXIT_KEY)
|
||||
simp.windows = []
|
||||
n0 = len(simp.log)
|
||||
rq = std(100, sim=simp, store=rp["store"], mode="off")
|
||||
new = [(x[0], x[2]) for x in simp.log[n0:]]
|
||||
check(f"C1: Off whose 0 A was refused, a power cut before its retry: the flag "
|
||||
f"is kept ({flag}), and the restart in Off writes the 0 A at once "
|
||||
f"({new})", flag is True and new[:1] and new[0][1] == 0.0
|
||||
and simp.setpoint_a == 0.0)
|
||||
# Shadow or control stopped at the start: no write, one warning.
|
||||
for stored, opts, ev, warn in (
|
||||
("solar", {"shadow_mode": "on"}, {}, True),
|
||||
("manual", {"shadow_mode": "on"}, {}, True),
|
||||
("solar", {"shadow_mode": "auto"},
|
||||
{0: lambda p, c: setattr(c, "auto", False)}, True),
|
||||
("off", {"shadow_mode": "on"}, {}, False)):
|
||||
n = LOG.mark()
|
||||
simw = SimCharger(setpoint_a=10)
|
||||
rr = std(120, sim=simw, opts=opts, events=ev, mode=stored)
|
||||
wl = [m for m in LOG.since(n, "WARNING") if "CHARGER_START_CURRENT" in m]
|
||||
notes_ = [x for _, x in rr["raised"] if x == messages.ID_CAR_START]
|
||||
check(f"C1 [stored {stored}, {opts.get('shadow_mode')}"
|
||||
f"{', stopped' if ev else ''}]: nothing written; "
|
||||
f"{'one warning' if warn else 'no warning'} "
|
||||
f"({len(wl)} log, {len(notes_)} notice)",
|
||||
simw.log == [] and len(wl) == (1 if warn else 0)
|
||||
and len(notes_) == (1 if warn else 0))
|
||||
check("C1: the warning's words, EN and NL",
|
||||
messages.car_start_current("10").body
|
||||
== "Charger still at 10 A from before the restart."
|
||||
and "10 A" in messages.car_start_current("10").body_nl)
|
||||
|
||||
# C5: each shutdown try waits at most 4 s for its read-back, so three fit in
|
||||
# 15 s against a charger that ignores the write.
|
||||
sim5 = TSim(setpoint_a=0, windows=[(299.5, 1e9, "ignore")])
|
||||
r5 = run("C5", std, 300, sim=sim5, finale=_shutdown)
|
||||
tr5 = [t for t, v in attempts(r5) if t >= 299]
|
||||
check(f"C5: a charger that ignores the 0 A: three tries ({tr5}) about 5 s "
|
||||
f"apart, each waiting 4 s at most, the inverters by 15 s "
|
||||
f"(+{_until(r5, 299.0)})",
|
||||
len(tr5) == 3 and all(4.0 <= b - a <= 6.0 for a, b in zip(tr5, tr5[1:]))
|
||||
and present(given(_until(r5, 299.0)))
|
||||
and _until(r5, 299.0) <= 15.0)
|
||||
|
||||
# C8: a charger outage in the middle of a phase change ends it; the first
|
||||
# write after the return is never a current (N12).
|
||||
for stage, dt in (("zero", 2), ("settle", 6)):
|
||||
sim8 = SimCharger(setpoint_a=0)
|
||||
sim8.ramp_w_s = 600.0
|
||||
rr = std(900, sun=step_fn((400, 600.0 + 4500.0), base=600.0 + 3000.0),
|
||||
sim=sim8, events={580 + dt: lambda p, c: p.ch.go_unavailable(True),
|
||||
620: lambda p, c: p.ch.go_unavailable(False)})
|
||||
w = [(t, a) for t, a, _ in cur_writes(rr) if t >= 620]
|
||||
check(f"C8 [{stage}]: the charger away from 580 + {dt} s to 620 s: the "
|
||||
f"sequence ends, nothing of it resumes: before the start rule's "
|
||||
f"120 s from the return only a 0 A may be written (here the "
|
||||
f"charger came back at the sequence's 0 A) ({w})",
|
||||
not [a for t, a in w if a > 0.0 and t < 740.0]
|
||||
and rr["trace"][625]["sp"] == 0.0)
|
||||
|
||||
# C9: Solar's 6 A lands late, then its 0 A pause is refused, then Off: the
|
||||
# exit 0 A and its retry still come (decided from the read-back).
|
||||
sim9 = SimCharger(setpoint_a=0)
|
||||
r9 = std(500, sim=sim9, sun=step_fn((190, 600.0 + 700.0),
|
||||
base=600.0 + 2300.0),
|
||||
opts={"ev_pause_min": 1},
|
||||
events={185: lambda p, c: setattr(p.ch, "lag_s", 12.0),
|
||||
205: lambda p, c: setattr(p.ch, "lag_s", 0.0),
|
||||
249: lambda p, c: setattr(p.ch, "refuse", "error"),
|
||||
255: act("car_mode", "off"),
|
||||
257: lambda p, c: setattr(p.ch, "refuse", None)})
|
||||
w9 = cur_writes(r9)
|
||||
z9 = [(t, ok) for t, a, ok in w9 if a == 0.0]
|
||||
check(f"C9: the 6 A late, the pause's 0 A refused, then Off: the 0 A is "
|
||||
f"tried again 60 s after the refusal and taken; the charger ends at "
|
||||
f"0 A ({w9})",
|
||||
len(z9) == 2 and present(nth(z9, 0)) and nth(z9, 0)[1] is False
|
||||
and nth(z9, 1)[1] is True and 59 <= nth(z9, 1)[0] - nth(z9, 0)[0] <= 61
|
||||
and sim9.setpoint_a == 0.0)
|
||||
|
||||
# T61: the start-up in Solar after a stop with no release.
|
||||
for k, sp, kw in (("10 A, keep", 10, {}),
|
||||
("16 A by another writer", 16, {}),
|
||||
|
||||
Reference in New Issue
Block a user