159 lines
6.1 KiB
PHP
159 lines
6.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Belevo\EnelixEMS\SymconTest\TestContext;
|
|
|
|
return static function (TestContext $test): void {
|
|
$kontakt1 = $test->createActionVariable('WP Kontakt 1');
|
|
$kontakt2 = $test->createActionVariable('WP Kontakt 2');
|
|
$rueckmeldung = $test->createVariable(0, 'WP läuft', false);
|
|
$waermepumpe = $test->createInstance(
|
|
'{A31C9274-54F7-4BD2-9804-7AF23E86C4D1}',
|
|
'Wärmepumpe',
|
|
[
|
|
'Kontaktart' => 0,
|
|
'Kontakt1VariableID' => $kontakt1,
|
|
'Kontakt2VariableID' => $kontakt2,
|
|
'Nennleistung' => 5000,
|
|
'Rueckmeldungsart' => 1,
|
|
'IstleistungVariableID' => $rueckmeldung,
|
|
'Anlaufwartezeit' => 1,
|
|
'Wiederholsperre' => 3,
|
|
'Mindestlaufzeit' => 5,
|
|
'Mindestsperrzeit' => 0,
|
|
'MaximaleSperrzeit' => 3,
|
|
'MaximaleSperrzeit24h' => 60,
|
|
'VorgabeTimeout' => 30,
|
|
'DiagnosevariablenAnzeigen' => true,
|
|
]
|
|
);
|
|
|
|
$manager = $test->createInstance(
|
|
'{6F771B18-59D4-4C8A-B951-3B2FE9F6A2C4}',
|
|
'WP Hilfsmanager',
|
|
[
|
|
'AutomatischeSuche' => false,
|
|
'VerbraucherZuordnung' => json_encode([
|
|
['InstanzID' => $waermepumpe, 'Aktiv' => true],
|
|
], JSON_THROW_ON_ERROR),
|
|
]
|
|
);
|
|
|
|
$senden = static function (?int $leistung, string $betriebsart) use (
|
|
$manager,
|
|
$waermepumpe
|
|
): void {
|
|
IPS_RequestAction(
|
|
$waermepumpe,
|
|
'ManagerdatenEmpfangen',
|
|
json_encode([
|
|
'Kopf' => [
|
|
'Version' => '4.0',
|
|
'AbsenderID' => $manager,
|
|
'EmpfaengerID' => $waermepumpe,
|
|
'Zeitpunkt' => time(),
|
|
],
|
|
'Betriebsart' => $betriebsart,
|
|
'Sollleistung_W' => $leistung,
|
|
], JSON_THROW_ON_ERROR)
|
|
);
|
|
};
|
|
|
|
$test->runCase('Instanz und Diagnosevariablen werden angelegt', static function (
|
|
TestContext $test
|
|
) use ($waermepumpe): void {
|
|
$test->assertInstanceStatus($waermepumpe);
|
|
foreach ([
|
|
'Aktiv',
|
|
'Waermepumpenzustand',
|
|
'WaermepumpeLaeuft',
|
|
'SperreAktiv',
|
|
'ErhoehungAktiv',
|
|
'SGReadyZustand',
|
|
'Istleistung',
|
|
'Sollleistung',
|
|
'AnlaufAusstehend',
|
|
'Sperrzeit24h',
|
|
] as $ident) {
|
|
$test->objectByIdent($ident, $waermepumpe);
|
|
}
|
|
});
|
|
|
|
$test->runCase('PV fordert Erhoehung an und bestaetigt den Anlauf', static function (
|
|
TestContext $test
|
|
) use ($waermepumpe, $kontakt1, $kontakt2, $rueckmeldung, $senden): void {
|
|
IPS_RequestAction($waermepumpe, 'Aktiv', true);
|
|
$senden(null, 'PV');
|
|
$senden(5000, 'PV');
|
|
$test->waitUntil(static fn (): bool => GetValue($kontakt2) === true);
|
|
$test->assertSame(false, GetValue($kontakt1), 'Kontakt 1 muss im PV-Anlauf aus sein.');
|
|
$test->assertSame(true, GetValue(
|
|
$test->objectByIdent('AnlaufAusstehend', $waermepumpe)
|
|
), 'Der PV-Anlauf muss bis zur Rueckmeldung ausstehend sein.');
|
|
|
|
$test->waitUntil(static fn (): bool => GetValue($kontakt2) === false, 2500);
|
|
$test->waitUntil(static fn (): bool => GetValue(
|
|
$test->objectByIdent('WiederholsperreAktiv', $waermepumpe)
|
|
) === true);
|
|
$test->assertSame(true, GetValue(
|
|
$test->objectByIdent('WiederholsperreAktiv', $waermepumpe)
|
|
), 'Nach dem fehlgeschlagenen Anlauf muss die Wiederholsperre aktiv sein.');
|
|
$test->assertSame(false, GetValue(
|
|
$test->objectByIdent('AenderungMoeglich', $waermepumpe)
|
|
), 'Waehrend der Wiederholsperre darf keine Aenderung angeboten werden.');
|
|
$test->waitUntil(static fn (): bool => GetValue(
|
|
$test->objectByIdent('WiederholsperreAktiv', $waermepumpe)
|
|
) === false, 4500);
|
|
|
|
$senden(5000, 'PV');
|
|
$test->waitUntil(static fn (): bool => GetValue($kontakt2) === true);
|
|
SetValue($rueckmeldung, true);
|
|
$test->waitUntil(static fn (): bool => GetValue(
|
|
$test->objectByIdent('WaermepumpeLaeuft', $waermepumpe)
|
|
) === true);
|
|
$test->assertSame(5000, (int) GetValue(
|
|
$test->objectByIdent('Istleistung', $waermepumpe)
|
|
));
|
|
});
|
|
|
|
$test->runCase('Lauf ohne Vorgabe erzwingt keine Erhoehung', static function (
|
|
TestContext $test
|
|
) use ($waermepumpe, $kontakt1, $kontakt2): void {
|
|
IPS_RequestAction($waermepumpe, 'Aktiv', false);
|
|
$test->assertSame(false, GetValue($test->objectByIdent('SollwertGueltig', $waermepumpe)));
|
|
$test->assertSame(0, GetValue($test->objectByIdent('Sollleistung', $waermepumpe)));
|
|
IPS_RequestAction($waermepumpe, 'Aktiv', true);
|
|
$test->waitUntil(
|
|
static fn (): bool => GetValue($kontakt1) === false
|
|
&& GetValue($kontakt2) === false
|
|
);
|
|
$test->assertSame(false, GetValue($kontakt1));
|
|
$test->assertSame(false, GetValue($kontakt2));
|
|
IPS_Sleep(5100);
|
|
});
|
|
|
|
$test->runCase('Peak sperrt und maximale Sperrzeit erzwingt Normalbetrieb', static function (
|
|
TestContext $test
|
|
) use ($waermepumpe, $kontakt1, $kontakt2, $senden): void {
|
|
$senden(null, 'Peak');
|
|
$senden(0, 'Peak');
|
|
$test->waitUntil(static fn (): bool => GetValue($kontakt1) === true, 2500);
|
|
$test->assertSame(false, GetValue($kontakt2));
|
|
$test->assertSame(true, GetValue(
|
|
$test->objectByIdent('SperreAktiv', $waermepumpe)
|
|
));
|
|
|
|
$test->waitUntil(static fn (): bool => GetValue($kontakt1) === false, 3500);
|
|
$test->waitUntil(static fn (): bool => GetValue(
|
|
$test->objectByIdent('SperrerholungAktiv', $waermepumpe)
|
|
) === true);
|
|
$test->assertSame(true, GetValue(
|
|
$test->objectByIdent('SperrerholungAktiv', $waermepumpe)
|
|
));
|
|
$test->assertSame(false, GetValue(
|
|
$test->objectByIdent('SperreAktiv', $waermepumpe)
|
|
));
|
|
});
|
|
};
|