From: Jérôme Benoit Date: Sat, 14 Jan 2023 19:37:57 +0000 (+0100) Subject: Improve charging profiles handling debug logs X-Git-Tag: v1.1.90~10 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ad67a158ed1e333a255b49e0c8b4aaa9c7b85867;p=e-mobility-charging-stations-simulator.git Improve charging profiles handling debug logs Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index ad9789dc..a52ebacb 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1806,8 +1806,11 @@ export default class ChargingStation { logger.error( `${this.logPrefix()} Charging profile id ${ matchingChargingProfile.chargingProfileId - } limit ${limit} is greater than connector id ${connectorId} maximum ${connectorMaximumPower}, dump charging profiles' stack: %j`, - this.getConnectorStatus(connectorId).chargingProfiles + } limit ${limit} is greater than connector id ${connectorId} maximum ${connectorMaximumPower}: %j`, + this.getConnectorStatus(connectorId).chargingProfiles.find( + (chargingProfile) => + chargingProfile.chargingProfileId === matchingChargingProfile.chargingProfileId + ) ); limit = connectorMaximumPower; } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index fbae8f85..03eb83f8 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -544,8 +544,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer logger.debug( `${chargingStation.logPrefix()} Charging profile(s) set on connector id ${ commandPayload.connectorId - }, dump their stack: %j`, - chargingStation.getConnectorStatus(commandPayload.connectorId).chargingProfiles + }: %j`, + commandPayload.csChargingProfiles ); return OCPPConstants.OCPP_SET_CHARGING_PROFILE_RESPONSE_ACCEPTED; } @@ -577,8 +577,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer logger.debug( `${chargingStation.logPrefix()} Charging profile(s) cleared on connector id ${ commandPayload.connectorId - }, dump their stack: %j`, - connectorStatus.chargingProfiles + }` ); return OCPPConstants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_ACCEPTED; } @@ -614,10 +613,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer if (clearCurrentCP) { connectorStatus.chargingProfiles.splice(index, 1); logger.debug( - `${chargingStation.logPrefix()} Matching charging profile(s) cleared on connector id ${ - commandPayload.connectorId - }, dump their stack: %j`, - connectorStatus.chargingProfiles + `${chargingStation.logPrefix()} Matching charging profile(s) cleared: %j`, + chargingProfile ); clearedCP = true; } @@ -880,8 +877,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer if (cp && cp.chargingProfilePurpose === ChargingProfilePurposeType.TX_PROFILE) { OCPP16ServiceUtils.setChargingProfile(chargingStation, connectorId, cp); logger.debug( - `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}, dump their stack: %j`, - chargingStation.getConnectorStatus(connectorId).chargingProfiles + `${chargingStation.logPrefix()} Charging profile(s) set at remote start transaction on connector id ${connectorId}: %j`, + cp ); return true; } else if (cp && cp.chargingProfilePurpose !== ChargingProfilePurposeType.TX_PROFILE) {