Files
Symcon_Belevo_Energiemanage…/OCPP_Server/libs/OCPPFrameRouter.php
T
2026-05-10 17:26:05 +02:00

38 lines
1.1 KiB
PHP

<?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;
}
$routeChargePointId = (string)($route['ChargePointId'] ?? ($route['chargePointId'] ?? ''));
if ($routeChargePointId !== $chargePointId) {
continue;
}
$routeEvse = (int)($route['EVSEId'] ?? ($route['evseId'] ?? 1));
$routeConnector = (int)($route['ConnectorId'] ?? ($route['connectorId'] ?? 1));
if ($routeEvse === $evseId && $routeConnector === $connectorId) {
return (int)($route['TargetInstance'] ?? ($route['instanceId'] ?? 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);
}
}
?>