Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ef8de26cb | ||
|
|
3083093e22 | ||
|
|
f62501174d | ||
|
|
49e010fdfb | ||
|
|
8d62abe36b |
@@ -144,3 +144,31 @@ one small set of facts and derives every path from them:
|
||||
`meter_max_age_s` is the bound (a silent meter: 0 A at
|
||||
`meter_max_age_s` + `ev_pause_min`).
|
||||
|
||||
## Rig round 2 (rig FAIL on 09b6af9), PM rulings
|
||||
|
||||
- **A short charger read gap** (chargers.py `CarTracker.observe`, shared by
|
||||
Solar, Manual and the peak guard): a reading missing for less than
|
||||
`stale_input_s` keeps the last trusted reading (`held`). A gap is a read
|
||||
that got no answer, or every required entity unavailable; one entity
|
||||
missing, a wrong power unit or the login off stay readings of their own
|
||||
(EV-03 round 4, unchanged); nothing is decided
|
||||
or written in that cycle (`ctl_car.car_step` returns), and it neither arms
|
||||
nor clears the stuck check. At `stale_input_s` the missing reading is taken
|
||||
as before (the safe path: the charger is gone, 0 A first on its return).
|
||||
This also ends the false PEAK_GUARD_FLOOR_LIMITED after one gap (EV-18
|
||||
T10(b) changed accordingly).
|
||||
- **Silent meter on `ha_signed`:** Solar's unknown-sun pause is timed from the
|
||||
meter's age: unknown since the age passed `meter_max_age_s`, so 0 A when the
|
||||
age reaches `meter_max_age_s` + `ev_pause_min` (330 s), checked every
|
||||
control cycle (bound 330 s + one cycle). Arrival sources are unchanged.
|
||||
- **No non-zero write while the meter is silent (SPIKE-06 C17, N8 strict):**
|
||||
while the meter's age is past `meter_max_age_s`, Solar sends no non-zero
|
||||
current: no retry, no raise, no phase change begun, and a phase change
|
||||
under way ends at its 0 A (no select after that, no closing current); the
|
||||
plan pauses. 0 A is always allowed. Also on a held read (`nz_block`).
|
||||
- **The age pause on a held read (C18):** on a held cycle Solar still steps
|
||||
(Manual does not), so a pause due on that cycle is not slipped; it can only
|
||||
write a NEW 0 A there (no retry to a charger that is not answering).
|
||||
- **Accepted (PM, P9g):** a frozen charger that also stops answering is
|
||||
flagged only once it answers again; the 15 s safe path covers the gap.
|
||||
|
||||
|
||||
@@ -498,8 +498,15 @@ class SunInputs:
|
||||
|
||||
def __init__(self, target_w=None, hold=False, auto=True, start_s=120.0,
|
||||
pause_s=300.0, spare_w=None, room_w=0.0, margin_w=100.0,
|
||||
first=DEFAULT_FIRST):
|
||||
first=DEFAULT_FIRST, unknown_s=0.0, silent=False):
|
||||
self.target_w, self.hold, self.auto = target_w, hold, auto
|
||||
# EV-20 rig round 2: how long the sun has already been unknown when
|
||||
# the cause is the meter's own age (`ha_signed`): the pause is timed
|
||||
# from that age, not from the cycle that noticed it.
|
||||
self.unknown_s = unknown_s
|
||||
# EV-20 SPIKE-06 C17 (N8): the meter is known silent (its age past
|
||||
# `meter_max_age_s`): no non-zero current goes out, only 0 A.
|
||||
self.silent = silent
|
||||
self.start_s, self.pause_s = start_s, pause_s
|
||||
self.spare_w, self.room_w, self.margin_w = spare_w, room_w, margin_w
|
||||
self.first = first
|
||||
@@ -563,7 +570,7 @@ class SolarPlan:
|
||||
self.switch, self._before = False, None
|
||||
|
||||
def step(self, now, *, target_w, n_now, auto, clamp, start_s, pause_s,
|
||||
hold=False, gap_ok=True):
|
||||
hold=False, gap_ok=True, unknown_s=0.0):
|
||||
"""`n_now`: the phases the car draws on now (1 for a one-phase car);
|
||||
`auto`: Solar may choose the phases; `gap_ok`: a phase change is
|
||||
allowed now (EV-04's one per `PHASE_GAP_S`); `hold`: readings late
|
||||
@@ -586,6 +593,11 @@ class SolarPlan:
|
||||
if self.a > 0.0:
|
||||
if self.unknown_since is None:
|
||||
self.unknown_since = now
|
||||
if unknown_s > 0.0:
|
||||
# ha_signed: unknown since the meter's age passed its
|
||||
# bound, so the pause comes at that age + `pause_s`.
|
||||
self.unknown_since = min(self.unknown_since,
|
||||
now - unknown_s)
|
||||
# A hold that began on a known low spare still ends on time.
|
||||
if now - self.unknown_since >= pause_s or (
|
||||
self.low_since is not None
|
||||
@@ -721,6 +733,8 @@ class SolarWriter(ManualWriter):
|
||||
self.stuck_starts = 0 # SPIKE-06 C12: starts under one stuck verdict
|
||||
self.stuck_wait = None # ... used up: the next start not before
|
||||
self.stuck_warned = False # ... and its one CHARGER_REFUSED was given
|
||||
self.nz_block = False # C17/C18: this step writes 0 A at most
|
||||
self.held_step = False # C18: a held read: only a NEW 0 A goes out
|
||||
|
||||
def owe_start(self) -> None:
|
||||
"""C1: the add-on starts in Off while an exit 0 A of its own was still
|
||||
@@ -828,7 +842,11 @@ class SolarWriter(ManualWriter):
|
||||
`MAX_TRIES` and never waits (0 A is the safe side)."""
|
||||
if self.hold:
|
||||
return
|
||||
if want > TOL_A and self.nz_block:
|
||||
return # C17/C18: 0 A only, no retry or raise
|
||||
if self.sent_a is not None and abs(self.sent_a - want) <= TOL_A:
|
||||
if self.held_step:
|
||||
return # C18: no retry to a charger not answering
|
||||
if self.taken or self.gave_up or (
|
||||
self.fail_at is not None
|
||||
and now - self.fail_at < RETRY_S):
|
||||
@@ -919,7 +937,7 @@ class SolarWriter(ManualWriter):
|
||||
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,
|
||||
clamp=clamp, start_s=sun.start_s, pause_s=sun.pause_s,
|
||||
gap_ok=gap_ok)
|
||||
gap_ok=gap_ok, unknown_s=getattr(sun, "unknown_s", 0.0))
|
||||
|
||||
@staticmethod
|
||||
def _drawing(r) -> bool:
|
||||
@@ -976,11 +994,18 @@ class SolarWriter(ManualWriter):
|
||||
|
||||
# ------------------------------------------------------------- step
|
||||
async def step(self, drv, r, *, mode, sun, clamp, now, tracker, writing,
|
||||
status, clock=None):
|
||||
status, clock=None, held=False):
|
||||
"""One cycle. `sun` is `SunInputs` (None outside Solar); `writing` is
|
||||
False in shadow mode, while control is stopped, under a safety stop
|
||||
and while stopping."""
|
||||
and while stopping. `held`: the charger missed this read and the last
|
||||
reading stands in (EV-20 round 2): the step may pause, never raise."""
|
||||
self._clock = clock or (lambda: now)
|
||||
# SPIKE-06 C17/C18: while the meter is silent, or on a held read, no
|
||||
# non-zero current goes out (no retry, no raise, no closing current
|
||||
# of a phase change); 0 A always may.
|
||||
self.nz_block = bool(held or (sun is not None
|
||||
and getattr(sun, "silent", False)))
|
||||
self.held_step = bool(held)
|
||||
entering = mode == SOLAR and self.mode_was != SOLAR
|
||||
self.mode_was = mode
|
||||
if entering:
|
||||
@@ -1121,6 +1146,15 @@ class SolarWriter(ManualWriter):
|
||||
gap = self._gap_ok(now)
|
||||
if self.sent_a == 0.0 and not self.taken:
|
||||
self.plan.ok_since = None # 0 A first, then the start rule
|
||||
if self.seq is not None and self.nz_block:
|
||||
# C17: a phase change under way ends at its 0 A; no select and no
|
||||
# closing current while the meter is silent. The plan pauses and
|
||||
# starts again by the start rule.
|
||||
self.seq = None
|
||||
self.plan.end_switch(False)
|
||||
self.plan.pause("unknown")
|
||||
await self._put(drv, 0.0, cur, now, tracker)
|
||||
return
|
||||
if self.seq is not None:
|
||||
self._plan_step(sun, now, clamp, self.plan.n, gap)
|
||||
if self.plan.a < CH.MIN_A:
|
||||
@@ -1163,7 +1197,7 @@ class SolarWriter(ManualWriter):
|
||||
return
|
||||
self._plan_step(sun, now, clamp, n_now, gap)
|
||||
want = self.amps_out(clamp)
|
||||
if want >= CH.MIN_A and self.plan.switch \
|
||||
if want >= CH.MIN_A and self.plan.switch and not self.nz_block \
|
||||
and self.plan.n != n_now and not self.single:
|
||||
if self.gave_up or (self.fail_at is not None
|
||||
and now - self.fail_at < RETRY_S):
|
||||
|
||||
@@ -255,6 +255,18 @@ def display_class(text) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def _is_gap(why) -> bool:
|
||||
"""EV-20: does this unavailable reading's cause mean "no answer" (a read
|
||||
gap), not a reading the charger gave?"""
|
||||
why = why or ""
|
||||
if why == "no answer":
|
||||
return True
|
||||
if why.startswith("no answer from "):
|
||||
gone = {x.strip() for x in why[len("no answer from "):].split(",")}
|
||||
return set(REQUIRED) <= gone
|
||||
return False
|
||||
|
||||
|
||||
def reading_from_states(states: dict) -> ChargerReading:
|
||||
"""A `ChargerReading` from `{role: state object or None}`. Pure."""
|
||||
def txt(role):
|
||||
@@ -719,6 +731,7 @@ class CarTracker:
|
||||
# write went out, kept at `begin_write` (the arming baseline). Empty: no
|
||||
# write begun, and `note_write` uses `sig`.
|
||||
pre_sig: tuple = ()
|
||||
held: bool = False # EV-20: the last reading stands in for a gap
|
||||
armed_at: float | None = None
|
||||
armed_sig: tuple | None = None
|
||||
sig: tuple | None = None
|
||||
@@ -735,6 +748,17 @@ class CarTracker:
|
||||
persist: bool = False # set when `today` changed, for the store
|
||||
|
||||
def observe(self, r: ChargerReading, now: float, now_utc, day: str):
|
||||
if not r.available and self.bad_since is None:
|
||||
self.bad_since, self.bad_since_utc = now, now_utc
|
||||
if self._held(r, now):
|
||||
# EV-20 rig round 2 (PM): a reading missing for less than
|
||||
# `stale_s` keeps the last trusted figure and decides nothing:
|
||||
# no write, no pause, and it neither arms nor clears the stuck
|
||||
# check. At `stale_s` the missing reading is taken as before.
|
||||
self.held = True
|
||||
self._status_edge(now, now_utc)
|
||||
return
|
||||
self.held = False
|
||||
self.reading = r
|
||||
self.obs_at = now
|
||||
self._corr_note(r, now)
|
||||
@@ -757,6 +781,16 @@ class CarTracker:
|
||||
self._timers(r, now)
|
||||
self._status_edge(now, now_utc)
|
||||
|
||||
def _held(self, r, now: float) -> bool:
|
||||
"""Is this missing reading a short gap behind a usable one? A gap is
|
||||
a read that failed (no answer at all) or Home Assistant showing every
|
||||
required entity unavailable. One entity missing, a wrong unit or the
|
||||
login off are readings of their own (EV-03), never held."""
|
||||
last = self.reading
|
||||
return (not r.available and _is_gap(r.why) and last is not None
|
||||
and last.available and self.last_ok is not None
|
||||
and now - self.last_ok < self.stale_s)
|
||||
|
||||
# -- reachability ----------------------------------------------------------
|
||||
def unreachable(self, now: float) -> bool:
|
||||
return self.bad_since is not None and now - self.bad_since >= UNREACHABLE_S
|
||||
|
||||
@@ -368,8 +368,15 @@ class CarMixin:
|
||||
cycle's read did) and writes only through `carmode`'s writers."""
|
||||
if not self.charger.configured():
|
||||
return
|
||||
held = bool(self.car.held)
|
||||
now = self.car_now()
|
||||
if self.car_mode != carmode.SOLAR:
|
||||
if held and self.car_mode != carmode.SOLAR \
|
||||
and not self.car_solar.engaged:
|
||||
# EV-20 rig round 2 (PM): the charger missed a read for less than
|
||||
# `stale_input_s`; the last trusted figure stands and nothing is
|
||||
# decided or written from the gap.
|
||||
return
|
||||
if self.car_mode != carmode.SOLAR and not held:
|
||||
await self.car_writer.step(
|
||||
self.charger, self.car.reading, mode=self.car_mode,
|
||||
want_a=self.car_a, want_phases=self.car_n, rev=self.car_rev,
|
||||
@@ -389,7 +396,7 @@ class CarMixin:
|
||||
sun=sun,
|
||||
clamp=self.car_clamp(), now=now, tracker=self.car,
|
||||
writing=self.car_writing(), status=self.car.status(now, True),
|
||||
clock=self.car_now)
|
||||
clock=self.car_now, held=held)
|
||||
|
||||
# ------------------------------------------------------- EV-20: Solar
|
||||
def car_may_charge(self, inv) -> bool:
|
||||
@@ -452,7 +459,29 @@ class CarMixin:
|
||||
hold=hold, auto=ph not in ("1", "3"),
|
||||
start_s=60.0 * carmode.solar_option(o, "ev_start_min"),
|
||||
pause_s=60.0 * carmode.solar_option(o, "ev_pause_min"),
|
||||
spare_w=spare, room_w=room, margin_w=margin, first=self.car_first)
|
||||
spare_w=spare, room_w=room, margin_w=margin, first=self.car_first,
|
||||
unknown_s=self._car_meter_over_s() if spare is None else 0.0,
|
||||
silent=self._car_meter_silent())
|
||||
|
||||
def _car_meter_silent(self) -> bool:
|
||||
"""SPIKE-06 C17 (N8): is the meter known silent (its age past
|
||||
`meter_max_age_s`)? Then Solar writes no non-zero current."""
|
||||
if not self.p1_enabled:
|
||||
return False
|
||||
age = self.p1.age_s()
|
||||
bound = float(self.o.get("meter_max_age_s", 30) or 30)
|
||||
return age is not None and age > bound
|
||||
|
||||
def _car_meter_over_s(self) -> float:
|
||||
"""EV-20 rig round 2 (PM): on `ha_signed`, how far the meter's age is
|
||||
past `meter_max_age_s`, so Solar's pause comes at that age +
|
||||
`ev_pause_min` (checked every cycle), not a cycle or two later."""
|
||||
if not self.p1_enabled \
|
||||
or str(self.o.get("meter_source") or "") != "ha_signed":
|
||||
return 0.0
|
||||
age = self.p1.age_s()
|
||||
bound = float(self.o.get("meter_max_age_s", 30) or 30)
|
||||
return 0.0 if age is None else max(0.0, age - bound)
|
||||
|
||||
def _car_sun_tick(self, mono) -> None:
|
||||
"""Solar kWh: per cycle, in Solar only, the car's power up to the sun
|
||||
|
||||
@@ -605,11 +605,14 @@ for nm, kw in (("T2", dict(house=H.shape(14000.0), b=const(800.0))),
|
||||
r10b, tr10b = H.run(a=ZERO, extra=unavailable(E + 1, E + 2), **kw)
|
||||
summary(f"T10(b) {nm}", r10b, tr10b)
|
||||
if nm == "T2":
|
||||
# EV-20 rig round 2 (PM): a charger read missing for less than
|
||||
# stale_input_s keeps the last trusted figure, so this one-cycle gap
|
||||
# is no longer an unknown car figure (was: the alarm for that cycle).
|
||||
check("T10(b) T2: the charger unavailable for one cycle (E+1): the "
|
||||
"alarm stands for that cycle only (Expected 5)",
|
||||
H.edges(tr10b) == [E + 1]
|
||||
and all(not x["alarm"] for x in H.window(tr10b, E + 2, E + 899))
|
||||
and all(x["explains"] for x in H.window(tr10b, E + 2, E + 899)
|
||||
"last trusted figure stands (EV-20), no alarm edge, the car "
|
||||
"explains every limited cycle",
|
||||
H.edges(tr10b) == [] and quiet(r10b, tr10b)
|
||||
and all(x["explains"] for x in H.window(tr10b, E, E + 899)
|
||||
if x["lim"]))
|
||||
else:
|
||||
check("T10(b) T5: the alarm at the base second and it stands",
|
||||
@@ -813,6 +816,21 @@ def per_quarter(ts):
|
||||
return out
|
||||
|
||||
|
||||
# EV-20 rig round 2: ONE failed charger read in the T2 shape. The tracker keeps
|
||||
# the last trusted figure for a gap under `stale_input_s`, so the car still
|
||||
# explains the peak and no floor alarm comes (rig: a false FLOOR_LIMITED 1-2 s
|
||||
# after a single read gap, on base and head).
|
||||
for gap in (1, 2):
|
||||
rg, trg = H.run(H.shape(14000.0), a=ZERO, b=const(800.0),
|
||||
extra={E + 30: lambda p, c: p.ch.go_unavailable(),
|
||||
E + 30 + gap: lambda p, c: p.ch.go_unavailable(
|
||||
False)})
|
||||
wg, limg = summary(f"T-gap {gap} s", rg, trg)
|
||||
check(f"T-gap: {gap} missed charger read(s) at E+30: no "
|
||||
f"goodwe_peak_soc_floor, no FLOOR_LIMITED ERROR, no red peak_guard "
|
||||
f"row, the car explains every limited cycle",
|
||||
quiet(rg, trg) and all_explained(limg))
|
||||
|
||||
# Cover off, the T9(c) liar at the reserve: the guard's own engagement flips
|
||||
# as the liar's figure is corroborated now and then (its input is
|
||||
# `car_exclude`), pre-existing (base: 4 edges). Printed, not graded here.
|
||||
|
||||
@@ -502,4 +502,175 @@ for race in (True, False):
|
||||
nevers(r, f"C13 controller [race={race}]")
|
||||
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n7. RIG ROUND 2: A SHORT CHARGER READ GAP; THE ha_signed PAUSE BY AGE")
|
||||
# =========================================================================== #
|
||||
# Full sun, Car first, charging 10 A from 120 s; the charger does not answer
|
||||
# for 1, 2 or 16 cycles at 600 s (Home Assistant shows it unavailable).
|
||||
def gap_run(n, beside=False):
|
||||
sim = SimCharger(setpoint_a=0)
|
||||
if beside:
|
||||
sim.lag_s = 1.0
|
||||
return S.drive(const(500.0), const(2900.0), dur=1100, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, sim=sim, beside=beside,
|
||||
events={600: lambda p, c: p.ch.go_unavailable(),
|
||||
600 + n: lambda p, c: p.ch.go_unavailable(False)})
|
||||
|
||||
|
||||
for n in (1, 2):
|
||||
for beside in (False, True):
|
||||
r = gap_run(n, beside)
|
||||
w = cur_writes(r)
|
||||
late = [(t, a) for t, a, _ in w if t >= 590]
|
||||
unk = [x["t"] for x in r["trace"] if 590 <= x["t"] < 1100
|
||||
and x["spare"] is None]
|
||||
check(f"read gap of {n} sample(s) at 600 s [beside={beside}]: no "
|
||||
f"write and no pause after it, the spare stays known (writes "
|
||||
f"from 590 s {late}, unknown {unk[:3]})",
|
||||
late == [] and unk == [] and r["sim"].power_w > 2000.0)
|
||||
nevers(r, f"read gap {n} [beside={beside}]")
|
||||
|
||||
# 16 s (>= stale_input_s): the safe path as before. The charger is taken as
|
||||
# gone; on its return Solar writes 0 A first (D2), then the start rule.
|
||||
r = gap_run(16)
|
||||
w = cur_writes(r)
|
||||
late = [(t, a) for t, a, _ in w if t >= 590]
|
||||
check(f"read gap of 16 s: the safe path, 0 A first on the return, then the "
|
||||
f"start rule ({late[:3]})",
|
||||
present(nth(late, 0)) and nth(late, 0)[1] == 0.0
|
||||
and 616 <= nth(late, 0)[0] <= 620 and present(nth(late, 1))
|
||||
and nth(late, 1)[1] > 0.0)
|
||||
|
||||
# The held figure neither arms nor clears the stuck check: a frozen reading
|
||||
# after an accepted write is still stuck, with a 2-sample gap inside the 60 s
|
||||
# (flagged at the first real reading at or after +60 s).
|
||||
tr = CH.CarTracker()
|
||||
for i in range(-5, 1):
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
tr.begin_write()
|
||||
tr.end_write(TS + 1)
|
||||
tr.note_write(TS, 10.0, 0.0, True)
|
||||
gone = CH.ChargerReading(why="no answer")
|
||||
st_at = None
|
||||
for i in range(1, 90):
|
||||
if i in (59, 60):
|
||||
tr.observe(gone, TS + i, UTC, DAY)
|
||||
else:
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
if st_at is None and tr.stuck(TS + i):
|
||||
st_at = i
|
||||
check(f"frozen reading with a 2-sample gap at +59/+60: still stuck, at the "
|
||||
f"first real reading after +60 (+{st_at})", st_at == 61)
|
||||
tr = CH.CarTracker()
|
||||
for i in range(-5, 1):
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
tr.begin_write()
|
||||
tr.end_write(TS + 1)
|
||||
tr.note_write(TS, 10.0, 0.0, True)
|
||||
for i in range(1, 70):
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
tr.observe(gone, TS + 70, UTC, DAY)
|
||||
check("a held gap does not clear a stuck verdict (+70 s gap, still stuck)",
|
||||
tr.stuck(TS + 70) and getattr(tr, "held", None) is True)
|
||||
|
||||
# ha_signed: the pause is timed from the meter's age (PM): unknown since the
|
||||
# age passed meter_max_age_s, so 0 A when the age reaches 330 s. A plan
|
||||
# stepped every 10 s (the rig's cycle) that first sees the unknown sun at age
|
||||
# 57 (a cycle or two after the bound passed) still pauses at the first step at
|
||||
# or after age 330 (bound: 330 + one cycle); timed from the noticing step it
|
||||
# would be age 357.
|
||||
plan = carmode.SolarPlan()
|
||||
plan.reset(1)
|
||||
kw = dict(n_now=1, auto=False, clamp=16.0, start_s=120.0, pause_s=300.0)
|
||||
t = 0.0
|
||||
while plan.a <= 0.0 and t < 400:
|
||||
plan.step(t, target_w=2900.0, **kw)
|
||||
t += 10.0
|
||||
age0 = t + 3.0 # the meter's last reading; the bound passes at +30
|
||||
paused_at = None
|
||||
while t < age0 + 400:
|
||||
age = t - age0
|
||||
over = max(0.0, age - 30.0)
|
||||
try:
|
||||
plan.step(t, target_w=None if age > 50.0 else 2900.0,
|
||||
unknown_s=over if age > 50.0 else 0.0, **kw)
|
||||
except TypeError: # a build without the age rule
|
||||
plan.step(t, target_w=None if age > 50.0 else 2900.0, **kw)
|
||||
if plan.a == 0.0 and paused_at is None:
|
||||
paused_at = age
|
||||
break
|
||||
t += 10.0
|
||||
check(f"ha_signed pause by age, plan stepped every 10 s: 0 A at meter age "
|
||||
f"{paused_at} (330 <= age <= 340)",
|
||||
paused_at is not None and 330.0 <= paused_at <= 340.0)
|
||||
# The controller hands Solar that age: 40 s after the meter went silent at
|
||||
# 300 s, `unknown_s` is 10 (age 40 - 30).
|
||||
seen = {}
|
||||
r = S.drive(const(500.0), const(2900.0), dur=360, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, opts={"ev_phases": "1"},
|
||||
events={300: lambda p, c: setattr(p, "meter_on", False),
|
||||
340: lambda p, c: seen.update(
|
||||
u=getattr(c.car_sun_inputs(p.clock[0]),
|
||||
"unknown_s", None))})
|
||||
check(f"ha_signed: 40 s after the meter went silent Solar is told the sun "
|
||||
f"has been unknown for 10 s ({seen})",
|
||||
seen.get("u") is not None and 9.0 <= seen["u"] <= 12.0)
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n8. SPIKE-06 ROUND 3: NO NON-ZERO WRITE WHILE THE METER IS SILENT (C17);")
|
||||
print(" THE AGE PAUSE ON A HELD READ (C18)")
|
||||
# =========================================================================== #
|
||||
# C17 (a): 7 A, a raise to 10 A at 340 s that the charger ignores, the meter
|
||||
# silent from 345 s (ha_signed). No re-send of the 10 A (the retry would come
|
||||
# at 400 s, meter age 55 s); 0 A when the age reaches 330 s.
|
||||
sim = TSim(setpoint_a=0, windows=[(335.0, 350.0, "ignore")])
|
||||
r = S.drive(const(500.0), lambda t: 3000.0 if t >= 340 else 2300.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0}, sim=sim,
|
||||
opts={"ev_phases": "1"},
|
||||
events={345: lambda p, c: setattr(p, "meter_on", False)})
|
||||
w = cur_writes(r)
|
||||
nz = [(t, a) for t, a, _ in w if a > 0.0 and t > 345 + 30]
|
||||
z = [t for t, a, _ in w if a == 0.0 and t > 345]
|
||||
raise_ = [(t, a, ok) for t, a, ok in w if 330 <= t <= 345]
|
||||
check(f"C17 (a): an ignored raise ({raise_}), then the meter silent from "
|
||||
f"345 s: no re-send while it is silent ({nz}), 0 A at meter age 330 "
|
||||
f"(+2) ({z[:1]})",
|
||||
present(nth(raise_, 0)) and nth(raise_, 0)[2] is False and nz == []
|
||||
and present(nth(z, 0)) and 345 + 329 <= nth(z, 0) <= 345 + 333)
|
||||
nevers(r, "C17 (a)")
|
||||
|
||||
# C17 (b): a 1 -> 3 phase change starts at 301 s (its 0 A); the meter has been
|
||||
# silent since 276 s, so its age passes 30 s at 307 s, before the closing
|
||||
# current (313 s without silence). The change ends at its 0 A: no closing
|
||||
# current, nothing non-zero until the meter is back.
|
||||
r = S.drive(const(500.0), const(7600.0), dur=900, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, car_phases=3,
|
||||
events={276: lambda p, c: setattr(p, "meter_on", False),
|
||||
800: lambda p, c: setattr(p, "meter_on", True)})
|
||||
w = cur_writes(r)
|
||||
seq0 = [t for t, a, _ in w if a == 0.0 and 295 <= t <= 305]
|
||||
nz = [(t, a) for t, a, _ in w if a > 0.0 and 306 < t < 800]
|
||||
check(f"C17 (b): a phase change under way when the meter goes silent ends at "
|
||||
f"its 0 A ({seq0}): no closing current, no non-zero write while silent "
|
||||
f"({nz}); writes {w[:6]}",
|
||||
present(nth(seq0, 0)) and nz == []
|
||||
and [a for t, a, _ in w if 301 <= t < 800][-1:] == [0.0])
|
||||
nevers(r, "C17 (b)")
|
||||
|
||||
# C18: a charger read gap on the very cycle the age pause is due (ha_signed,
|
||||
# meter silent from 300 s: due at 629 s without a gap, the meter's last sample
|
||||
# being at 299 s). The held cycle still steps Solar's pause: 0 A at 629 s, at
|
||||
# most one cycle later (f625011: 631 s with the gap from 629 s).
|
||||
for gap_at in (629, 630):
|
||||
r = S.drive(const(500.0), const(2900.0), dur=760, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, opts={"ev_phases": "1"},
|
||||
events={300: lambda p, c: setattr(p, "meter_on", False),
|
||||
gap_at: lambda p, c: p.ch.go_unavailable(),
|
||||
gap_at + 2: lambda p, c: p.ch.go_unavailable(False)})
|
||||
w = cur_writes(r)
|
||||
z = [t for t, a, _ in w if a == 0.0 and t > 300]
|
||||
check(f"C18: a 2-sample read gap from {gap_at} s, the age pause due at "
|
||||
f"629 s: 0 A at {z[:1]} (629-630)",
|
||||
present(nth(z, 0)) and 629 <= nth(z, 0) <= 630)
|
||||
|
||||
report()
|
||||
|
||||
Reference in New Issue
Block a user