no message

This commit is contained in:
belevo\mh
2026-04-17 13:20:55 +02:00
parent 2939722a59
commit 38b335e7f7
+50 -2
View File
@@ -667,8 +667,56 @@ private function CalculateBatteryDistribution(float $pEvW, float $pSdlW): array
$this->SetValue("Aktuelle_Leistung_SDL", $pSdlW);
$this->SetValue("Aktuelle_Leistung_EV", $totalPower_ist + $pSdlW);
$eps = 0.01;
$aktEV = 0.0;
$aktSDL = 0.0;
// Optional: Wenn einer 0 ist -> aktiver Kanal bekommt totalPower_ist
if (abs($pEvW) < $eps && abs($pSdlW) < $eps) {
$aktEV = 0.0;
$aktSDL = 0.0;
} elseif (abs($pEvW) < $eps) {
$aktEV = 0.0;
$aktSDL = $totalPower_ist;
} elseif (abs($pSdlW) < $eps) {
$aktEV = $totalPower_ist;
$aktSDL = 0.0;
} else {
// Beide aktiv
$sameDirection = (($pEvW > 0 && $pSdlW > 0) || ($pEvW < 0 && $pSdlW < 0));
if ($sameDirection) {
// Regel A: gleiche Richtung -> Ist proportional nach |Soll| aufteilen
$sumAbs = abs($pEvW) + abs($pSdlW);
if ($sumAbs < $eps) {
// Fallback
$aktEV = $totalPower_ist / 2.0;
$aktSDL = $totalPower_ist / 2.0;
} else {
$aktEV = $totalPower_ist * (abs($pEvW) / $sumAbs);
$aktSDL = $totalPower_ist - $aktEV; // Summe bleibt exakt totalPower_ist
}
} else {
// Regel B: gegensätzliche Richtung -> Sollwerte anzeigen
$aktEV = $pEvW;
$aktSDL = $pSdlW;
}
}
$this->SetValue("Aktuelle_Leistung_EV", (float)$aktEV);
$this->SetValue("Aktuelle_Leistung_SDL", (float)$aktSDL);