Improve charging profiles handling debug logs
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 14 Jan 2023 19:37:57 +0000 (20:37 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 14 Jan 2023 19:37:57 +0000 (20:37 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index ad9789dc6ae187a94a108b202530c53f1539c80a..a52ebacb88eeb91a62e1d3ddf91d70b3a519f40b 100644 (file)
@@ -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;
         }
index fbae8f85b05382e328bb0a931834fc35be936026..03eb83f83de114e11f2f6865e2fbba2efe3a5bed 100644 (file)
@@ -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) {