refactor: ensure ATG will not start a transaction if one is already
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 4 Feb 2024 11:51:42 +0000 (12:51 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 4 Feb 2024 11:51:42 +0000 (12:51 +0100)
started

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts

index adf38e67b4591c0dae62a6b76827556bbba5382f..37c9b63113f3cc03e916ded80b8b470807d0dfb4 100644 (file)
@@ -324,6 +324,15 @@ export class AutomaticTransactionGenerator {
       )
       return false
     }
+    const connectorStatus = this.chargingStation.getConnectorStatus(connectorId)
+    if (connectorStatus?.transactionStarted === true) {
+      logger.info(
+        `${this.logPrefix(
+          connectorId
+        )} entered in transaction loop while a transaction ${connectorStatus.transactionId} is already started on connector ${connectorId}`
+      )
+      return false
+    }
     return true
   }
 
@@ -365,7 +374,7 @@ export class AutomaticTransactionGenerator {
         logger.info(
           `${this.logPrefix(
             connectorId
-          )} transaction loop waiting for running transaction ${connectorStatus.transactionId} on connector ${connectorId} to be stopped`
+          )} transaction loop waiting for started transaction ${connectorStatus.transactionId} on connector ${connectorId} to be stopped`
         )
         logged = true
       }