Meter DC charging only, on a monotonic clock
The charging session meter used the head unit's wall clock, which jumps when it picks up GPS or NTP time. One forward jump mid-charge invented both kWh and hours. The consumption counters already integrate on elapsedRealtime for exactly this reason; the session meter now does too, and keeps wall-clock values only as the start and end stamps a reader needs to place a session on a timeline. Intervals longer than five minutes are no longer bridged. A head unit that slept mid-charge came back and billed the whole gap at the last power reading, and a session interrupted overnight reported the night as charging time. Reported duration is metered charging time now, not the span from start to end. Sessions are metered on DC alone, at or above 10 kW. AC charging on this car is an overnight affair the head unit sleeps through, so its curve, duration and energy were guesses either way. The charging screen says so rather than letting the previous DC session's figures be read as the current AC charge. Also: - A daily consumption record uploaded after an offline spell carries the lifetime total as it stood at the close of that day. Every backlogged day used to be stamped with the current lifetime, which plots as a flat line and one cliff. - The offline session queue is capped at 50. It is a single SharedPreferences string read into memory in full, and nothing drained it while the cloud endpoint was unconfigured. - A long charge keeps the start of its curve: at 720 points the sample interval doubles and the curve is thinned, rather than dropping the oldest point. - The cloud sync throttle runs on the monotonic clock, and catch-up sends up to 10 days and 10 sessions per cycle rather than one and three. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1a37e52eda
commit
e9bfa1217b
@@ -967,7 +967,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
boolean charging = ChargingState.isCharging(
|
||||
code, s.getChargePortConnected(), s.getBatteryPowerKw(), s.getSpeedKmh());
|
||||
ChargeSessionTracker.Snapshot session = chargeSessionTracker.snapshot();
|
||||
chargeStatus.setText(charging ? (code != null && code == 10 ? "DC hızlı şarj" : "AC şarj")
|
||||
// Only DC is metered, so an AC charge must say so rather than let the readouts
|
||||
// below — which then describe the previous DC session — be read as this charge.
|
||||
boolean dc = ChargingState.isDcCharging(
|
||||
code, s.getChargePortConnected(), s.getBatteryPowerKw(), s.getSpeedKmh());
|
||||
chargeStatus.setText(dc ? "DC hızlı şarj"
|
||||
: charging ? "AC şarj (ölçülmüyor)"
|
||||
: (session.startedAtMs > 0 ? "Son şarj" : "Şarj yok"));
|
||||
chargeSoc.setText(fmt(s.getSocPercent(), "%.1f %%"));
|
||||
chargeStartSoc.setText(fmt(session.startSocPercent, "%.1f %%"));
|
||||
|
||||
Reference in New Issue
Block a user