no message
This commit is contained in:
@@ -81,18 +81,17 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
// =====================
|
// =====================
|
||||||
$now = microtime(true);
|
$now = microtime(true);
|
||||||
|
|
||||||
$lastTs = (float)$this->GetBufferSafe("Int_LastTs"); // Float!
|
$lastTs = (float)$this->GetBufferSafe("Int_LastTs"); // Float!
|
||||||
$Esdl_kWh = (float)$this->GetBufferSafe("Int_E_SDL_kWh"); // SDL-Konto in kWh (Integrator)
|
$Esdl_kWh = (float)$this->GetBufferSafe("Int_E_SDL_kWh"); // SDL-Konto in kWh
|
||||||
|
|
||||||
if ($lastTs <= 0.0) {
|
if ($lastTs <= 0.0) {
|
||||||
$lastTs = $now;
|
$lastTs = $now;
|
||||||
$Esdl_kWh = 0.0;
|
$Esdl_kWh = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dtSec = $now - $lastTs;
|
$dtSec = $now - $lastTs;
|
||||||
if ($dtSec < 0.0) $dtSec = 0.0;
|
if ($dtSec < 0.0) $dtSec = 0.0;
|
||||||
// optional: falls IPS mal hängt, keine riesigen Sprünge integrieren
|
if ($dtSec > 10.0) $dtSec = 10.0; // optional: Kappe bei Aussetzern
|
||||||
if ($dtSec > 10.0) $dtSec = 10.0;
|
|
||||||
|
|
||||||
$dtH = $dtSec / 3600.0;
|
$dtH = $dtSec / 3600.0;
|
||||||
|
|
||||||
@@ -163,8 +162,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
}
|
}
|
||||||
$EV_SOC = is_finite($EV_SOC) ? max(0.0, min(100.0, $EV_SOC)) : 0.0;
|
$EV_SOC = is_finite($EV_SOC) ? max(0.0, min(100.0, $EV_SOC)) : 0.0;
|
||||||
|
|
||||||
// SDL_SOC im Fenster (wie du es früher hattest – hier konstant, wenn du willst)
|
// SDL_SOC (wie in deinem alten Code im Fenster)
|
||||||
// Wenn du hier lieber dynamisch willst, sag kurz Bescheid.
|
|
||||||
$denSDL = ($capKWh - $upKWh + $underKWh);
|
$denSDL = ($capKWh - $upKWh + $underKWh);
|
||||||
if ($denSDL > 0.0) {
|
if ($denSDL > 0.0) {
|
||||||
$SDL_SOC = 100.0 * $underKWh / $denSDL;
|
$SDL_SOC = 100.0 * $underKWh / $denSDL;
|
||||||
@@ -186,7 +184,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
// Obere Grenze: EV = 100%
|
// Obere Grenze: EV = 100%
|
||||||
$EV_SOC = 100.0;
|
$EV_SOC = 100.0;
|
||||||
|
|
||||||
// SDL_SOC (deine bestehende obere Formel)
|
// SDL_SOC (deine obere Formel)
|
||||||
$den1 = ($capKWh - $real_kWh + $underKWh);
|
$den1 = ($capKWh - $real_kWh + $underKWh);
|
||||||
$den2 = (2.0 * $underKWh);
|
$den2 = (2.0 * $underKWh);
|
||||||
if ($den1 > 0.0 && $den2 > 0.0) {
|
if ($den1 > 0.0 && $den2 > 0.0) {
|
||||||
@@ -209,7 +207,7 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
// Untere Grenze: EV = 0%
|
// Untere Grenze: EV = 0%
|
||||||
$EV_SOC = 0.0;
|
$EV_SOC = 0.0;
|
||||||
|
|
||||||
// SDL_SOC (deine bestehende untere Formel)
|
// SDL_SOC (deine untere Formel)
|
||||||
$den = $upKWh + $underKWh;
|
$den = $upKWh + $underKWh;
|
||||||
$SDL_SOC = ($den > 0.0) ? ($real_kWh * 100.0 / $den) : 0.0;
|
$SDL_SOC = ($den > 0.0) ? ($real_kWh * 100.0 / $den) : 0.0;
|
||||||
$SDL_SOC = is_finite($SDL_SOC) ? max(0.0, min(100.0, $SDL_SOC)) : 0.0;
|
$SDL_SOC = is_finite($SDL_SOC) ? max(0.0, min(100.0, $SDL_SOC)) : 0.0;
|
||||||
@@ -275,14 +273,15 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
// ============================
|
||||||
// 1) EV-SoC "normal" (physikalisch) ohne Integrator
|
// EV Anzeige: "normal" physikalisch (ja: aus realem SoC!)
|
||||||
// ============================
|
// ============================
|
||||||
$evPosPct = ($EV_kWh_ges > 0.0) ? ($real_kWh_ev_ges / $EV_kWh_ges * 100.0) : 0.0;
|
$evPosPct = ($EV_kWh_ges > 0.0) ? ($real_kWh_ev_ges / $EV_kWh_ges * 100.0) : 0.0;
|
||||||
$evPosPct = max(0.0, min(100.0, $evPosPct));
|
$evPosPct = max(0.0, min(100.0, $evPosPct));
|
||||||
$this->SetIdentValue("SoC_EV", round($evPosPct, 3));
|
$this->SetIdentValue("SoC_EV", round($evPosPct, 3));
|
||||||
|
|
||||||
// ============================
|
// ============================
|
||||||
// 2) SDL-SoC integriert mit Nennleistung_Soll_SDL (virtuell)
|
// SDL Anzeige: integriert mit Nennleistung_Soll_SDL
|
||||||
|
// UND WICHTIG: bei Soll = 0 -> SoC stehen lassen (kein Resync!)
|
||||||
// ============================
|
// ============================
|
||||||
$pSdlSollW = (float)GetValue($this->GetIDForIdent("Nennleistung_Soll_SDL"));
|
$pSdlSollW = (float)GetValue($this->GetIDForIdent("Nennleistung_Soll_SDL"));
|
||||||
$epsW = 1.0;
|
$epsW = 1.0;
|
||||||
@@ -293,17 +292,14 @@ class Bat_EV_SDL_V3_Beta extends IPSModule
|
|||||||
$maxSDL_dis = $sdlDisKW_ges * 1000.0;
|
$maxSDL_dis = $sdlDisKW_ges * 1000.0;
|
||||||
$pSdlSollW = max(-$maxSDL_dis, min($maxSDL_ch, $pSdlSollW));
|
$pSdlSollW = max(-$maxSDL_dis, min($maxSDL_ch, $pSdlSollW));
|
||||||
|
|
||||||
// Init SDL-Konto einmalig auf physikalische Referenz
|
// Init SDL-Konto einmalig auf physikalische Referenz (nur beim ersten Lauf)
|
||||||
if ($this->GetBufferSafe("Int_Init_SDL") !== "1") {
|
if ($this->GetBufferSafe("Int_Init_SDL") !== "1") {
|
||||||
$Esdl_kWh = $real_kWh_sdl_ges;
|
$Esdl_kWh = $real_kWh_sdl_ges;
|
||||||
$this->SetBuffer("Int_Init_SDL", "1");
|
$this->SetBuffer("Int_Init_SDL", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wenn SDL inaktiv: hart auf Referenz (damit nichts driftet)
|
// Nur wenn aktiv integrieren, sonst: NICHTS -> Konto bleibt stehen
|
||||||
if (!$sdlActive) {
|
if ($sdlActive) {
|
||||||
$Esdl_kWh = $real_kWh_sdl_ges;
|
|
||||||
} else {
|
|
||||||
// Integration: (+) laden -> steigt, (-) entladen -> fällt
|
|
||||||
$Esdl_kWh += (($pSdlSollW / 1000.0) * $dtH);
|
$Esdl_kWh += (($pSdlSollW / 1000.0) * $dtH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user