Modul Landwirtschaft ausgebaut

This commit is contained in:
2025-02-05 15:45:50 +01:00
parent 20643951e8
commit 1bbcf972a4
3 changed files with 94 additions and 5 deletions

View File

@@ -60,7 +60,43 @@
"name": "Kontakt_Volllast",
"caption": "Schaltkontakt Volllast",
"test": true
},
{
"type": "List",
"name": "Zeitplan",
"caption": "Zeitplan für Solltemperaturen",
"columns": [
{
"caption": "Uhrzeit",
"name": "Uhrzeit",
"width": "150px",
"add": "00:00",
"edit": {
"type": "ValidationTextBox"
}
},
{
"caption": "Solltemperatur",
"name": "Solltemperatur",
"width": "150px",
"add": 0,
"edit": {
"type": "NumberSpinner"
}
}
],
"add": true,
"delete": true,
"sort": {
"column": "Uhrzeit",
"direction": "ascending"
}
},
{
"type": "NumberSpinner",
"name": "Boilervolumen",
"caption": "Boilervolumen",
"suffix": "Liter"
}
]
}
}

View File

@@ -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")
);

View File

@@ -6,7 +6,7 @@
"compatibility": {
"version": "7.1"
},
"version": "1.028",
"version": "1.029",
"build": 0,
"date": 0
}