EV-16: hold the Car Why text while car_over holds and the guard floor flag toggles
Display only: the 'are at' / 'give all they can' text changes only when the other state has stood for 180 s (the car_over off hold); SoC unread is never 'are at'. Cleared when car_over drops, on unplug and with cover off. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,7 @@ class CarMixin:
|
||||
self.car_over = False # ... held: the card and row say so
|
||||
self._car_over_since = None
|
||||
self._car_over_gone = None
|
||||
self._car_why_hold = None # EV-16: the held Car Why (display)
|
||||
self._car_batt_prev = self._car_batt_prev2 = None
|
||||
self._car_hx_prev = None # EV-19: last cycle's (held, car W)
|
||||
self._car_need_real = self._car_need_excl = False # EV-10 latches
|
||||
@@ -398,6 +399,7 @@ class CarMixin:
|
||||
self._car_over_gone = mono
|
||||
if mono - self._car_over_gone >= OVER_OFF_HOLD_S:
|
||||
self.car_over, self._car_over_since = False, None
|
||||
self._car_why_hold = None # EV-16: display only
|
||||
self._car_over_gone = None
|
||||
|
||||
def _car_explains_alarm(self, real_proj, guard, target_w, w) -> bool:
|
||||
@@ -497,6 +499,7 @@ class CarMixin:
|
||||
# The session is over: that is a real end, with no hold.
|
||||
self.car_over = False
|
||||
self._car_over_since = self._car_over_gone = None
|
||||
self._car_why_hold = None # EV-16: display only
|
||||
if s not in (chargers.NONE_, None) and self._car_prev_state in (
|
||||
chargers.NONE_, None):
|
||||
self._car_session += 1
|
||||
|
||||
@@ -1301,6 +1301,32 @@ def _car_why(key, c, good):
|
||||
return _t("car.why." + (key if key else "wait"))
|
||||
|
||||
|
||||
# EV-16: the Why of "car over the limit" follows the guard's floor flag, which
|
||||
# toggles cycle by cycle at the reserve. The text is held: it changes only when
|
||||
# the other state has stood for as long as the car_over row's own hold.
|
||||
WHY_HOLD_S = 180.0 # = ctl_car.OVER_OFF_HOLD_S (tested)
|
||||
|
||||
|
||||
def _over_why_is_floor(c, pg) -> bool:
|
||||
"""True: "are at {pct}"; False: "give all they can". Display only: the
|
||||
state lives in `c._car_why_hold` and nothing in control reads it."""
|
||||
mono = c.car_now()
|
||||
cand = (pg.floor_limited and pg.soc is not None) if pg is not None \
|
||||
else None
|
||||
h = getattr(c, "_car_why_hold", None)
|
||||
if h is None:
|
||||
h = [bool(cand), None] # shown, since when cand differs
|
||||
elif cand is None or cand == h[0]:
|
||||
h[1] = None
|
||||
else:
|
||||
if h[1] is None:
|
||||
h[1] = mono
|
||||
if mono - h[1] >= WHY_HOLD_S:
|
||||
h = [cand, None]
|
||||
c._car_why_hold = h
|
||||
return h[0]
|
||||
|
||||
|
||||
def _car_manual_why(c, key):
|
||||
"""The Why of Manual: what you set, and what the peak limit does about it.
|
||||
Plan lines: two sentences of at most 12 words."""
|
||||
@@ -1311,9 +1337,11 @@ def _car_manual_why(c, key):
|
||||
if c.car_over:
|
||||
pg = getattr(c, "peak_guard", None)
|
||||
if not c.car_cover:
|
||||
c._car_why_hold = None
|
||||
return _t("car.why.manual_nocover", a=a)
|
||||
return _t("car.why.manual_over" if pg is not None and pg.floor_limited
|
||||
return _t("car.why.manual_over" if _over_why_is_floor(c, pg)
|
||||
else "car.why.manual_full", a=a, pct=pct)
|
||||
c._car_why_hold = None
|
||||
if c.shadow:
|
||||
t, n = w.would if w.would is not None else (c.car_a, c.car_n)
|
||||
return _t("car.why.manual_would", a=f"{float(t):.0f}",
|
||||
|
||||
Reference in New Issue
Block a user