72 lines
2.7 KiB
PHP
72 lines
2.7 KiB
PHP
<?php
|
|
class Pufferspeicher extends IPSModule
|
|
{
|
|
public function Create()
|
|
{
|
|
parent::Create();
|
|
|
|
$this->RegisterPropertyInteger("ZeitKonstante", 120);
|
|
$this->RegisterPropertyBoolean("Puffertemperatur_glätten", false);
|
|
$this->RegisterPropertyInteger("Interval", 5)
|
|
|
|
|
|
// Variabeln für Kommunkation mit Manager
|
|
$this->RegisterVariableInteger("Sperre_Prio", "Sperre_Prio");
|
|
$this->RegisterVariableInteger("PV_Prio", "PV_Prio");
|
|
$this->RegisterVariableBoolean("Idle", "Idle", "", 0);
|
|
$this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0);
|
|
$this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0);
|
|
$this->RegisterVariableString("PowerSteps", "PowerSteps");
|
|
$this->RegisterVariableInteger("Power", "Power", '', 0);
|
|
$this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving", "", true);
|
|
$this->RegisterVariableInteger("Leistung_Delta", "Leistung_Delta", "", 0);
|
|
// Hilfsvariabeln für Idle zustand
|
|
$this->RegisterPropertyInteger("IdleCounterMax", 2);
|
|
$this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0);
|
|
$this->SetValue("IdleCounter", 0);
|
|
// Initialisiere Idle
|
|
$this->SetValue("Idle", true);
|
|
$this->RegisterTimer("Timer_Do_UserCalc_Boiler",$this->ReadPropertyInteger("Interval")*1000,"IPS_RequestAction(" .$this->InstanceID .', "Do_UserCalc", "");');
|
|
}
|
|
}
|
|
|
|
public function ApplyChanges()
|
|
{
|
|
parent::ApplyChanges();
|
|
$this->SetTimerInterval("Timer_Do_UserCalc_Boiler",$this->ReadPropertyInteger("Interval")*1000);
|
|
}
|
|
|
|
|
|
private function ProcessIdleCounter()
|
|
{
|
|
// IdleCounter auslesen und verarbeiten
|
|
$idleCounter = $this->GetValue("IdleCounter");
|
|
if ($idleCounter > 0) {
|
|
$this->SetValue("Idle", false);
|
|
$this->SetValue("IdleCounter", $idleCounter - 1);
|
|
} else {
|
|
$this->SetValue("Idle", true);
|
|
}
|
|
}
|
|
private function CheckIdle($power)
|
|
{
|
|
$lastpower = GetValue("Aktuelle_Leistung");
|
|
if ($lastpower != GetValue("Aktuelle_Leistung")) {
|
|
$this->SetValue("Idle", false);
|
|
$this->SetValue(
|
|
"IdleCounter",
|
|
$this->ReadPropertyInteger("IdleCounterMax")
|
|
);
|
|
}
|
|
// IdleCounter auslesen und verarbeiten
|
|
$idleCounter = $this->GetValue("IdleCounter");
|
|
if ($idleCounter > 0) {
|
|
$this->SetValue("Idle", false);
|
|
$this->SetValue("IdleCounter", $idleCounter - 1);
|
|
} else {
|
|
$this->SetValue("Idle", true);
|
|
}
|
|
}
|
|
}
|
|
?>
|