From ecbee4980cb916ebb2f3b6d024509a310120332e Mon Sep 17 00:00:00 2001 From: TCFDONMEZ Date: Wed, 30 Sep 2026 23:24:15 +0300 Subject: [PATCH] Match DriveHub lifetime consumption calculation --- FatihsMG4-unstable-2.2.30.apk.sha256 | 1 - FatihsMG4-unstable-2.2.31.apk.sha256 | 1 + app/build.gradle | 4 ++-- .../com/evsuite/abrp/ConsumptionTracker.java | 21 ++++++++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) delete mode 100644 FatihsMG4-unstable-2.2.30.apk.sha256 create mode 100644 FatihsMG4-unstable-2.2.31.apk.sha256 diff --git a/FatihsMG4-unstable-2.2.30.apk.sha256 b/FatihsMG4-unstable-2.2.30.apk.sha256 deleted file mode 100644 index a27ca63..0000000 --- a/FatihsMG4-unstable-2.2.30.apk.sha256 +++ /dev/null @@ -1 +0,0 @@ -0069924daa5e61e5e0e5bd82976fe5adafbb3c020fde8b5f41755f4844a25d4f FatihsMG4-unstable-2.2.30.apk diff --git a/FatihsMG4-unstable-2.2.31.apk.sha256 b/FatihsMG4-unstable-2.2.31.apk.sha256 new file mode 100644 index 0000000..cb72828 --- /dev/null +++ b/FatihsMG4-unstable-2.2.31.apk.sha256 @@ -0,0 +1 @@ +2557622f673727f3ca0154bed75bc101fe20b2e228799777484664df36a595e7 FatihsMG4-unstable-2.2.31.apk diff --git a/app/build.gradle b/app/build.gradle index 47b0242..4885900 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,8 +34,8 @@ android { applicationId "com.evsuite.abrp" minSdk 27 targetSdk 36 - versionCode 47 - versionName "2.2.30" + versionCode 48 + versionName "2.2.31" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/evsuite/abrp/ConsumptionTracker.java b/app/src/main/java/com/evsuite/abrp/ConsumptionTracker.java index a9f95ea..85712de 100644 --- a/app/src/main/java/com/evsuite/abrp/ConsumptionTracker.java +++ b/app/src/main/java/com/evsuite/abrp/ConsumptionTracker.java @@ -48,6 +48,25 @@ final class ConsumptionTracker { Float power = s.getBatteryPowerKw(); double km = speed == null ? 0d : Math.max(0d, ((lastSpeed == null ? speed : lastSpeed) + speed) * 0.5d) * hours; + // DriveHub_Dort lifetime algorithm: trapezoidal speed, the same dead band + // and calibration factors, and net DC power including regeneration. + float currentSpeed = speed != null ? Math.abs(speed) + : (lastSpeed == null ? 0f : Math.abs(lastSpeed)); + float lifetimeSpeed = lastSpeed == null ? currentSpeed + : (Math.abs(lastSpeed) + currentSpeed) * 0.5f; + if (lifetimeSpeed < 2.5f) lifetimeSpeed = 0f; + else if (lifetimeSpeed > 90f) lifetimeSpeed *= 1.0035f; + else if (lifetimeSpeed > 30f) lifetimeSpeed *= 1.0015f; + double lifetimeKm = lifetimeSpeed * hours; + double lifetimeKwh = 0d; + if (power != null) { + if (currentSpeed == 0f && power < 0f) { + lifetimeKwh = 0d; + } else { + double effectiveKw = lastPower == null ? power : (lastPower + power) * 0.5d; + lifetimeKwh = effectiveKw * hours; + } + } Float vehicleConsumed = s.getVehicleConsumedKwh(); double kwh; if (vehicleConsumed != null && lastVehicleConsumedKwh != null @@ -63,7 +82,7 @@ final class ConsumptionTracker { } double dsoc = (lastSoc == null || s.getSocPercent() == null || Boolean.TRUE.equals(s.getChargePortConnected())) ? 0d : lastSoc - s.getSocPercent(); - lifetime = add(lifetime, km, kwh, hours, dsoc); + lifetime = add(lifetime, lifetimeKm, lifetimeKwh, hours, dsoc); String dayKey = "day_" + LocalDate.now(); SharedPreferences.Editor daily = prefs.edit(); save(daily, dayKey, add(load(dayKey), km, kwh, hours, dsoc));