This commit is contained in:
@@ -78,6 +78,40 @@ final class WarmwasserRegler
|
||||
return array_merge([0], array_column($stufen, 'Leistung_W'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $leistungswerte
|
||||
* @return list<int>
|
||||
*/
|
||||
public static function leistungsangebot(
|
||||
bool $peakbetrieb,
|
||||
float $temperatur,
|
||||
float $mindesttemperatur,
|
||||
float $maximaltemperatur,
|
||||
float $hysterese,
|
||||
bool $stufeAktiv,
|
||||
array $leistungswerte
|
||||
): array {
|
||||
if ($hysterese < 0.0 || $leistungswerte === []) {
|
||||
throw new InvalidArgumentException('Hysterese und Leistungswerte sind ungueltig.');
|
||||
}
|
||||
|
||||
$mindestladung = $temperatur < $mindesttemperatur
|
||||
|| ($temperatur < $mindesttemperatur + $hysterese && $stufeAktiv);
|
||||
if ($peakbetrieb) {
|
||||
return $mindestladung ? $leistungswerte : [0];
|
||||
}
|
||||
if ($mindestladung) {
|
||||
return [max($leistungswerte)];
|
||||
}
|
||||
if ($temperatur < $maximaltemperatur - $hysterese
|
||||
|| ($temperatur < $maximaltemperatur && $stufeAktiv)
|
||||
) {
|
||||
return $leistungswerte;
|
||||
}
|
||||
|
||||
return [0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{Stufe: int, Leistung_W: int, KontaktID: int}> $stufen
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user