X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPRequestService.ts;h=021e09f369edb855d5be7d161e512f073d3504a3;hb=9b75e3ab59b911697ad2f809e2aee6967a46e0c4;hp=4ab79d9d2bdb400cbbad9dca3f2befb7d93505b5;hpb=3f94cab5f9ffdc613338a715cf3fad1cede5a687;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 4ab79d9d..021e09f3 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -34,6 +34,8 @@ export default abstract class OCPPRequestService { this.chargingStation = chargingStation; this.ocppResponseService = ocppResponseService; this.sendMessageHandler.bind(this); + this.sendResult.bind(this); + this.sendError.bind(this); } public static getInstance( @@ -124,7 +126,8 @@ export default abstract class OCPPRequestService { (!this.chargingStation.getOcppStrictCompliance() && this.chargingStation.isInUnknownState()) || this.chargingStation.isInAcceptedState() || - (this.chargingStation.isInPendingState() && params.triggerMessage) + (this.chargingStation.isInPendingState() && + (params.triggerMessage || messageType === MessageType.CALL_RESULT_MESSAGE)) ) { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; @@ -152,6 +155,11 @@ export default abstract class OCPPRequestService { // FIXME: Handle sending error this.chargingStation.wsConnection.send(messageToSend); PerformanceStatistics.endMeasure(commandName, beginId); + logger.debug( + `${this.chargingStation.logPrefix()} >> Command '${commandName}' sent ${this.getMessageTypeString( + messageType + )} payload: ${messageToSend}` + ); } else if (!params.skipBufferingOnError) { // Buffer it this.chargingStation.bufferMessage(messageToSend); @@ -300,6 +308,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, @@ -315,9 +334,10 @@ export default abstract class OCPPRequestService { } } - public abstract sendMessageHandler( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public abstract sendMessageHandler( commandName: RequestCommand, commandParams?: JsonType, params?: SendParams - ): Promise; + ): Promise; }