Modul Landwirtschaft ausgebaut
This commit is contained in:
@@ -14,6 +14,9 @@ class Boiler_2_Stufig_Landwirtschaft extends IPSModule
|
||||
$this->RegisterPropertyInteger("Kontakt_Teillast", 0);
|
||||
$this->RegisterPropertyInteger("Kontakt_Volllast", 0);
|
||||
$this->RegisterPropertyBoolean("Boilertemperatur_glätten", false);
|
||||
$this->RegisterPropertyInteger("Boilervolumen", 300);
|
||||
$this->RegisterPropertyString("Zeitplan", "");
|
||||
|
||||
|
||||
// Boiler spezifische Variablen
|
||||
|
||||
@@ -78,6 +81,45 @@ class Boiler_2_Stufig_Landwirtschaft extends IPSModule
|
||||
}
|
||||
}
|
||||
|
||||
function getNextTimeAndTemperature($zeitplan) {
|
||||
if (empty($zeitplan)) {
|
||||
return null;
|
||||
}
|
||||
$currentTime = date('H:i');
|
||||
foreach ($zeitplan as $entry) {
|
||||
if ($entry['Uhrzeit'] > $currentTime) {
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
// Falls keine spätere Uhrzeit gefunden wird, nimm den ersten Eintrag am nächsten Tag
|
||||
return $zeitplan[0];
|
||||
}
|
||||
|
||||
function calculateRemainingTime($nextTime) {
|
||||
$currentTime = new DateTime();
|
||||
$nextDateTime = DateTime::createFromFormat('H:i', $nextTime);
|
||||
if ($nextDateTime < $currentTime) {
|
||||
$nextDateTime->modify('+1 day');
|
||||
}
|
||||
$interval = $currentTime->diff($nextDateTime);
|
||||
return $interval->h + ($interval->i / 60);
|
||||
}
|
||||
|
||||
function calculateRequiredHeat($boilervolumen, $tempDiff) {
|
||||
// Annahme: spezifische Wärmekapazität von Wasser = 4.186 J/g°C
|
||||
// 1 Liter Wasser = 1000 Gramm
|
||||
$specificHeatCapacity = 4.186; // J/g°C
|
||||
$waterMass = $boilervolumen * 1000; // Gramm
|
||||
return $specificHeatCapacity * $waterMass * $tempDiff; // Joules
|
||||
}
|
||||
|
||||
function canBoilerReachTemperature($boilervolumen, $boilerTemper, $nextTemp, $remainingTime, $vollleistung) {
|
||||
$tempDiff = $nextTemp - $boilerTemper;
|
||||
$requiredHeat = calculateRequiredHeat($boilervolumen, $tempDiff);
|
||||
$availableHeat = $vollleistung * $remainingTime * 3600; // Leistung in Watt * Zeit in Sekunden
|
||||
return $availableHeat >= $requiredHeat;
|
||||
}
|
||||
|
||||
// Methode zum Setzen des aktuellen Stromverbrauchs
|
||||
public function SetAktuelle_Leistung(int $power)
|
||||
{
|
||||
@@ -158,8 +200,6 @@ class Boiler_2_Stufig_Landwirtschaft extends IPSModule
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$boilerTemp = $this->GetValue("Boilertemperatur");
|
||||
$minTemp = $this->GetValue("Mindesttemperatur");
|
||||
$maxTemp = $this->GetValue("Maximaltemperatur");
|
||||
@@ -167,6 +207,19 @@ class Boiler_2_Stufig_Landwirtschaft extends IPSModule
|
||||
$teilLeistung = $this->ReadPropertyInteger("BoilerLeistungTeillast");
|
||||
$vollLeistung = $this->ReadPropertyInteger("BoilerLeistungVolllast");
|
||||
|
||||
|
||||
$nextEntry = getNextTimeAndTemperature($this->ReadPropertyInteger("Zeitplan"));
|
||||
if ($nextEntry !== null) {
|
||||
$remainingTime = calculateRemainingTime($nextEntry['Uhrzeit']);
|
||||
$nextTemp = $nextEntry['Solltemperatur'];
|
||||
|
||||
if (!canBoilerReachTemperature($this->ReadPropertyInteger("Boilervolumen"), $boilerTemp, $nextTemp, $remainingTime, $vollLeistung)) {
|
||||
$minTemp = $nextTemp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$AktuelleVollast = GetValue(
|
||||
$this->ReadPropertyInteger("Kontakt_Volllast")
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user