X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2Focpp%2F2.0%2FOCPP20ResponseService.ts;h=81dca3a4a29a46de3c54d85ad3b3b2324ccccaf6;hb=f2d5e3d9bd2e0a0e139c270ea791a5a6833c13c9;hp=aefd93dc454907632987f7ad433bb8eb9859dfaa;hpb=5edd8ba0f8978cfb3ca9d80f299d9748c6c5970e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index aefd93dc..81dca3a4 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -3,7 +3,7 @@ import type { JSONSchemaType } from 'ajv'; import { OCPP20ServiceUtils } from './OCPP20ServiceUtils'; -import { type ChargingStation, ChargingStationConfigurationUtils } from '../../../charging-station'; +import { type ChargingStation, addConfigurationKey } from '../../../charging-station'; import { OCPPError } from '../../../exception'; import { ErrorType, @@ -40,9 +40,15 @@ export class OCPP20ResponseService extends OCPPResponseService { // } super(OCPPVersion.VERSION_20); this.responseHandlers = new Map([ - [OCPP20RequestCommand.BOOT_NOTIFICATION, this.handleResponseBootNotification.bind(this)], - [OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this)], - [OCPP20RequestCommand.STATUS_NOTIFICATION, this.emptyResponseHandler.bind(this)], + [ + OCPP20RequestCommand.BOOT_NOTIFICATION, + this.handleResponseBootNotification.bind(this) as ResponseHandler, + ], + [OCPP20RequestCommand.HEARTBEAT, this.emptyResponseHandler.bind(this) as ResponseHandler], + [ + OCPP20RequestCommand.STATUS_NOTIFICATION, + this.emptyResponseHandler.bind(this) as ResponseHandler, + ], ]); this.jsonSchemas = new Map>([ [ @@ -87,11 +93,11 @@ export class OCPP20ResponseService extends OCPPResponseService { ) => boolean; } - public async responseHandler( + public async responseHandler( chargingStation: ChargingStation, commandName: OCPP20RequestCommand, - payload: JsonType, - requestPayload: JsonType, + payload: ResType, + requestPayload: ReqType, ): Promise { if ( chargingStation.isRegistered() === true || @@ -103,7 +109,7 @@ export class OCPP20ResponseService extends OCPPResponseService { ) { try { this.validatePayload(chargingStation, commandName, payload); - await this.responseHandlers.get(commandName)(chargingStation, payload, requestPayload); + await this.responseHandlers.get(commandName)!(chargingStation, payload, requestPayload); } catch (error) { logger.error( `${chargingStation.logPrefix()} ${moduleName}.responseHandler: Handle response error:`, @@ -147,7 +153,7 @@ export class OCPP20ResponseService extends OCPPResponseService { return this.validateResponsePayload( chargingStation, commandName, - this.jsonSchemas.get(commandName), + this.jsonSchemas.get(commandName)!, payload, ); } @@ -162,7 +168,7 @@ export class OCPP20ResponseService extends OCPPResponseService { payload: OCPP20BootNotificationResponse, ): void { if (payload.status === RegistrationStatusEnumType.ACCEPTED) { - ChargingStationConfigurationUtils.addConfigurationKey( + addConfigurationKey( chargingStation, OCPP20OptionalVariableName.HeartbeatInterval, payload.interval.toString(),