X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F2.0%2FOCPP20ResponseService.ts;h=111b114a34048113c4fdf2a60a77133570fe4405;hb=1cee0015ac704be480535c7228103525cc3c8cc2;hp=4984b115e48a03d0315a83eeee28ae2c74e488cf;hpb=9429aa42d725c4b42c30e0134d75b363aed412f0;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 4984b115..111b114a 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -3,11 +3,10 @@ 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, - type JsonObject, type JsonType, type OCPP20BootNotificationResponse, type OCPP20ClearCacheResponse, @@ -28,11 +27,11 @@ const moduleName = 'OCPP20ResponseService'; export class OCPP20ResponseService extends OCPPResponseService { public jsonIncomingRequestResponseSchemas: Map< OCPP20IncomingRequestCommand, - JSONSchemaType + JSONSchemaType >; private responseHandlers: Map; - private jsonSchemas: Map>; + private jsonSchemas: Map>; public constructor() { // if (new.target?.name === moduleName) { @@ -40,11 +39,17 @@ 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>([ + this.jsonSchemas = new Map>([ [ OCPP20RequestCommand.BOOT_NOTIFICATION, OCPP20ServiceUtils.parseJsonSchemaFile( @@ -117,7 +122,7 @@ export class OCPP20ResponseService extends OCPPResponseService { ErrorType.NOT_IMPLEMENTED, `${commandName} is not implemented to handle response PDU ${JSON.stringify( payload, - null, + undefined, 2, )}`, commandName, @@ -129,7 +134,7 @@ export class OCPP20ResponseService extends OCPPResponseService { ErrorType.SECURITY_ERROR, `${commandName} cannot be issued to handle response PDU ${JSON.stringify( payload, - null, + undefined, 2, )} while the charging station is not registered on the central server.`, commandName, @@ -162,7 +167,7 @@ export class OCPP20ResponseService extends OCPPResponseService { payload: OCPP20BootNotificationResponse, ): void { if (payload.status === RegistrationStatusEnumType.ACCEPTED) { - ChargingStationConfigurationUtils.addConfigurationKey( + addConfigurationKey( chargingStation, OCPP20OptionalVariableName.HeartbeatInterval, payload.interval.toString(),