From 0282b7c0ea2651c7367cd21bc96e8ef3637076c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 7 Jul 2023 23:46:47 +0200 Subject: [PATCH] refactor: remove payloadSchemaValidation from template in favor of ocppStrictCompliance MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- README.md | 3 +-- src/charging-station/ChargingStation.ts | 19 +------------------ .../ocpp/OCPPIncomingRequestService.ts | 2 +- .../ocpp/OCPPRequestService.ts | 4 ++-- .../ocpp/OCPPResponseService.ts | 2 +- src/types/ChargingStationTemplate.ts | 1 + 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 592b3eab..dbf0533e 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ But the modifications to test have to be done to the files in the build target d | supervisionUrlOcppKey | | 'ConnectionUrl' | string | the vendor string that will be used as a vendor OCPP parameter key to set the supervision URL | | ocppVersion | 1.6/2.0/2.0.1 | 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 | +| ocppStrictCompliance | true/false | false | boolean | strict adherence to the OCPP version and protocol specifications. OCPP commands PDU validation against [OCA](https://www.openchargealliance.org/) JSON schemas | | 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](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](dist/assets/configurations) | | automaticTransactionGeneratorPersistentConfiguration | true/false | true | boolean | enable persistent automatic transaction generator configuration storage by charging stations 'hashId'. The persistency is ensured by the charging stations configuration files in [dist/assets/configurations](dist/assets/configurations) | @@ -165,7 +165,6 @@ But the modifications to test have to be done to the files in the build target d | amperageLimitationUnit | A/cA/dA/mA | A | string | charging stations amperage limit unit | | enableStatistics | true/false | false | boolean | enable charging stations statistics | | mustAuthorizeAtRemoteStart | true/false | true | boolean | always send authorize at remote start transaction when AuthorizeRemoteTxRequests is enabled | -| payloadSchemaValidation | true/false | true if ocppStrictCompliance is true/false if ocppStrictCompliance is false | boolean | validate OCPP commands PDU against [OCA](https://www.openchargealliance.org/) JSON schemas | | 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 | diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 022f11bb..1494cc56 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -250,23 +250,6 @@ export class ChargingStation { return this.stationInfo.mustAuthorizeAtRemoteStart ?? true; } - public getPayloadSchemaValidation(): boolean { - if ( - this.getOcppStrictCompliance() === true && - (isNullOrUndefined(this.stationInfo.payloadSchemaValidation) || - this.stationInfo.payloadSchemaValidation === false) - ) { - return true; - } else if ( - this.getOcppStrictCompliance() === false && - (isNullOrUndefined(this.stationInfo.payloadSchemaValidation) || - this.stationInfo.payloadSchemaValidation === true) - ) { - return false; - } - return this.stationInfo.payloadSchemaValidation ?? true; - } - public getNumberOfPhases(stationInfo?: ChargingStationInfo): number | undefined { const localStationInfo: ChargingStationInfo = stationInfo ?? this.stationInfo; switch (this.getCurrentOutType(stationInfo)) { @@ -365,7 +348,7 @@ export class ChargingStation { } public getOcppStrictCompliance(): boolean { - return this.stationInfo?.ocppStrictCompliance ?? false; + return this.stationInfo?.ocppStrictCompliance ?? true; } public getVoltageOut(stationInfo?: ChargingStationInfo): number | undefined { diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index 66dd198d..0fc67ed2 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -84,7 +84,7 @@ export abstract class OCPPIncomingRequestService extends AsyncResource { schema: JSONSchemaType, payload: T ): boolean { - if (chargingStation.getPayloadSchemaValidation() === false) { + if (chargingStation.getOcppStrictCompliance() === false) { return true; } const validate = this.ajv.compile(schema); diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 443c6c80..4ea134b6 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -197,7 +197,7 @@ export abstract class OCPPRequestService { commandName: RequestCommand | IncomingRequestCommand, payload: T ): boolean { - if (chargingStation.getPayloadSchemaValidation() === false) { + if (chargingStation.getOcppStrictCompliance() === false) { return true; } if (this.jsonSchemas.has(commandName as RequestCommand) === false) { @@ -230,7 +230,7 @@ export abstract class OCPPRequestService { commandName: RequestCommand | IncomingRequestCommand, payload: T ): boolean { - if (chargingStation.getPayloadSchemaValidation() === false) { + if (chargingStation.getOcppStrictCompliance() === false) { return true; } if ( diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index caf826e0..1bc4a8a8 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -58,7 +58,7 @@ export abstract class OCPPResponseService { schema: JSONSchemaType, payload: T ): boolean { - if (chargingStation.getPayloadSchemaValidation() === false) { + if (chargingStation.getOcppStrictCompliance() === false) { return true; } const validate = this.ajv.compile(schema); diff --git a/src/types/ChargingStationTemplate.ts b/src/types/ChargingStationTemplate.ts index 10f9733f..b9bd389b 100644 --- a/src/types/ChargingStationTemplate.ts +++ b/src/types/ChargingStationTemplate.ts @@ -109,6 +109,7 @@ export type ChargingStationTemplate = { registrationMaxRetries?: number; enableStatistics?: boolean; mustAuthorizeAtRemoteStart?: boolean; + /** @deprecated Replaced by ocppStrictCompliance */ payloadSchemaValidation?: boolean; amperageLimitationOcppKey?: string; amperageLimitationUnit?: AmpereUnits; -- 2.34.1