Neues Ladestationsmodul mit ocpp Modul erstellt.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class OCPPFrameRouter
|
||||
{
|
||||
public function route(array $routes, string $chargePointId, int $evseId = 1, int $connectorId = 1, int $defaultTarget = 0): int
|
||||
{
|
||||
foreach ($routes as $route) {
|
||||
if (!is_array($route)) {
|
||||
continue;
|
||||
}
|
||||
if ((string)($route['ChargePointId'] ?? '') !== $chargePointId) {
|
||||
continue;
|
||||
}
|
||||
$routeEvse = (int)($route['EVSEId'] ?? 1);
|
||||
$routeConnector = (int)($route['ConnectorId'] ?? 1);
|
||||
if ($routeEvse === $evseId && $routeConnector === $connectorId) {
|
||||
return (int)($route['TargetInstance'] ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
return $defaultTarget;
|
||||
}
|
||||
|
||||
public function extractChargePointId(string $path, string $fallback = ''): string
|
||||
{
|
||||
$path = trim($path, '/');
|
||||
if ($path === '') {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
$parts = explode('/', $path);
|
||||
return (string)end($parts);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user