From: Jérôme Benoit Date: Sun, 2 May 2021 18:34:45 +0000 (+0200) Subject: Fix SRPC call type counting in statistics. X-Git-Tag: v1.0.1-0~43 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=193d2c0a14e09db6af0a618525f8e0c8aef58cfe;p=e-mobility-charging-stations-simulator.git Fix SRPC call type counting in statistics. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index b5ec5209..44327562 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -517,7 +517,7 @@ export default class ChargingStation { private async onMessage(messageEvent: MessageEvent): Promise { let [messageType, messageId, commandName, commandPayload, errorDetails]: IncomingRequest = [0, '', '' as IncomingRequestCommand, {}, {}]; - let responseCallback: (payload?: Record | string, requestPayload?: Record) => void; + let responseCallback: (payload: Record | string, requestPayload: Record) => void; let rejectCallback: (error: OCPPError) => void; let requestPayload: Record; let errMsg: string; diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 5615eb77..20163f7d 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -21,8 +21,7 @@ export default abstract class OCPPRequestService { this.ocppResponseService = ocppResponseService; } - public async sendMessage(messageId: string, commandParams: any, messageType: MessageType = MessageType.CALL_RESULT_MESSAGE, - commandName: RequestCommand | IncomingRequestCommand): Promise { + public async sendMessage(messageId: string, commandParams: any, messageType: MessageType, commandName: RequestCommand | IncomingRequestCommand): Promise { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; // Send a message through wsConnection @@ -77,7 +76,7 @@ export default abstract class OCPPRequestService { */ async function responseCallback(payload: Record | string, requestPayload: Record): Promise { if (self.chargingStation.getEnableStatistics()) { - self.chargingStation.statistics.addMessage(commandName, messageType); + self.chargingStation.statistics.addMessage(commandName, MessageType.CALL_RESULT_MESSAGE); } // Send the response await self.ocppResponseService.handleResponse(commandName as RequestCommand, payload, requestPayload); @@ -91,7 +90,7 @@ export default abstract class OCPPRequestService { */ function rejectCallback(error: OCPPError): void { if (self.chargingStation.getEnableStatistics()) { - self.chargingStation.statistics.addMessage(commandName, messageType); + self.chargingStation.statistics.addMessage(commandName, MessageType.CALL_ERROR_MESSAGE); } logger.debug(`${self.chargingStation.logPrefix()} Error: %j occurred when calling command %s with parameters: %j`, error, commandName, commandParams); // Build Exception diff --git a/src/types/ocpp/Requests.ts b/src/types/ocpp/Requests.ts index d4388efe..26283cc9 100644 --- a/src/types/ocpp/Requests.ts +++ b/src/types/ocpp/Requests.ts @@ -27,6 +27,6 @@ export const IncomingRequestCommand = { ...OCPP16IncomingRequestCommand }; -export type Request = [(payload?: Record, requestPayload?: Record) => void, (error?: OCPPError) => void, Record]; +export type Request = [(payload: Record, requestPayload: Record) => void, (error: OCPPError) => void, Record]; export type IncomingRequest = [MessageType, string, IncomingRequestCommand, Record, Record];