From: Jérôme Benoit Date: Mon, 8 Jan 2024 13:02:37 +0000 (+0100) Subject: feat: add ATG absolute stop date support X-Git-Tag: v1.2.32~48 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=46a830d2173d93d4fc5e4bb46fb3591a27fb29dc;p=e-mobility-charging-stations-simulator.git feat: add ATG absolute stop date support Default to relative stop date Signed-off-by: Jérôme Benoit --- 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 })