EV-20 rig round 2: a short charger read gap keeps the last reading; ha_signed pause timed from the meter age
A charger reading missing for less than stale_input_s keeps the last trusted reading in CarTracker (shared by Solar, Manual and the peak guard): no decision or write in that cycle, no stuck arm or clear. At stale_input_s the safe path is unchanged. This also stops the false PEAK_GUARD_FLOOR_LIMITED after one gap (EV-18 T10(b) updated). On ha_signed Solar's unknown-sun pause comes at meter age meter_max_age_s + ev_pause_min, checked every cycle. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -498,8 +498,12 @@ 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):
|
||||
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
|
||||
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 +567,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 +590,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
|
||||
@@ -919,7 +928,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:
|
||||
|
||||
Reference in New Issue
Block a user