X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPResponseService.ts;h=0aedbb1eebb5b6a17a2abe94b2b85641c68c07e9;hb=856e8f67312da4acabeff1bd8452f02658a22fdb;hp=46d12fb048aa7374972316451972a4090aef59a2;hpb=ec0eebcce06f18b41e6639b72728110bda55c250;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 46d12fb0..0aedbb1e 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -4,13 +4,7 @@ import ajvFormats from 'ajv-formats'; import { OCPPServiceUtils } from './OCPPServiceUtils'; import type { ChargingStation } from '../../charging-station'; import { OCPPError } from '../../exception'; -import type { - IncomingRequestCommand, - JsonObject, - JsonType, - OCPPVersion, - RequestCommand, -} from '../../types'; +import type { IncomingRequestCommand, JsonType, OCPPVersion, RequestCommand } from '../../types'; import { logger } from '../../utils'; const moduleName = 'OCPPResponseService'; @@ -20,16 +14,16 @@ export abstract class OCPPResponseService { public jsonIncomingRequestResponseValidateFunctions: Map< IncomingRequestCommand, - ValidateFunction + ValidateFunction >; private readonly version: OCPPVersion; private readonly ajv: Ajv; - private jsonRequestValidateFunctions: Map>; + private jsonRequestValidateFunctions: Map>; public abstract jsonIncomingRequestResponseSchemas: Map< IncomingRequestCommand, - JSONSchemaType + JSONSchemaType >; protected constructor(version: OCPPVersion) { @@ -39,10 +33,10 @@ export abstract class OCPPResponseService { multipleOfPrecision: 2, }); ajvFormats(this.ajv); - this.jsonRequestValidateFunctions = new Map>(); + this.jsonRequestValidateFunctions = new Map>(); this.jsonIncomingRequestResponseValidateFunctions = new Map< IncomingRequestCommand, - ValidateFunction + ValidateFunction >(); this.responseHandler = this.responseHandler.bind(this) as < ReqType extends JsonType, @@ -74,14 +68,11 @@ export abstract class OCPPResponseService { schema: JSONSchemaType, payload: T, ): boolean { - if (chargingStation.getOcppStrictCompliance() === false) { + if (chargingStation.stationInfo?.ocppStrictCompliance === false) { return true; } if (this.jsonRequestValidateFunctions.has(commandName) === false) { - this.jsonRequestValidateFunctions.set( - commandName, - this.ajv.compile(schema).bind(this), - ); + this.jsonRequestValidateFunctions.set(commandName, this.ajv.compile(schema).bind(this)); } const validate = this.jsonRequestValidateFunctions.get(commandName)!; if (validate(payload)) { @@ -92,7 +83,7 @@ export abstract class OCPPResponseService { validate.errors, ); throw new OCPPError( - OCPPServiceUtils.ajvErrorsToErrorType(validate.errors!), + OCPPServiceUtils.ajvErrorsToErrorType(validate.errors), 'Response PDU is invalid', commandName, JSON.stringify(validate.errors, undefined, 2),