X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2F1.6%2FOCPP16RequestService.ts;h=eb3474809edca7e437ef223443137e9f6d23b4d0;hb=1b6498baa159ac6ebd4eda9008cde367640bf3ed;hp=64ce459cb315b735f5e28ece254bfb96bb20e154;hpb=794aea9d3e6b713d55bf5adb06faa211206cfa77;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 64ce459c..eb347480 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -1,15 +1,16 @@ // Partial Copyright Jerome Benoit. 2021. All Rights Reserved. +import { JsonObject, JsonType } from '../../../types/JsonType'; + import type ChargingStation from '../../ChargingStation'; import Constants from '../../../utils/Constants'; import { ErrorType } from '../../../types/ocpp/ErrorType'; -import { JsonType } from '../../../types/JsonType'; import { OCPP16RequestCommand } from '../../../types/ocpp/1.6/Requests'; import { OCPP16ServiceUtils } from './OCPP16ServiceUtils'; import OCPPError from '../../../exception/OCPPError'; import OCPPRequestService from '../OCPPRequestService'; import type OCPPResponseService from '../OCPPResponseService'; -import { SendParams } from '../../../types/ocpp/Requests'; +import { RequestParams } from '../../../types/ocpp/Requests'; import Utils from '../../../utils/Utils'; const moduleName = 'OCPP16RequestService'; @@ -22,32 +23,33 @@ export default class OCPP16RequestService extends OCPPRequestService { super(chargingStation, ocppResponseService); } - public async sendMessageHandler( + public async requestHandler( commandName: OCPP16RequestCommand, commandParams?: JsonType, - params?: SendParams + params?: RequestParams ): Promise { if (Object.values(OCPP16RequestCommand).includes(commandName)) { return (await this.sendMessage( Utils.generateUUID(), - this.buildCommandPayload(commandName, commandParams), + this.buildRequestPayload(commandName, commandParams), commandName, params )) as unknown as Response; } throw new OCPPError( ErrorType.NOT_SUPPORTED, - `${moduleName}.sendMessageHandler: Unsupported OCPP command ${commandName}`, + `${moduleName}.requestHandler: Unsupported OCPP command ${commandName}`, commandName, { commandName } ); } - private buildCommandPayload( + private buildRequestPayload( commandName: OCPP16RequestCommand, commandParams?: JsonType ): Request { let connectorId: number; + commandParams = commandParams as JsonObject; switch (commandName) { case OCPP16RequestCommand.AUTHORIZE: return { @@ -133,7 +135,7 @@ export default class OCPP16RequestService extends OCPPRequestService { throw new OCPPError( ErrorType.NOT_SUPPORTED, // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - `${moduleName}.buildCommandPayload: Unsupported OCPP command: ${commandName}`, + `${moduleName}.buildRequestPayload: Unsupported OCPP command: ${commandName}`, commandName, { commandName } );