X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPResponseService.ts;h=7934500ed3ebd7612cfb05ad58b0c68699396dc1;hb=88499f52f95a8030eb2186b918fac160b95e58a5;hp=1bc4a8a8f6ae3a713da40be7ca0079aa96ae5865;hpb=0282b7c0ea2651c7367cd21bc96e8ef3637076c7;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 1bc4a8a8..7934500e 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -31,17 +31,20 @@ export abstract class OCPPResponseService { multipleOfPrecision: 2, }); ajvFormats(this.ajv); - this.responseHandler = this.responseHandler.bind(this) as ( + this.responseHandler = this.responseHandler.bind(this) as < + ReqType extends JsonType, + ResType extends JsonType, + >( chargingStation: ChargingStation, commandName: RequestCommand, - payload: JsonType, - requestPayload: JsonType + payload: ResType, + requestPayload: ReqType, ) => Promise; this.validateResponsePayload = this.validateResponsePayload.bind(this) as ( chargingStation: ChargingStation, commandName: RequestCommand, schema: JSONSchemaType, - payload: T + payload: T, ) => boolean; } @@ -56,7 +59,7 @@ export abstract class OCPPResponseService { chargingStation: ChargingStation, commandName: RequestCommand, schema: JSONSchemaType, - payload: T + payload: T, ): boolean { if (chargingStation.getOcppStrictCompliance() === false) { return true; @@ -67,13 +70,13 @@ export abstract class OCPPResponseService { } logger.error( `${chargingStation.logPrefix()} ${moduleName}.validateResponsePayload: Command '${commandName}' response PDU is invalid: %j`, - validate.errors + validate.errors, ); throw new OCPPError( - OCPPServiceUtils.ajvErrorsToErrorType(validate.errors), + OCPPServiceUtils.ajvErrorsToErrorType(validate.errors!), 'Response PDU is invalid', commandName, - JSON.stringify(validate.errors, null, 2) + JSON.stringify(validate.errors, null, 2), ); } @@ -81,10 +84,10 @@ export abstract class OCPPResponseService { /* This is intentional */ } - public abstract responseHandler( + public abstract responseHandler( chargingStation: ChargingStation, commandName: RequestCommand, - payload: JsonType, - requestPayload: JsonType + payload: ResType, + requestPayload: ReqType, ): Promise; }