This commit is contained in:
@@ -6,14 +6,18 @@ use Belevo\EnelixEMS\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$kontaktId = $test->createActionVariable('Schaltkontakt');
|
||||
$rueckmeldungId = $test->createVariable(0, 'Rückmeldung', false);
|
||||
$verbraucherId = $test->createInstance(
|
||||
'{15879A4E-D0C2-4495-83DE-46E1E462591E}',
|
||||
'Verbraucher 1-Stufig',
|
||||
[
|
||||
'Nennleistung' => 1200,
|
||||
'SchaltkontaktVariableID' => $kontaktId,
|
||||
'Mindesteinschaltdauer' => 0,
|
||||
'Mindestausschaltdauer' => 0,
|
||||
'RueckmeldungVariableID' => $rueckmeldungId,
|
||||
'Mindestlaufzeit' => 0,
|
||||
'Mindesteinschaltdauer' => 2,
|
||||
'Mindestausschaltdauer' => 2,
|
||||
'VorgabeTimeout' => 30,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
]
|
||||
);
|
||||
@@ -28,21 +32,10 @@ return static function (TestContext $test): void {
|
||||
]
|
||||
);
|
||||
|
||||
$test->runCase('Instanz und Variablen werden angelegt', static function (TestContext $test) use (
|
||||
$anforderungSenden = static function (int $leistung) use (
|
||||
$managerId,
|
||||
$verbraucherId
|
||||
): void {
|
||||
$test->assertInstanceStatus($verbraucherId);
|
||||
foreach (['Aktiv', 'Schaltzustand', 'Tageslaufzeit', 'Istleistung', 'Sollleistung'] as $ident) {
|
||||
$test->objectByIdent($ident, $verbraucherId);
|
||||
}
|
||||
});
|
||||
|
||||
$test->runCase('Sollwert schaltet den Verbraucher ein', static function (TestContext $test) use (
|
||||
$managerId,
|
||||
$verbraucherId,
|
||||
$kontaktId
|
||||
): void {
|
||||
IPS_RequestAction($verbraucherId, 'Aktiv', true);
|
||||
$paket = [
|
||||
'Kopf' => [
|
||||
'Version' => '3.0',
|
||||
@@ -50,41 +43,149 @@ return static function (TestContext $test): void {
|
||||
'EmpfaengerID' => $verbraucherId,
|
||||
'Zeitpunkt' => time(),
|
||||
],
|
||||
'Sollleistung_W' => 1200,
|
||||
'Sollleistung_W' => $leistung,
|
||||
];
|
||||
IPS_RequestAction(
|
||||
$verbraucherId,
|
||||
'ManagerdatenEmpfangen',
|
||||
json_encode($paket, JSON_THROW_ON_ERROR)
|
||||
);
|
||||
};
|
||||
$test->runCase('Instanz und Diagnosevariablen werden angelegt', static function (
|
||||
TestContext $test
|
||||
) use ($verbraucherId): void {
|
||||
$test->assertInstanceStatus($verbraucherId);
|
||||
foreach ([
|
||||
'Aktiv', 'Schaltzustand', 'Tageslaufzeit', 'Istleistung', 'Sollleistung',
|
||||
'AenderungMoeglich', 'Rueckmeldefehler', 'SchaltbefehlAusstehend',
|
||||
'RestMindestzeit',
|
||||
] as $ident) {
|
||||
$test->objectByIdent($ident, $verbraucherId);
|
||||
}
|
||||
});
|
||||
|
||||
$test->runCase('Nur angebotene Leistungsanforderungen werden angenommen', static function (
|
||||
TestContext $test
|
||||
) use (
|
||||
$verbraucherId,
|
||||
$kontaktId,
|
||||
$rueckmeldungId,
|
||||
$anforderungSenden
|
||||
): void {
|
||||
IPS_RequestAction($verbraucherId, 'Aktiv', true);
|
||||
IPS_Sleep(2100);
|
||||
|
||||
$anforderungSenden(600);
|
||||
$test->assertSame(false, GetValue($kontaktId));
|
||||
$test->assertSame(
|
||||
0,
|
||||
(int) GetValue($test->objectByIdent('Sollleistung', $verbraucherId))
|
||||
);
|
||||
$anforderungSenden(1200);
|
||||
$test->waitUntil(static fn (): bool => GetValue($kontaktId) === true);
|
||||
$test->assertSame(true, GetValue($kontaktId));
|
||||
$test->assertSame(false, GetValue(
|
||||
$test->objectByIdent('Schaltzustand', $verbraucherId)
|
||||
));
|
||||
$test->assertSame(true, GetValue(
|
||||
$test->objectByIdent('SchaltbefehlAusstehend', $verbraucherId)
|
||||
));
|
||||
|
||||
SetValue($rueckmeldungId, true);
|
||||
$test->waitUntil(static fn (): bool => GetValue(
|
||||
$test->objectByIdent('Schaltzustand', $verbraucherId)
|
||||
) === true);
|
||||
$test->assertSame(
|
||||
1200,
|
||||
(int) round((float) GetValue($test->objectByIdent('Istleistung', $verbraucherId)))
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Sollwert null schaltet den Verbraucher aus', static function (TestContext $test) use (
|
||||
$managerId,
|
||||
$test->runCase('Mindesteinschaltdauer verhindert zu frühes Ausschalten', static function (
|
||||
TestContext $test
|
||||
) use (
|
||||
$verbraucherId,
|
||||
$kontaktId
|
||||
$kontaktId,
|
||||
$rueckmeldungId,
|
||||
$anforderungSenden
|
||||
): void {
|
||||
$paket = [
|
||||
'Kopf' => [
|
||||
'Version' => '3.0',
|
||||
'AbsenderID' => $managerId,
|
||||
'EmpfaengerID' => $verbraucherId,
|
||||
'Zeitpunkt' => time(),
|
||||
],
|
||||
'Sollleistung_W' => 0,
|
||||
];
|
||||
IPS_RequestAction(
|
||||
$verbraucherId,
|
||||
'ManagerdatenEmpfangen',
|
||||
json_encode($paket, JSON_THROW_ON_ERROR)
|
||||
$anforderungSenden(0);
|
||||
$test->assertSame(true, GetValue($kontaktId));
|
||||
$test->assertTrue(
|
||||
(int) GetValue($test->objectByIdent('RestMindestzeit', $verbraucherId)) > 0
|
||||
);
|
||||
|
||||
IPS_Sleep(2100);
|
||||
$anforderungSenden(0);
|
||||
$test->waitUntil(static fn (): bool => GetValue($kontaktId) === false);
|
||||
$test->assertSame(true, GetValue(
|
||||
$test->objectByIdent('SchaltbefehlAusstehend', $verbraucherId)
|
||||
));
|
||||
|
||||
SetValue($rueckmeldungId, false);
|
||||
$test->waitUntil(static fn (): bool => GetValue(
|
||||
$test->objectByIdent('Schaltzustand', $verbraucherId)
|
||||
) === false);
|
||||
});
|
||||
|
||||
$test->runCase('Mindestausschaltdauer verhindert zu frühes Einschalten', static function (
|
||||
TestContext $test
|
||||
) use (
|
||||
$kontaktId,
|
||||
$rueckmeldungId,
|
||||
$anforderungSenden
|
||||
): void {
|
||||
$anforderungSenden(1200);
|
||||
$test->assertSame(false, GetValue($kontaktId));
|
||||
|
||||
IPS_Sleep(2100);
|
||||
$anforderungSenden(1200);
|
||||
$test->waitUntil(static fn (): bool => GetValue($kontaktId) === true);
|
||||
SetValue($rueckmeldungId, true);
|
||||
});
|
||||
|
||||
$test->runCase('Tägliche Mindestlaufzeit wird spätestens rechtzeitig erzwungen', static function (
|
||||
TestContext $test
|
||||
) use (
|
||||
$verbraucherId,
|
||||
$kontaktId,
|
||||
$rueckmeldungId,
|
||||
$anforderungSenden
|
||||
): void {
|
||||
IPS_Sleep(2100);
|
||||
$anforderungSenden(0);
|
||||
$test->waitUntil(static fn (): bool => GetValue($kontaktId) === false);
|
||||
SetValue($rueckmeldungId, false);
|
||||
|
||||
IPS_SetProperty($verbraucherId, 'Mindestlaufzeit', 86400);
|
||||
IPS_ApplyChanges($verbraucherId);
|
||||
$test->waitUntil(static fn (): bool => GetValue($kontaktId) === true);
|
||||
$test->assertSame(1200, (int) GetValue(
|
||||
$test->objectByIdent('Sollleistung', $verbraucherId)
|
||||
));
|
||||
SetValue($rueckmeldungId, true);
|
||||
|
||||
IPS_SetProperty($verbraucherId, 'Mindestlaufzeit', 0);
|
||||
IPS_ApplyChanges($verbraucherId);
|
||||
});
|
||||
|
||||
$test->runCase('Physische Rückmeldung bestätigt und überwacht den Zustand', static function (
|
||||
TestContext $test
|
||||
) use ($verbraucherId, $kontaktId, $rueckmeldungId): void {
|
||||
$test->assertSame(true, GetValue($kontaktId));
|
||||
SetValue($rueckmeldungId, false);
|
||||
IPS_RequestAction($verbraucherId, 'Melden', true);
|
||||
$test->waitUntil(static fn (): bool => GetValue(
|
||||
$test->objectByIdent('Rueckmeldefehler', $verbraucherId)
|
||||
) === true);
|
||||
$test->assertSame(true, GetValue(
|
||||
$test->objectByIdent('Stoerung', $verbraucherId)
|
||||
));
|
||||
|
||||
SetValue($rueckmeldungId, true);
|
||||
IPS_RequestAction($verbraucherId, 'Melden', true);
|
||||
$test->waitUntil(static fn (): bool => GetValue(
|
||||
$test->objectByIdent('Rueckmeldefehler', $verbraucherId)
|
||||
) === false);
|
||||
$test->assertInstanceStatus($verbraucherId);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user