feat: add ATG absolute stop date support
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 8 Jan 2024 13:02:37 +0000 (14:02 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 8 Jan 2024 13:02:37 +0000 (14:02 +0100)
Default to relative stop date

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

index e5a7852753145b1945140675e597cccd7ec3cf36..838157333d14f4a6a43d4ef8ad0a76f639cf0cb9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -223,6 +223,7 @@ type AutomaticTransactionGeneratorConfiguration = {
   maxDelayBetweenTwoTransactions: number
   probabilityOfStart: number
   stopAfterHours: number
+  stopAbsoluteDuration: boolean
   stopOnConnectionFailure: boolean
   requireAuthorize?: boolean
   idTagDistribution?: 'random' | 'round-robin' | 'connector-affinity'
index b2f095b1fd222faae7ba91c714f069f3202fa1ec..552222136a88f26ae64cb9ee9b6feef2543f416b 100644 (file)
@@ -262,8 +262,12 @@ export class AutomaticTransactionGenerator {
   private setStartConnectorStatus (connectorId: number): void {
     // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     this.connectorsStatus.get(connectorId)!.startDate = new Date()
-    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-    if (!isValidTime(this.connectorsStatus.get(connectorId)!.stopDate)) {
+    if (
+      this.chargingStation.getAutomaticTransactionGeneratorConfiguration()?.stopAbsoluteDuration ===
+        false ||
+      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+      !isValidTime(this.connectorsStatus.get(connectorId)!.stopDate)
+    ) {
       // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
       this.connectorsStatus.get(connectorId)!.stopDate = new Date(
         // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
index 670590d491307aeb97f03bcd3d1bb2019ceb1773..a2866a829e882995f438680b68ff42cb58890278 100644 (file)
@@ -12,6 +12,7 @@ export interface AutomaticTransactionGeneratorConfiguration {
   maxDelayBetweenTwoTransactions: number
   probabilityOfStart: number
   stopAfterHours: number
+  stopAbsoluteDuration: boolean
   stopOnConnectionFailure: boolean
   requireAuthorize?: boolean
   idTagDistribution?: IdTagDistribution
index 75a17c1100647f1212de1bb00e55a23c50a38e74..2223c5efc8fc118bb0723f95b1dcdd7edc60a5c3 100644 (file)
@@ -49,6 +49,7 @@ export class Constants {
       maxDelayBetweenTwoTransactions: 30,
       probabilityOfStart: 1,
       stopAfterHours: 0.25,
+      stopAbsoluteDuration: false,
       stopOnConnectionFailure: true
     })