From: Jérôme Benoit Date: Wed, 24 May 2023 21:08:59 +0000 (+0200) Subject: refactor(simulator): add more default values to ATG X-Git-Tag: v1.2.14~14 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6170d8cd4877c852985c90a38441da35ec026b85;p=e-mobility-charging-stations-simulator.git refactor(simulator): add more default values to ATG Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 32c8a3bf..1499f8fb 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -225,9 +225,11 @@ export class AutomaticTransactionGenerator extends AsyncResource { const wait = Utils.getRandomInteger( this.chargingStation.getAutomaticTransactionGeneratorConfiguration() - .maxDelayBetweenTwoTransactions, + .maxDelayBetweenTwoTransactions ?? + Constants.DEFAULT_ATG_MAX_DELAY_BETWEEN_TWO_TRANSACTIONS, this.chargingStation.getAutomaticTransactionGeneratorConfiguration() - .minDelayBetweenTwoTransactions + .minDelayBetweenTwoTransactions ?? + Constants.DEFAULT_ATG_MIN_DELAY_BETWEEN_TWO_TRANSACTIONS ) * 1000; logger.info( `${this.logPrefix(connectorId)} waiting for ${Utils.formatDurationMilliSeconds(wait)}` @@ -245,8 +247,10 @@ export class AutomaticTransactionGenerator extends AsyncResource { // Wait until end of transaction const waitTrxEnd = Utils.getRandomInteger( - this.chargingStation.getAutomaticTransactionGeneratorConfiguration().maxDuration, - this.chargingStation.getAutomaticTransactionGeneratorConfiguration().minDuration + this.chargingStation.getAutomaticTransactionGeneratorConfiguration().maxDuration ?? + Constants.DEFAULT_ATG_MAX_DURATION, + this.chargingStation.getAutomaticTransactionGeneratorConfiguration().minDuration ?? + Constants.DEFAULT_ATG_MIN_DURATION ) * 1000; logger.info( `${this.logPrefix(connectorId)} transaction started with id ${this.chargingStation diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index df1c879b..6d2a6bf0 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -8,14 +8,18 @@ export class Constants { static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // Ms static readonly CHARGING_STATION_ATG_INITIALIZATION_TIME = 1000; // Ms + static readonly DEFAULT_ATG_MIN_DURATION = 60; + static readonly DEFAULT_ATG_MAX_DURATION = 120; + static readonly DEFAULT_ATG_MIN_DELAY_BETWEEN_TWO_TRANSACTIONS = 15; + static readonly DEFAULT_ATG_MAX_DELAY_BETWEEN_TWO_TRANSACTIONS = 30; static readonly DEFAULT_ATG_STOP_AFTER_HOURS = 0.25; // Hours static readonly DEFAULT_ATG_CONFIGURATION: AutomaticTransactionGeneratorConfiguration = Object.freeze({ enable: false, - minDuration: 60, - maxDuration: 120, - minDelayBetweenTwoTransactions: 15, - maxDelayBetweenTwoTransactions: 30, + minDuration: Constants.DEFAULT_ATG_MIN_DURATION, + maxDuration: Constants.DEFAULT_ATG_MAX_DURATION, + minDelayBetweenTwoTransactions: Constants.DEFAULT_ATG_MIN_DELAY_BETWEEN_TWO_TRANSACTIONS, + maxDelayBetweenTwoTransactions: Constants.DEFAULT_ATG_MAX_DELAY_BETWEEN_TWO_TRANSACTIONS, probabilityOfStart: 1, stopAfterHours: Constants.DEFAULT_ATG_STOP_AFTER_HOURS, stopOnConnectionFailure: true,