From: Jérôme Benoit Date: Thu, 11 Aug 2022 19:09:22 +0000 (+0200) Subject: Add template section to list OCPP commands supported (#129) X-Git-Tag: v1.1.65~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=65554cc3fc240ee17d57c57ec60a2a0da4d757ba;p=e-mobility-charging-stations-simulator.git Add template section to list OCPP commands supported (#129) --- diff --git a/README.md b/README.md index 3056f386..aeb0b879 100644 --- a/README.md +++ b/README.md @@ -119,56 +119,57 @@ But the modifications to test have to be done to the files in the build target d **src/assets/station-templates/\.json**: -| Key | Value(s) | Default Value | Value type | Description | -| ---------------------------------- | ---------- | --------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| supervisionUrls | | '' | string \| string[] | string or array of connection URIs to OCPP-J servers | -| supervisionUser | | '' | string | basic HTTP authentication user to OCPP-J server | -| supervisionPassword | | '' | string | basic HTTP authentication password to OCPP-J server | -| supervisionUrlOcppConfiguration | true/false | false | boolean | allow supervision URL configuration via a vendor OCPP parameter key | -| supervisionUrlOcppKey | | 'ConnectionUrl' | string | the vendor string that will be used as a vendor OCPP parameter key to set the supervision URL | -| ocppVersion | 1.6 | 1.6 | string | OCPP version | -| ocppProtocol | json | json | string | OCPP protocol | -| ocppStrictCompliance | true/false | false | boolean | strict adherence to the OCPP version and protocol specifications | -| ocppPersistentConfiguration | true/false | true | boolean | enable persistent OCPP parameters storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in dist/assets/configurations | -| stationInfoPersistentConfiguration | true/false | true | boolean | enable persistent station information and specifications storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in dist/assets/configurations | -| wsOptions | | {} | ClientOptions & ClientRequestArgs | [ws](https://github.com/websockets/ws) and node.js [http](https://nodejs.org/api/http.html) clients options intersection | -| authorizationFile | | '' | string | RFID tags list file relative to src/assets path | -| baseName | | '' | string | base name to build charging stations id | -| nameSuffix | | '' | string | name suffix to build charging stations id | -| fixedName | true/false | false | boolean | use the baseName as the charging stations unique name | -| chargePointModel | | '' | string | charging stations model | -| chargePointVendor | | '' | string | charging stations vendor | -| chargePointSerialNumberPrefix | | '' | string | charge point serial number prefix | -| chargeBoxSerialNumberPrefix | | '' | string | charge box serial number prefix (deprecated in OCPP 1.6) | -| firmwareVersion | | '' | string | charging stations firmware version | -| power | | | float \| float[] | charging stations maximum power value(s) | -| powerSharedByConnectors | true/false | false | boolean | charging stations power shared by its connectors | -| powerUnit | W/kW | W | string | charging stations power unit | -| currentOutType | AC/DC | AC | string | charging stations current out type | -| voltageOut | | AC:230/DC:400 | integer | charging stations voltage out | -| numberOfPhases | 0/1/3 | AC:3/DC:0 | integer | charging stations number of phase(s) | -| numberOfConnectors | | | integer \| integer[] | charging stations number of connector(s) | -| useConnectorId0 | true/false | true | boolean | use connector id 0 definition from the charging station configuration template | -| randomConnectors | true/false | false | boolean | randomize runtime connector id affectation from the connector id definition in charging station configuration template | -| resetTime | | 60 | integer | seconds to wait before the charging stations come back at reset | -| autoRegister | true/false | false | boolean | set charging stations as registered at boot notification for testing purpose | -| autoReconnectMaxRetries | | -1 (unlimited) | integer | connection retries to the OCPP-J server | -| reconnectExponentialDelay | true/false | false | boolean | connection delay retry to the OCPP-J server | -| registrationMaxRetries | | -1 (unlimited) | integer | charging stations boot notification retries | -| amperageLimitationOcppKey | | undefined | string | charging stations OCPP parameter key used to set the amperage limit, per phase for each connector on AC and global for DC | -| amperageLimitationUnit | A/cA/dA/mA | A | string | charging stations amperage limit unit | -| enableStatistics | true/false | true | boolean | enable charging stations statistics | -| mayAuthorizeAtRemoteStart | true/false | true | boolean | always send authorize at remote start transaction when AuthorizeRemoteTxRequests is enabled | -| beginEndMeterValues | true/false | false | boolean | enable Transaction.{Begin,End} MeterValues | -| outOfOrderEndMeterValues | true/false | false | boolean | send Transaction.End MeterValues out of order. Need to relax OCPP specifications strict compliance ('ocppStrictCompliance' parameter) | -| meteringPerTransaction | true/false | true | boolean | enable metering history on a per transaction basis | -| transactionDataMeterValues | true/false | false | boolean | enable transaction data MeterValues at stop transaction | -| mainVoltageMeterValues | true/false | true | boolean | include charging stations main voltage MeterValues on three phased charging stations | -| phaseLineToLineVoltageMeterValues | true/false | true | boolean | include charging stations line to line voltage MeterValues on three phased charging stations | -| customValueLimitationMeterValues | true/false | true | boolean | enable limitation on custom fluctuated value in MeterValues | -| Configuration | | | ChargingStationConfiguration | charging stations OCPP parameters configuration section | -| AutomaticTransactionGenerator | | | AutomaticTransactionGenerator | charging stations ATG configuration section | -| Connectors | | | Connectors | charging stations connectors configuration section | +| Key | Value(s) | Default Value | Value type | Description | +| ---------------------------------- | ---------- | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| supervisionUrls | | '' | string \| string[] | string or array of connection URIs to OCPP-J servers | +| supervisionUser | | '' | string | basic HTTP authentication user to OCPP-J server | +| supervisionPassword | | '' | string | basic HTTP authentication password to OCPP-J server | +| supervisionUrlOcppConfiguration | true/false | false | boolean | allow supervision URL configuration via a vendor OCPP parameter key | +| supervisionUrlOcppKey | | 'ConnectionUrl' | string | the vendor string that will be used as a vendor OCPP parameter key to set the supervision URL | +| ocppVersion | 1.6 | 1.6 | string | OCPP version | +| ocppProtocol | json | json | string | OCPP protocol | +| ocppStrictCompliance | true/false | false | boolean | strict adherence to the OCPP version and protocol specifications | +| ocppPersistentConfiguration | true/false | true | boolean | enable persistent OCPP parameters storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in dist/assets/configurations | +| stationInfoPersistentConfiguration | true/false | true | boolean | enable persistent station information and specifications storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in dist/assets/configurations | +| wsOptions | | {} | ClientOptions & ClientRequestArgs | [ws](https://github.com/websockets/ws) and node.js [http](https://nodejs.org/api/http.html) clients options intersection | +| authorizationFile | | '' | string | RFID tags list file relative to src/assets path | +| baseName | | '' | string | base name to build charging stations id | +| nameSuffix | | '' | string | name suffix to build charging stations id | +| fixedName | true/false | false | boolean | use the baseName as the charging stations unique name | +| chargePointModel | | '' | string | charging stations model | +| chargePointVendor | | '' | string | charging stations vendor | +| chargePointSerialNumberPrefix | | '' | string | charge point serial number prefix | +| chargeBoxSerialNumberPrefix | | '' | string | charge box serial number prefix (deprecated in OCPP 1.6) | +| firmwareVersion | | '' | string | charging stations firmware version | +| power | | | float \| float[] | charging stations maximum power value(s) | +| powerSharedByConnectors | true/false | false | boolean | charging stations power shared by its connectors | +| powerUnit | W/kW | W | string | charging stations power unit | +| currentOutType | AC/DC | AC | string | charging stations current out type | +| voltageOut | | AC:230/DC:400 | integer | charging stations voltage out | +| numberOfPhases | 0/1/3 | AC:3/DC:0 | integer | charging stations number of phase(s) | +| numberOfConnectors | | | integer \| integer[] | charging stations number of connector(s) | +| useConnectorId0 | true/false | true | boolean | use connector id 0 definition from the charging station configuration template | +| randomConnectors | true/false | false | boolean | randomize runtime connector id affectation from the connector id definition in charging station configuration template | +| resetTime | | 60 | integer | seconds to wait before the charging stations come back at reset | +| autoRegister | true/false | false | boolean | set charging stations as registered at boot notification for testing purpose | +| autoReconnectMaxRetries | | -1 (unlimited) | integer | connection retries to the OCPP-J server | +| reconnectExponentialDelay | true/false | false | boolean | connection delay retry to the OCPP-J server | +| registrationMaxRetries | | -1 (unlimited) | integer | charging stations boot notification retries | +| amperageLimitationOcppKey | | undefined | string | charging stations OCPP parameter key used to set the amperage limit, per phase for each connector on AC and global for DC | +| amperageLimitationUnit | A/cA/dA/mA | A | string | charging stations amperage limit unit | +| enableStatistics | true/false | true | boolean | enable charging stations statistics | +| mayAuthorizeAtRemoteStart | true/false | true | boolean | always send authorize at remote start transaction when AuthorizeRemoteTxRequests is enabled | +| beginEndMeterValues | true/false | false | boolean | enable Transaction.{Begin,End} MeterValues | +| outOfOrderEndMeterValues | true/false | false | boolean | send Transaction.End MeterValues out of order. Need to relax OCPP specifications strict compliance ('ocppStrictCompliance' parameter) | +| meteringPerTransaction | true/false | true | boolean | enable metering history on a per transaction basis | +| transactionDataMeterValues | true/false | false | boolean | enable transaction data MeterValues at stop transaction | +| mainVoltageMeterValues | true/false | true | boolean | include charging stations main voltage MeterValues on three phased charging stations | +| phaseLineToLineVoltageMeterValues | true/false | true | boolean | include charging stations line to line voltage MeterValues on three phased charging stations | +| customValueLimitationMeterValues | true/false | true | boolean | enable limitation on custom fluctuated value in MeterValues | +| commandsSupport | | {
"incomingCommands": {},
"outgoingCommands": {}
} | {
incomingCommands: Record;
outgoingCommands?: Record;
} | Configuration section for OCPP commands support. Empty section means all implemented are supported support | +| Configuration | | | ChargingStationConfiguration | charging stations OCPP parameters configuration section | +| AutomaticTransactionGenerator | | | AutomaticTransactionGenerator | charging stations ATG configuration section | +| Connectors | | | Connectors | charging stations connectors configuration section | #### Configuration section diff --git a/src/assets/station-templates/chargex.station-template.json b/src/assets/station-templates/chargex.station-template.json new file mode 100644 index 00000000..057d25df --- /dev/null +++ b/src/assets/station-templates/chargex.station-template.json @@ -0,0 +1,86 @@ +{ + "authorizationFile": "authorization-tags.json", + "baseName": "CS-CHARGEX", + "chargePointModel": "Aqueduct 1.0", + "chargePointVendor": "ChargeX GmbH", + "firmwareVersion": "MCC 1.2.0; SCC [0.12.0, 0.13.0]", + "power": 22080, + "powerUnit": "W", + "numberOfConnectors": 1, + "voltageOut": 230, + "beginEndMeterValues": true, + "outOfOrderEndMeterValues": true, + "commandsSupport": { + "incomingCommands": { + "Authorize": true, + "Reset": true, + "GetConfiguration": true, + "ChangeConfiguration": true, + "ClearCache": true, + "ChangeAvailability": false, + "UnlockConnector": true, + "SetChargingProfile": false, + "ClearChargingProfile": false, + "RemoteStartTransaction": true, + "RemoteStopTransaction": true, + "GetDiagnostics": false, + "TriggerMessage": false + } + }, + "Configuration": { + "configurationKey": [ + { + "key": "AllowOfflineTxForUnknownId", + "value": "True" + }, + { + "key": "AuthorizeRemoteTxRequests", + "value": "True", + "readonly": true + }, + { + "key": "LocalAuthListEnabled", + "value": "False", + "readonly": true + }, + { + "key": "LocalPreAuthorize", + "value": "False", + "readonly": true + }, + { + "key": "MeterValueSampleInterval", + "value": "300" + }, + { + "key": "TransactionMessageAttempts", + "value": "3" + }, + { + "key": "TransactionMessageRetryInterval", + "value": "20" + } + ] + }, + "AutomaticTransactionGenerator": { + "enable": false, + "minDuration": 60, + "maxDuration": 80, + "minDelayBetweenTwoTransactions": 15, + "maxDelayBetweenTwoTransactions": 30, + "probabilityOfStart": 1, + "stopAfterHours": 0.3, + "stopOnConnectionFailure": false, + "requireAuthorize": true + }, + "Connectors": { + "0": {}, + "1": { + "MeterValues": [ + { + "unit": "Wh" + } + ] + } + } +} diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index 51887b1b..c216ed6b 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -16,7 +16,11 @@ import { ChargingProfileKindType, RecurrencyKindType } from '../types/ocpp/1.6/C import { ChargingProfile, ChargingSchedulePeriod } from '../types/ocpp/ChargingProfile'; import { StandardParametersKey } from '../types/ocpp/Configuration'; import { MeterValueMeasurand, MeterValuePhase } from '../types/ocpp/MeterValues'; -import { BootNotificationRequest } from '../types/ocpp/Requests'; +import { + BootNotificationRequest, + IncomingRequestCommand, + RequestCommand, +} from '../types/ocpp/Requests'; import { WebSocketCloseEventStatusString } from '../types/WebSocket'; import { WorkerProcessType } from '../types/Worker'; import Configuration from '../utils/Configuration'; @@ -530,6 +534,28 @@ export class ChargingStationUtils { ); } + public static isCommandSupported( + command: RequestCommand | IncomingRequestCommand, + stationInfo: ChargingStationInfo + ): boolean { + if ( + Object.values(IncomingRequestCommand).includes(command as IncomingRequestCommand) && + !stationInfo?.commandsSupport?.incomingCommands + ) { + return true; + } + if ( + Object.values(RequestCommand).includes(command as RequestCommand) && + !stationInfo?.commandsSupport?.outgoingCommands + ) { + return true; + } + return ( + ((stationInfo?.commandsSupport?.incomingCommands[command] as boolean) ?? false) || + ((stationInfo?.commandsSupport?.outgoingCommands[command] as boolean) ?? false) + ); + } + private static getRandomSerialNumberSuffix(params?: { randomBytesLength?: number; upperCase?: boolean; diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index d431b9a8..172aa8dd 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -157,7 +157,10 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer chargingStation.isRegistered() || (!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState()) ) { - if (this.incomingRequestHandlers.has(commandName)) { + if ( + this.incomingRequestHandlers.has(commandName) && + ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo) + ) { try { // Call the method to build the response response = await this.incomingRequestHandlers.get(commandName)( diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 3656e70f..78ff8888 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -8,6 +8,7 @@ import { RequestParams } from '../../../types/ocpp/Requests'; import Constants from '../../../utils/Constants'; import Utils from '../../../utils/Utils'; import type ChargingStation from '../../ChargingStation'; +import { ChargingStationUtils } from '../../ChargingStationUtils'; import OCPPRequestService from '../OCPPRequestService'; import type OCPPResponseService from '../OCPPResponseService'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; @@ -28,7 +29,10 @@ export default class OCPP16RequestService extends OCPPRequestService { commandParams?: JsonType, params?: RequestParams ): Promise { - if (Object.values(OCPP16RequestCommand).includes(commandName)) { + if ( + Object.values(OCPP16RequestCommand).includes(commandName) && + ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo) + ) { return (await this.sendMessage( chargingStation, Utils.generateUUID(), diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 38a29976..47021ca6 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -34,6 +34,7 @@ import logger from '../../../utils/Logger'; import Utils from '../../../utils/Utils'; import type ChargingStation from '../../ChargingStation'; import { ChargingStationConfigurationUtils } from '../../ChargingStationConfigurationUtils'; +import { ChargingStationUtils } from '../../ChargingStationUtils'; import OCPPResponseService from '../OCPPResponseService'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; @@ -65,7 +66,10 @@ export default class OCPP16ResponseService extends OCPPResponseService { requestPayload: JsonType ): Promise { if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) { - if (this.responseHandlers.has(commandName)) { + if ( + this.responseHandlers.has(commandName) && + ChargingStationUtils.isCommandSupported(commandName, chargingStation.stationInfo) + ) { try { await this.responseHandlers.get(commandName)(chargingStation, payload, requestPayload); } catch (error) { diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index 6a2abe89..6acca89c 100644 --- a/src/types/ChargingStationTemplate.ts +++ b/src/types/ChargingStationTemplate.ts @@ -7,6 +7,7 @@ import ChargingStationOcppConfiguration from './ChargingStationOcppConfiguration import { ConnectorStatus } from './ConnectorStatus'; import { OCPPProtocol } from './ocpp/OCPPProtocol'; import { OCPPVersion } from './ocpp/OCPPVersion'; +import { IncomingRequestCommand, RequestCommand } from './ocpp/Requests'; export enum CurrentType { AC = 'AC', @@ -34,6 +35,11 @@ export enum Voltage { export type WsOptions = ClientOptions & ClientRequestArgs; +interface CommandsSupport { + incomingCommands: Record; + outgoingCommands?: Record; +} + export default interface ChargingStationTemplate { templateHash?: string; supervisionUrls?: string | string[]; @@ -85,6 +91,7 @@ export default interface ChargingStationTemplate { mainVoltageMeterValues?: boolean; phaseLineToLineVoltageMeterValues?: boolean; customValueLimitationMeterValues?: boolean; + commandsSupport?: CommandsSupport; Configuration?: ChargingStationOcppConfiguration; AutomaticTransactionGenerator?: AutomaticTransactionGeneratorConfiguration; Connectors: Record;