66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
class CapabilityModel
|
|
{
|
|
public static function defaults(): array
|
|
{
|
|
return [
|
|
'smartCharging' => false,
|
|
'meterValues' => false,
|
|
'phaseMetering' => false,
|
|
'currentImportPerPhase' => false,
|
|
'voltagePerPhase' => false,
|
|
'powerImport' => false,
|
|
'powerExport' => false,
|
|
'energyImport' => false,
|
|
'energyExport' => false,
|
|
'numberPhases' => false,
|
|
'phaseToUse' => false,
|
|
'phaseSwitching' => false,
|
|
'dataTransfer' => false,
|
|
'remoteStartStop' => false,
|
|
'availability' => false,
|
|
'simpleAmpereProfiles' => false,
|
|
'getVariables' => false,
|
|
'setVariables' => false,
|
|
'transactionEvent' => false,
|
|
'soc' => false,
|
|
'temperature' => false,
|
|
'signedMeterValue' => false,
|
|
'bidirectional' => false
|
|
];
|
|
}
|
|
|
|
public static function detectFromBoot(string $version, array $payload): array
|
|
{
|
|
$capabilities = self::defaults();
|
|
$capabilities['meterValues'] = true;
|
|
|
|
if ($version === '2.0.1' || $version === '2.1') {
|
|
$capabilities['getVariables'] = true;
|
|
$capabilities['setVariables'] = true;
|
|
$capabilities['transactionEvent'] = true;
|
|
$capabilities['smartCharging'] = true;
|
|
}
|
|
|
|
if ($version === '2.1') {
|
|
$capabilities['bidirectional'] = true;
|
|
$capabilities['powerExport'] = true;
|
|
$capabilities['energyExport'] = true;
|
|
}
|
|
|
|
if (isset($payload['chargingStation']['model']) || isset($payload['chargePointModel'])) {
|
|
$capabilities['dataTransfer'] = true;
|
|
}
|
|
|
|
return $capabilities;
|
|
}
|
|
|
|
public static function merge(array $base, array $updates): array
|
|
{
|
|
return array_replace($base, array_intersect_key($updates, $base));
|
|
}
|
|
}
|
|
|
|
?>
|