From: Jérôme Benoit Date: Thu, 19 Jan 2023 22:01:55 +0000 (+0100) Subject: Fix and add log messages X-Git-Tag: v1.1.91~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8ca6874c767f7068b101291232cf69b05bbd28c1;p=e-mobility-charging-stations-simulator.git Fix and add log messages Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index a87ef6f2..547a4f36 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -65,6 +65,7 @@ import { type IncomingRequest, IncomingRequestCommand, type MeterValuesRequest, + type OutgoingRequest, RequestCommand, type ResponseCallback, type StatusNotificationRequest, @@ -769,6 +770,12 @@ export default class ChargingStation { this.messageBuffer.forEach((message) => { // TODO: evaluate the need to track performance this.wsConnection.send(message); + const [messageType] = JSON.parse(message) as OutgoingRequest | Response | ErrorResponse; + logger.debug( + `${this.logPrefix()} >> Buffered ${OCPPServiceUtils.getMessageTypeString( + messageType + )} payload sent: ${message}` + ); this.messageBuffer.delete(message); }); } diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index d7772bdc..effa3abd 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -569,7 +569,7 @@ export default class OCPP16ResponseService extends OCPPResponseService { ' Starting transaction id ' + payload.transactionId.toString() + " REJECTED with status '" + - payload?.idTagInfo?.status + + payload.idTagInfo?.status + "', idTag '" + requestPayload.idTag + "'" @@ -661,16 +661,11 @@ export default class OCPP16ResponseService extends OCPPResponseService { chargingStation.powerDivider--; } chargingStation.resetConnectorStatus(transactionConnectorId); - const logMsg = - chargingStation.logPrefix() + - ' Transaction ' + - requestPayload.transactionId.toString() + - ' STOPPED on ' + - chargingStation.stationInfo.chargingStationId + - '#' + - transactionConnectorId.toString() + - " with status '" + - payload.idTagInfo?.status ?? 'undefined' + "'"; + const logMsg = `${chargingStation.logPrefix()} Transaction ${requestPayload.transactionId.toString()} STOPPED on ${ + chargingStation.stationInfo.chargingStationId + }#${transactionConnectorId.toString()} with status '${ + payload.idTagInfo?.status ?? 'undefined' + }'`; if ( Utils.isNullOrUndefined(payload.idTagInfo) || payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED