From: Jérôme Benoit Date: Wed, 13 Apr 2022 21:30:12 +0000 (+0200) Subject: Factor out OCPP message type to string method X-Git-Tag: v1.1.57~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9a3b8d9fcb673461f651ca0993d708583528b296;p=e-mobility-charging-stations-simulator.git Factor out OCPP message type to string method Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index ed3a8da7..2813d39a 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -154,20 +154,10 @@ export default abstract class OCPPRequestService { // FIXME: Handle sending error this.chargingStation.wsConnection.send(messageToSend); PerformanceStatistics.endMeasure(commandName, beginId); - let msgTypeStr: string; - switch (messageType) { - case MessageType.CALL_MESSAGE: - msgTypeStr = 'request'; - break; - case MessageType.CALL_RESULT_MESSAGE: - msgTypeStr = 'response'; - break; - case MessageType.CALL_ERROR_MESSAGE: - msgTypeStr = 'error'; - break; - } logger.debug( - `${this.chargingStation.logPrefix()} >> Command '${commandName}' sent ${msgTypeStr} payload: ${messageToSend}` + `${this.chargingStation.logPrefix()} >> Command '${commandName}' sent ${this.getMessageTypeString( + messageType + )} payload: ${messageToSend}` ); } else if (!params.skipBufferingOnError) { // Buffer it @@ -317,6 +307,17 @@ export default abstract class OCPPRequestService { return messageToSend; } + private getMessageTypeString(messageType: MessageType): string { + switch (messageType) { + case MessageType.CALL_MESSAGE: + return 'request'; + case MessageType.CALL_RESULT_MESSAGE: + return 'response'; + case MessageType.CALL_ERROR_MESSAGE: + return 'error'; + } + } + private handleRequestError( commandName: RequestCommand | IncomingRequestCommand, error: Error,