This commit is contained in:
@@ -13,7 +13,7 @@ final class LadestationAdapterTest extends TestCase
|
||||
/**
|
||||
* @dataProvider statusFaelle
|
||||
* @param array<string, string> $konfiguration
|
||||
* @param array{Rohstatus: int, Istleistung_W: float} $erwartet
|
||||
* @param array{Rohstatus: int, Istleistung_W: float, Iststrom_A?: float} $erwartet
|
||||
*/
|
||||
public function testStatusaufrufUndDekodierungFuerAlleGeraete(
|
||||
int $geraetetyp,
|
||||
@@ -47,16 +47,16 @@ final class LadestationAdapterTest extends TestCase
|
||||
yield 'go-e alt' => [
|
||||
LadestationAdapter::GO_E_ALT,
|
||||
$this->lokaleKonfiguration(),
|
||||
$this->goEAntwort(2, 1100),
|
||||
$this->goEAntwort(2, 1100, [160, 158, 159]),
|
||||
'http://192.0.2.10/mqtt?payload=',
|
||||
['Rohstatus' => 2, 'Istleistung_W' => 11000.0],
|
||||
['Rohstatus' => 2, 'Istleistung_W' => 11000.0, 'Iststrom_A' => 16.0],
|
||||
];
|
||||
yield 'go-e Gemini' => [
|
||||
LadestationAdapter::GO_E_GEMINI,
|
||||
$this->lokaleKonfiguration(),
|
||||
$this->goEAntwort(2, 2300),
|
||||
$this->goEAntwort(2, 2300, [9.8, 0, 0]),
|
||||
'http://192.0.2.10/api/status',
|
||||
['Rohstatus' => 2, 'Istleistung_W' => 2300.0],
|
||||
['Rohstatus' => 2, 'Istleistung_W' => 2300.0, 'Iststrom_A' => 9.8],
|
||||
];
|
||||
yield 'Smart-me Pico' => [
|
||||
LadestationAdapter::SMART_ME_PICO,
|
||||
@@ -161,9 +161,13 @@ final class LadestationAdapterTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
private function goEAntwort(int $status, float $leistung): string
|
||||
/** @param list<int|float> $stroeme */
|
||||
private function goEAntwort(int $status, float $leistung, array $stroeme): string
|
||||
{
|
||||
$nrg = array_fill(0, 12, 0);
|
||||
foreach (array_values($stroeme) as $index => $strom) {
|
||||
$nrg[4 + $index] = $strom;
|
||||
}
|
||||
$nrg[11] = $leistung;
|
||||
|
||||
return json_encode(['car' => $status, 'nrg' => $nrg], JSON_THROW_ON_ERROR);
|
||||
|
||||
@@ -77,6 +77,24 @@ final class LadestationReglerTest extends TestCase
|
||||
self::assertSame(4, $status['Fahrzeugstatus']);
|
||||
}
|
||||
|
||||
public function testDirekterPhasenstromHatVorrangVorNominalerLeistungsumrechnung(): void
|
||||
{
|
||||
$status = LadestationRegler::normalisiereStatus([
|
||||
'Rohstatus' => 2,
|
||||
'Istleistung_W' => 10263.0,
|
||||
'Iststrom_A' => 15.9,
|
||||
], true);
|
||||
|
||||
self::assertEqualsWithDelta(15.9, $status['Ladestrom_A'], 0.01);
|
||||
}
|
||||
|
||||
public function testFahrzeugMaximalstromWirdMitZweiAmpereAbstandErkannt(): void
|
||||
{
|
||||
self::assertSame(16, LadestationRegler::ermittleFahrzeugMaximalstrom(20, 15.9, 20));
|
||||
self::assertNull(LadestationRegler::ermittleFahrzeugMaximalstrom(17, 15.9, 20));
|
||||
self::assertNull(LadestationRegler::ermittleFahrzeugMaximalstrom(20, 0.0, 20));
|
||||
}
|
||||
|
||||
public function testBetriebsartUndSolarladenBestimmenDasLeistungsangebot(): void
|
||||
{
|
||||
$solarPV = LadestationRegler::leistungsangebot(true, true, true, false, 1, 16, true, false);
|
||||
|
||||
@@ -159,6 +159,34 @@ final class ManagerReglerTest extends TestCase
|
||||
self::assertSame(0, $ergebnis['Restabweichung_W']);
|
||||
}
|
||||
|
||||
public function testBegrenztesFahrzeugLaedtVorBatterieOhneBatterieentladung(): void
|
||||
{
|
||||
$ergebnis = ManagerRegler::verteile(
|
||||
-3587.0,
|
||||
0.0,
|
||||
[
|
||||
$this->verbraucher(
|
||||
10,
|
||||
0,
|
||||
[0, 4150, 4850, 5550, 6250, 6950, 7600, 8300, 9000, 9700, 10300, 11000],
|
||||
10263
|
||||
),
|
||||
$this->verbraucher(
|
||||
20,
|
||||
1,
|
||||
[['Von_W' => -39000, 'Bis_W' => 39000]],
|
||||
0
|
||||
),
|
||||
],
|
||||
'PrioritaetPV'
|
||||
);
|
||||
|
||||
self::assertSame(13850, $ergebnis['Verteilbudget_W']);
|
||||
self::assertSame([10 => 11000, 20 => 2850], $ergebnis['Sollwerte']);
|
||||
self::assertGreaterThanOrEqual(0, $ergebnis['Sollwerte'][20]);
|
||||
self::assertSame(0, $ergebnis['Restabweichung_W']);
|
||||
}
|
||||
|
||||
public function testFehlendeIstleistungFaelltAufAngenommenenSollwertZurueck(): void
|
||||
{
|
||||
$verbraucher = $this->verbraucher(10, 0, [3000], null, false);
|
||||
|
||||
@@ -6,8 +6,11 @@ use Belevo\EnelixEMS\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$testPasswort = hash('sha256', __FILE__);
|
||||
$goEAntwort = static function (int $status, float $leistung): string {
|
||||
$goEAntwort = static function (int $status, float $leistung, array $stroeme = []): string {
|
||||
$nrg = array_fill(0, 12, 0);
|
||||
foreach (array_values($stroeme) as $index => $strom) {
|
||||
$nrg[4 + $index] = $strom;
|
||||
}
|
||||
$nrg[11] = $leistung;
|
||||
return json_encode(['car' => $status, 'nrg' => $nrg], JSON_THROW_ON_ERROR);
|
||||
};
|
||||
@@ -16,14 +19,14 @@ return static function (TestContext $test): void {
|
||||
'go-e alt' => [
|
||||
'Geraetetyp' => 1,
|
||||
'Geraeteadresse' => '192.0.2.10',
|
||||
'Testantwort' => $goEAntwort(2, 1100),
|
||||
'Testantwort' => $goEAntwort(2, 1100, [160, 158, 159]),
|
||||
'Phasenzahl' => 3,
|
||||
'BefehlUrlTeil' => 'amp=16',
|
||||
],
|
||||
'go-e Gemini' => [
|
||||
'Geraetetyp' => 2,
|
||||
'Geraeteadresse' => '192.0.2.11',
|
||||
'Testantwort' => $goEAntwort(2, 2300),
|
||||
'Testantwort' => $goEAntwort(2, 2300, [10, 0, 0]),
|
||||
'Phasenzahl' => 1,
|
||||
'BefehlUrlTeil' => 'amp=16',
|
||||
],
|
||||
@@ -77,6 +80,23 @@ return static function (TestContext $test): void {
|
||||
]
|
||||
);
|
||||
|
||||
$stromerkennung = $test->createInstance(
|
||||
'{0D94913C-0F31-4C29-A685-6EB4AE58E55D}',
|
||||
'Ladestation Fahrzeugstromerkennung',
|
||||
[
|
||||
'Geraetetyp' => 2,
|
||||
'Geraeteadresse' => '192.0.2.13',
|
||||
'MaximalerLadestrom' => 20,
|
||||
'FahrzeugstromErkennungszeit' => 1,
|
||||
'Ladefreigabe' => true,
|
||||
'Solarladen' => true,
|
||||
'EinstellungenInVisu' => true,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
'Testmodus' => true,
|
||||
'Testantwort' => $goEAntwort(2, 10263, [15.9, 15.8, 15.7]),
|
||||
]
|
||||
);
|
||||
|
||||
$managerId = $test->createInstance(
|
||||
'{6F771B18-59D4-4C8A-B951-3B2FE9F6A2C4}',
|
||||
'Hilfsmanager Ladestation',
|
||||
@@ -84,7 +104,7 @@ return static function (TestContext $test): void {
|
||||
'AutomatischeSuche' => false,
|
||||
'VerbraucherZuordnung' => json_encode(array_map(
|
||||
static fn (int $id): array => ['InstanzID' => $id, 'Aktiv' => true],
|
||||
array_values($stationen)
|
||||
array_merge(array_values($stationen), [$stromerkennung])
|
||||
), JSON_THROW_ON_ERROR),
|
||||
]
|
||||
);
|
||||
@@ -161,7 +181,7 @@ return static function (TestContext $test): void {
|
||||
GetValue($test->objectByIdent('FahrzeugGeladen', $solarPause))
|
||||
);
|
||||
|
||||
IPS_SetProperty($solarPause, 'Testantwort', $goEAntwort(2, 2300));
|
||||
IPS_SetProperty($solarPause, 'Testantwort', $goEAntwort(2, 2300, [100, 100, 100]));
|
||||
IPS_ApplyChanges($solarPause);
|
||||
|
||||
$test->assertSame(
|
||||
@@ -229,6 +249,30 @@ return static function (TestContext $test): void {
|
||||
), 'Peak mit Solarladen muss die Ladestation stoppen.');
|
||||
});
|
||||
|
||||
$test->runCase('Fahrzeugstrom wird nach stabiler Unterschreitung begrenzt', static function (
|
||||
TestContext $test
|
||||
) use ($stromerkennung, $anforderungSenden): void {
|
||||
IPS_RequestAction($stromerkennung, 'Aktiv', true);
|
||||
IPS_RequestAction($stromerkennung, 'Solarladen', true);
|
||||
$anforderungSenden($stromerkennung, 13850);
|
||||
IPS_RequestAction($stromerkennung, 'Statuszyklus', false);
|
||||
IPS_Sleep(2100);
|
||||
IPS_RequestAction($stromerkennung, 'Statuszyklus', false);
|
||||
|
||||
$test->assertSame(
|
||||
16,
|
||||
GetValue($test->objectByIdent('FahrzeugMaximalstrom', $stromerkennung))
|
||||
);
|
||||
$test->assertSame(
|
||||
'[0,4150,4850,5550,6250,6950,7600,8300,9000,9700,10300,11000]',
|
||||
(string) GetValue($test->objectByIdent('LeistungsangebotDiagnose', $stromerkennung))
|
||||
);
|
||||
$test->assertTrue(str_contains(
|
||||
(string) GetValue($test->objectByIdent('LetzterGeraetebefehl', $stromerkennung)),
|
||||
'amp=16'
|
||||
));
|
||||
});
|
||||
|
||||
$test->runCase('Sollwert bleibt waehrend der Ladeanlaufzeit gueltig', static function (
|
||||
TestContext $test
|
||||
) use ($goEAntwort, $stationen, $anforderungSenden): void {
|
||||
|
||||
Reference in New Issue
Block a user