Neues Ladestationsmodul mit ocpp Modul erstellt.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class ConnectionRegistry
|
||||
{
|
||||
public static function empty(): array
|
||||
{
|
||||
return [
|
||||
'connections' => [],
|
||||
'lastSeen' => []
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromJson(string $json): array
|
||||
{
|
||||
$data = json_decode($json, true);
|
||||
if (!is_array($data)) {
|
||||
return self::empty();
|
||||
}
|
||||
return array_replace(self::empty(), $data);
|
||||
}
|
||||
|
||||
public static function toJson(array $state): string
|
||||
{
|
||||
return json_encode(array_replace(self::empty(), $state));
|
||||
}
|
||||
|
||||
public static function touch(array $state, string $chargePointId, string $remote = ''): array
|
||||
{
|
||||
$state = array_replace(self::empty(), $state);
|
||||
$state['connections'][$chargePointId] = [
|
||||
'chargePointId' => $chargePointId,
|
||||
'remote' => $remote,
|
||||
'timestamp' => time()
|
||||
];
|
||||
$state['lastSeen'][$chargePointId] = time();
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class WebSocketEndpoint
|
||||
{
|
||||
public static function supportSummary(bool $registerHookAvailable, string $hookPath): array
|
||||
{
|
||||
if ($registerHookAvailable) {
|
||||
return [
|
||||
'status' => 'Hook vorbereitet',
|
||||
'detail' => 'Symcon RegisterHook ist verfuegbar. WebSocket-Dauerbetrieb muss mit echter OCPP-Station verifiziert werden.',
|
||||
'hookPath' => $hookPath
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'Hook manuell/spaeter',
|
||||
'detail' => 'RegisterHook ist in dieser Symcon-Umgebung nicht als Modul-Methode verfuegbar. WebHook Control muss manuell oder nach Upgrade verbunden werden.',
|
||||
'hookPath' => $hookPath
|
||||
];
|
||||
}
|
||||
|
||||
public static function readRawBody(): string
|
||||
{
|
||||
$data = @file_get_contents('php://input');
|
||||
return is_string($data) ? $data : '';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user