From 46a830d2173d93d4fc5e4bb46fb3591a27fb29dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 8 Jan 2024 14:02:37 +0100 Subject: [PATCH] feat: add ATG absolute stop date support MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Default to relative stop date Signed-off-by: Jérôme Benoit --- README.md | 1 + src/charging-station/AutomaticTransactionGenerator.ts | 8 ++++++-- src/types/AutomaticTransactionGenerator.ts | 1 + src/utils/Constants.ts | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5a78527..83815733 100644 --- 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' diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index b2f095b1..55222213 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -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 diff --git a/src/types/AutomaticTransactionGenerator.ts b/src/types/AutomaticTransactionGenerator.ts index 670590d4..a2866a82 100644 --- a/src/types/AutomaticTransactionGenerator.ts +++ b/src/types/AutomaticTransactionGenerator.ts @@ -12,6 +12,7 @@ export interface AutomaticTransactionGeneratorConfiguration { maxDelayBetweenTwoTransactions: number probabilityOfStart: number stopAfterHours: number + stopAbsoluteDuration: boolean stopOnConnectionFailure: boolean requireAuthorize?: boolean idTagDistribution?: IdTagDistribution diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index 75a17c11..2223c5ef 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -49,6 +49,7 @@ export class Constants { maxDelayBetweenTwoTransactions: 30, probabilityOfStart: 1, stopAfterHours: 0.25, + stopAbsoluteDuration: false, stopOnConnectionFailure: true }) -- 2.34.1