91 lines
2.9 KiB
PHP
91 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Belevo\EnelixEMS\SymconTest\TestContext;
|
|
|
|
return static function (TestContext $test): void {
|
|
$kontaktId = $test->createActionVariable('Schaltkontakt');
|
|
$verbraucherId = $test->createInstance(
|
|
'{15879A4E-D0C2-4495-83DE-46E1E462591E}',
|
|
'Verbraucher 1-Stufig',
|
|
[
|
|
'Nennleistung' => 1200,
|
|
'SchaltkontaktVariableID' => $kontaktId,
|
|
'Mindesteinschaltdauer' => 0,
|
|
'Mindestausschaltdauer' => 0,
|
|
'DiagnosevariablenAnzeigen' => true,
|
|
]
|
|
);
|
|
$managerId = $test->createInstance(
|
|
'{6F771B18-59D4-4C8A-B951-3B2FE9F6A2C4}',
|
|
'Hilfsmanager',
|
|
[
|
|
'AutomatischeSuche' => false,
|
|
'VerbraucherZuordnung' => json_encode([
|
|
['InstanzID' => $verbraucherId, 'Aktiv' => true],
|
|
], JSON_THROW_ON_ERROR),
|
|
]
|
|
);
|
|
|
|
$test->runCase('Instanz und Variablen werden angelegt', static function (TestContext $test) use (
|
|
$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',
|
|
'AbsenderID' => $managerId,
|
|
'EmpfaengerID' => $verbraucherId,
|
|
'Zeitpunkt' => time(),
|
|
],
|
|
'Sollleistung_W' => 1200,
|
|
];
|
|
IPS_RequestAction(
|
|
$verbraucherId,
|
|
'ManagerdatenEmpfangen',
|
|
json_encode($paket, JSON_THROW_ON_ERROR)
|
|
);
|
|
$test->waitUntil(static fn (): bool => GetValue($kontaktId) === true);
|
|
$test->assertSame(true, GetValue($kontaktId));
|
|
$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,
|
|
$verbraucherId,
|
|
$kontaktId
|
|
): 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)
|
|
);
|
|
$test->waitUntil(static fn (): bool => GetValue($kontaktId) === false);
|
|
$test->assertSame(false, GetValue($kontaktId));
|
|
});
|
|
};
|