no message
This commit is contained in:
@@ -67,33 +67,25 @@ class Verbraucher_extern extends IPSModule
|
||||
}
|
||||
|
||||
|
||||
private function berechneKombinationen(array $verbraucherListe, float $power = null)
|
||||
private function berechneKombinationen(array $verbraucherListe)
|
||||
{
|
||||
$kombinationen = [];
|
||||
$this->kombinationenRekursiv($verbraucherListe, [], $kombinationen, $power);
|
||||
return $kombinationen;
|
||||
}
|
||||
|
||||
private function kombinationenRekursiv(array $verbraucherListe, array $aktuelleKombi, array &$kombinationen, float $power = null)
|
||||
{
|
||||
if (empty($verbraucherListe)) {
|
||||
$summe = array_sum($aktuelleKombi);
|
||||
if ($power === null || $summe <= $power) {
|
||||
$kombinationen[] = $summe;
|
||||
|
||||
$kombinationen = [0];
|
||||
|
||||
foreach ($verbraucherListe as $verbraucher) {
|
||||
|
||||
if ($verbraucher['Read_Var'] == 1) {
|
||||
$tempListe = $kombinationen;
|
||||
foreach ($tempListe as &$wert) {
|
||||
$wert += $verbraucher['P_Nenn'];
|
||||
}
|
||||
unset($wert);
|
||||
$kombinationen = array_merge($kombinationen, $tempListe);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$verbraucher = array_shift($verbraucherListe);
|
||||
if ($this->GetValue($verbraucher['Read_Var']) == 1) {
|
||||
$this->kombinationenRekursiv($verbraucherListe, array_merge($aktuelleKombi, [$verbraucher['P_Nenn']]), $kombinationen, $power);
|
||||
}
|
||||
$this->kombinationenRekursiv($verbraucherListe, $aktuelleKombi, $kombinationen, $power);
|
||||
$kombinationen = array_unique(sort($kombinationen));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
|
||||
public function SetAktuelle_Leistung(float $power) {
|
||||
$this->CheckIdle($power);
|
||||
@@ -106,15 +98,17 @@ class Verbraucher_extern extends IPSModule
|
||||
$pNenn = $verbraucher['P_Nenn'];
|
||||
$this->SetValue($writeVarID, in_array($pNenn, $kombinationen) ? 1 : 0);
|
||||
}
|
||||
$this->SetValue("Leistung_Delta", $power - array_sum($kombinationen));
|
||||
$this->SetValue("Leistung_Delta", GetValue($this->ReadPropertyInteger("delta_power")));
|
||||
}
|
||||
|
||||
public function GetCurrentData(bool $Peak)
|
||||
{
|
||||
$this->SetValue("Is_Peak_Shaving", $Peak);
|
||||
SetValue($this->ReadPropertyInteger("Is_Peak"), $Peak);
|
||||
|
||||
$verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true);
|
||||
$kombinationen = $this->berechneKombinationen($verbraucherListe);
|
||||
$this->SetValue("PowerSteps", implode(", ", $kombinationen));
|
||||
$this->SetValue("PowerSteps", json_encode($kombinationen));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user