@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Belevo\EnelixEMS\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$netzleistungId = $test->createVariable(2, 'Netzleistung', 0.0);
|
||||
$einKontaktId = $test->createActionVariable('Kontakt Verbraucher 1-Stufig');
|
||||
$einStufigId = $test->createInstance(
|
||||
'{15879A4E-D0C2-4495-83DE-46E1E462591E}',
|
||||
'Verbraucher 1-Stufig',
|
||||
[
|
||||
'Nennleistung' => 1000,
|
||||
'SchaltkontaktVariableID' => $einKontaktId,
|
||||
'Mindesteinschaltdauer' => 0,
|
||||
'Mindestausschaltdauer' => 0,
|
||||
'PrioritaetPV' => 0,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$temperaturId = $test->createVariable(2, 'Boilertemperatur', 52.0);
|
||||
$warmKontakte = [
|
||||
$test->createActionVariable('Warmwasser Stufe 1'),
|
||||
$test->createActionVariable('Warmwasser Stufe 2'),
|
||||
];
|
||||
$warmStufen = [
|
||||
['Stufe' => 1, 'Leistung' => 1000, 'Schaltkontakt_Stufe' => $warmKontakte[0]],
|
||||
['Stufe' => 2, 'Leistung' => 2000, 'Schaltkontakt_Stufe' => $warmKontakte[1]],
|
||||
];
|
||||
$warmwasserId = $test->createInstance(
|
||||
'{B7C54AF4-AD7D-4FE4-B75D-203693906251}',
|
||||
'Wassererwärmer',
|
||||
[
|
||||
'Boilerfuehler_PT1' => $temperaturId,
|
||||
'LeistungsStufen' => json_encode($warmStufen, JSON_THROW_ON_ERROR),
|
||||
'LastwechselSperrzeit' => 1,
|
||||
'LegionellenfunktionAktiv' => false,
|
||||
'PrioritaetPV' => 1,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$managerId = $test->createInstance(
|
||||
'{6F771B18-59D4-4C8A-B951-3B2FE9F6A2C4}',
|
||||
'Manager',
|
||||
[
|
||||
'NetzleistungVariableID' => $netzleistungId,
|
||||
'AutomatischeSuche' => false,
|
||||
'VerbraucherZuordnung' => '[]',
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
'SollwertSolarladen' => 0.0,
|
||||
]
|
||||
);
|
||||
|
||||
$setAssignment = static function (array $ids) use ($test, $managerId): void {
|
||||
$assignment = array_map(
|
||||
static fn (int $id): array => ['InstanzID' => $id, 'Aktiv' => true],
|
||||
$ids
|
||||
);
|
||||
$test->configureInstance($managerId, [
|
||||
'VerbraucherZuordnung' => json_encode($assignment, JSON_THROW_ON_ERROR),
|
||||
]);
|
||||
};
|
||||
$reportConsumers = static function (array $ids): void {
|
||||
foreach ($ids as $id) {
|
||||
IPS_RequestAction($id, 'Aktiv', true);
|
||||
IPS_RequestAction($id, 'Melden', true);
|
||||
}
|
||||
};
|
||||
|
||||
$test->runCase('Manager funktioniert ohne Verbraucher', static function (TestContext $test) use (
|
||||
$managerId
|
||||
): void {
|
||||
IPS_RequestAction($managerId, 'Aktiv', true);
|
||||
IPS_RequestAction($managerId, 'Regeln', true);
|
||||
$test->assertInstanceStatus($managerId);
|
||||
$test->assertSame('PV', GetValue($test->objectByIdent('Betriebsart', $managerId)));
|
||||
});
|
||||
|
||||
$test->runCase('Manager steuert Verbraucher 1-Stufig', static function (TestContext $test) use (
|
||||
$setAssignment,
|
||||
$reportConsumers,
|
||||
$netzleistungId,
|
||||
$managerId,
|
||||
$einStufigId,
|
||||
$einKontaktId
|
||||
): void {
|
||||
$setAssignment([$einStufigId]);
|
||||
SetValue($netzleistungId, -1000.0);
|
||||
$reportConsumers([$einStufigId]);
|
||||
IPS_RequestAction($managerId, 'Regeln', true);
|
||||
$test->waitUntil(static fn (): bool => GetValue($einKontaktId) === true);
|
||||
$test->assertSame(true, GetValue($einKontaktId));
|
||||
});
|
||||
|
||||
$test->runCase('Manager steuert Wassererwärmer', static function (TestContext $test) use (
|
||||
$setAssignment,
|
||||
$reportConsumers,
|
||||
$netzleistungId,
|
||||
$managerId,
|
||||
$warmwasserId,
|
||||
$warmKontakte
|
||||
): void {
|
||||
$setAssignment([$warmwasserId]);
|
||||
SetValue($netzleistungId, -2000.0);
|
||||
$reportConsumers([$warmwasserId]);
|
||||
IPS_RequestAction($managerId, 'Regeln', true);
|
||||
$test->waitUntil(static fn (): bool => GetValue($warmKontakte[1]) === true);
|
||||
$test->assertSame([false, true], array_map(
|
||||
static fn (int $id): bool => (bool) GetValue($id),
|
||||
$warmKontakte
|
||||
));
|
||||
});
|
||||
|
||||
$test->runCase('Manager steuert beide Verbrauchertypen gemeinsam', static function (
|
||||
TestContext $test
|
||||
) use (
|
||||
$setAssignment,
|
||||
$reportConsumers,
|
||||
$netzleistungId,
|
||||
$managerId,
|
||||
$einStufigId,
|
||||
$warmwasserId,
|
||||
$einKontaktId,
|
||||
$warmKontakte
|
||||
): void {
|
||||
$setAssignment([$einStufigId, $warmwasserId]);
|
||||
SetValue($netzleistungId, -3000.0);
|
||||
$reportConsumers([$einStufigId, $warmwasserId]);
|
||||
IPS_RequestAction($managerId, 'Regeln', true);
|
||||
$test->waitUntil(static fn (): bool => (
|
||||
GetValue($einKontaktId) === true && GetValue($warmKontakte[1]) === true
|
||||
));
|
||||
$test->assertSame(
|
||||
2,
|
||||
GetValue($test->objectByIdent('VerbraucherAnzahl', $managerId))
|
||||
);
|
||||
$test->assertSame(true, GetValue($einKontaktId));
|
||||
$test->assertSame(true, GetValue($warmKontakte[1]));
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
<?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));
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Belevo\EnelixEMS\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$temperaturId = $test->createVariable(2, 'Boilertemperatur', 52.0, null, '~Temperature');
|
||||
$kontakte = [
|
||||
$test->createActionVariable('Heizstufe 1'),
|
||||
$test->createActionVariable('Heizstufe 2'),
|
||||
$test->createActionVariable('Heizstufe 3'),
|
||||
];
|
||||
$stufen = [];
|
||||
foreach ($kontakte as $index => $kontaktId) {
|
||||
$stufen[] = [
|
||||
'Stufe' => $index + 1,
|
||||
'Leistung' => ($index + 1) * 1000,
|
||||
'Schaltkontakt_Stufe' => $kontaktId,
|
||||
];
|
||||
}
|
||||
|
||||
$verbraucherId = $test->createInstance(
|
||||
'{B7C54AF4-AD7D-4FE4-B75D-203693906251}',
|
||||
'Wassererwärmer',
|
||||
[
|
||||
'Boilerfuehler_PT1' => $temperaturId,
|
||||
'LeistungsStufen' => json_encode($stufen, JSON_THROW_ON_ERROR),
|
||||
'LastwechselSperrzeit' => 1,
|
||||
'LegionellenfunktionAktiv' => false,
|
||||
'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 Diagnosevariablen werden angelegt', static function (
|
||||
TestContext $test
|
||||
) use ($verbraucherId): void {
|
||||
$test->assertInstanceStatus($verbraucherId);
|
||||
foreach ([
|
||||
'Aktiv', 'Boilertemperatur', 'Mindesttemperatur', 'Maximaltemperatur',
|
||||
'Istleistung', 'Sollleistung', 'AktiveStufe', 'TemperaturGueltig',
|
||||
] as $ident) {
|
||||
$test->objectByIdent($ident, $verbraucherId);
|
||||
}
|
||||
});
|
||||
|
||||
$test->runCase('Temperaturmessung wird übernommen', static function (TestContext $test) use (
|
||||
$verbraucherId
|
||||
): void {
|
||||
IPS_RequestAction($verbraucherId, 'Aktiv', true);
|
||||
IPS_RequestAction($verbraucherId, 'Melden', true);
|
||||
$temperature = (float) GetValue($test->objectByIdent('Boilertemperatur', $verbraucherId));
|
||||
$test->assertEquals(52.0, $temperature, 0.01);
|
||||
$test->assertSame(
|
||||
true,
|
||||
GetValue($test->objectByIdent('TemperaturGueltig', $verbraucherId))
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Sollwert wählt genau eine Leistungsstufe', static function (
|
||||
TestContext $test
|
||||
) use ($managerId, $verbraucherId, $kontakte): void {
|
||||
$paket = [
|
||||
'Kopf' => [
|
||||
'Version' => '3.0',
|
||||
'AbsenderID' => $managerId,
|
||||
'EmpfaengerID' => $verbraucherId,
|
||||
'Zeitpunkt' => time(),
|
||||
],
|
||||
'Sollleistung_W' => 2000,
|
||||
];
|
||||
IPS_RequestAction(
|
||||
$verbraucherId,
|
||||
'ManagerdatenEmpfangen',
|
||||
json_encode($paket, JSON_THROW_ON_ERROR)
|
||||
);
|
||||
$test->waitUntil(static fn (): bool => GetValue($kontakte[1]) === true);
|
||||
$test->assertSame(
|
||||
[false, true, false],
|
||||
array_map(static fn (int $id): bool => (bool) GetValue($id), $kontakte)
|
||||
);
|
||||
$test->assertSame(
|
||||
2,
|
||||
GetValue($test->objectByIdent('AktiveStufe', $verbraucherId))
|
||||
);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user