EV-51: Solar decides every meter-age rule on the writer step's own age; DEBUG line per step
The writer step took the meter age from the snapshot of the previous cycle (silent / unknown_s / hold), so in production order the silent-meter pause came one cycle late (C21) and a start or raise could still be written at an own age of 31-39 s (C22, N8). The step now judges its own age: the pause timing and held_pause, the non-zero write block (nz_block), and the late-readings hold with its stale rule. Meter values stay from the snapshot; car.held / car.reading and the arrival sources' spare-unknown check are unchanged. Also: one DEBUG line per Solar writer step (time, meter age, decision, write); tools/ev20_sun.drive takes cyc / phase / jitter / cset (default unchanged); test_ev51.py (T1-T43, N1-N12); DECISIONS states the rule once. Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -498,8 +498,13 @@ 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, unknown_s=0.0, silent=False):
|
||||
first=DEFAULT_FIRST, unknown_s=0.0, silent=False,
|
||||
meter_back=False, age_s=None):
|
||||
self.target_w, self.hold, self.auto = target_w, hold, auto
|
||||
# EV-51: the meter's own age at the writer step (None: no reading), and
|
||||
# `meter_back`: the cycle's snapshot said "meter too old" but the step's
|
||||
# own age says a new reading came, so no unknown timer is carried over.
|
||||
self.meter_back, self.age_s = meter_back, age_s
|
||||
# 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.
|
||||
@@ -570,11 +575,15 @@ 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, unknown_s=0.0):
|
||||
hold=False, gap_ok=True, unknown_s=0.0, meter_back=False):
|
||||
"""`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
|
||||
under the stale bound, everything stands."""
|
||||
under the stale bound, everything stands. `meter_back` (EV-51): the
|
||||
meter's own age is fresh again at this step: the unknown timer that
|
||||
counted its silence starts over."""
|
||||
if meter_back:
|
||||
self.unknown_since = None
|
||||
if hold:
|
||||
# Readings late under the stale bound: nothing changes, but a
|
||||
# hold or an unknown spare that has run its time still pauses
|
||||
@@ -937,7 +946,8 @@ 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, unknown_s=getattr(sun, "unknown_s", 0.0))
|
||||
gap_ok=gap_ok, unknown_s=getattr(sun, "unknown_s", 0.0),
|
||||
meter_back=getattr(sun, "meter_back", False))
|
||||
|
||||
@staticmethod
|
||||
def _drawing(r) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user