Release 0.25.0 #276
@@ -432,8 +432,10 @@ class CarMixin:
|
||||
if late is not None and self._car_late_mono is not None:
|
||||
late += max(0.0, now - self._car_late_mono)
|
||||
own.hold = late is not None and late < stale
|
||||
if late is not None and late >= stale:
|
||||
own.spare_w = own.target_w = None # the stale rule, on own late
|
||||
if own.silent or (late is not None and late >= stale):
|
||||
# The stale rule on the step's own age / own late (C23): a spare
|
||||
# read from data the own age calls old starts or raises nothing.
|
||||
own.spare_w = own.target_w = None
|
||||
return own
|
||||
|
||||
async def _car_step_run(self, held, now, sun) -> None:
|
||||
|
||||
@@ -528,7 +528,8 @@ def _sets(r):
|
||||
|
||||
|
||||
_real_own = getattr(Controller, "car_sun_own", None)
|
||||
for first, sun in (("car", 2900.0), ("batteries", 7900.0)):
|
||||
for first, sun, soc in (("car", 2900.0, 100.0), ("car", 2900.0, 50.0),
|
||||
("batteries", 7900.0, 50.0)):
|
||||
sets = []
|
||||
for own in (True, False):
|
||||
if _real_own is not None:
|
||||
@@ -537,8 +538,7 @@ for first, sun in (("car", 2900.0), ("batteries", 7900.0)):
|
||||
kw = dict(first=first, sun=sun, dur=760, cyc=5, phase=0, race=True)
|
||||
STEPS.clear()
|
||||
r = S.drive(S.const(500.0), S.const(sun), dur=760, first=first,
|
||||
socs={"a": 100.0, "b": 100.0} if first == "car"
|
||||
else {"a": 50.0, "b": 50.0}, opts=dict(OPT1),
|
||||
socs={"a": soc, "b": soc}, opts=dict(OPT1),
|
||||
events={SIL: lambda p, c: setattr(p, "meter_on", False)},
|
||||
cyc=5, phase=0, race=True)
|
||||
finally:
|
||||
@@ -546,9 +546,13 @@ for first, sun in (("car", 2900.0), ("batteries", 7900.0)):
|
||||
Controller.car_sun_own = _real_own
|
||||
sets.append(_sets(r))
|
||||
sa, sb = sets
|
||||
check(f"T24 [{first} first, sun {sun:.0f}]: the batteries' setpoints are "
|
||||
f"the same on every cycle whichever age the writer step uses "
|
||||
f"({len(sa)} writes)", sa == sb and bool(sa))
|
||||
sil_a = [x for x in sa if x[0] >= SIL]
|
||||
sil_b = [x for x in sb if x[0] >= SIL]
|
||||
check(f"T24 / N5 [{first} first, sun {sun:.0f}, SoC {soc:.0f}]: the batteries' setpoints "
|
||||
f"are the same on every cycle, and in the silence from {SIL} s, "
|
||||
f"whichever age the writer step uses ({len(sa)} writes, "
|
||||
f"{len(sil_a)} in the silence)",
|
||||
sa == sb and sil_a == sil_b and (soc >= 100.0 or bool(sil_a)))
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n4. DOCS (T26)")
|
||||
@@ -869,4 +873,32 @@ for l0 in (101, 103, 105):
|
||||
f"({nz43})", cross["now"] == 120.0 and not cross["writes"]
|
||||
and not nz43)
|
||||
|
||||
# T44 (C23, PM): a start due just after the silence begins. No plan start and
|
||||
# no non-zero write from data the step's own age calls old (> 30 s); after the
|
||||
# meter returns the start comes only from a fresh reading, with its dwell.
|
||||
def _c23(cyc):
|
||||
bad = []
|
||||
for onset in range(88, 100):
|
||||
back = onset + 60
|
||||
r, st = run_log(go, onset=onset, dur=back + 200, cyc=cyc, phase=0,
|
||||
race=True,
|
||||
events={back: lambda p, c: setattr(p, "meter_on", True)})
|
||||
stale_start = [(x["now"], round(x["age"], 1)) for x in st
|
||||
if x["age"] is not None and x["age"] > 30.0
|
||||
and x["a0"] <= 0.0 < x["a1"]]
|
||||
nzw = [(x["now"], w[0], x["snap_tgt"]) for x in st for w in x["writes"]
|
||||
if w[0] > 0.0]
|
||||
late_nz = [x for x in nzw if x[2] is None] # from a None target
|
||||
if stale_start or n8(st) or late_nz:
|
||||
bad.append((onset, stale_start[:1], nzw[:1]))
|
||||
return bad
|
||||
|
||||
|
||||
for cyc in (5, 10):
|
||||
bad = _c23(cyc)
|
||||
check(f"T44 (C23) [{cyc} s race]: a start due just after the silence "
|
||||
f"(onset 88-99, back 60 s later): no plan start at own age > 30, no "
|
||||
f"non-zero write from old data; the start only from a fresh reading "
|
||||
f"(a start at own age <= 30 is the normal dwell) ({len(bad)} bad: {bad[:2]})", not bad)
|
||||
|
||||
report()
|
||||
|
||||
Reference in New Issue
Block a user