const wait =
Utils.getRandomInteger(
this.chargingStation.getAutomaticTransactionGeneratorConfiguration()
- .maxDelayBetweenTwoTransactions ??
- Constants.DEFAULT_ATG_MAX_DELAY_BETWEEN_TWO_TRANSACTIONS,
+ .maxDelayBetweenTwoTransactions,
this.chargingStation.getAutomaticTransactionGeneratorConfiguration()
- .minDelayBetweenTwoTransactions ??
- Constants.DEFAULT_ATG_MIN_DELAY_BETWEEN_TWO_TRANSACTIONS
+ .minDelayBetweenTwoTransactions
) * 1000;
logger.info(
`${this.logPrefix(connectorId)} waiting for ${Utils.formatDurationMilliSeconds(wait)}`
// Wait until end of transaction
const waitTrxEnd =
Utils.getRandomInteger(
- this.chargingStation.getAutomaticTransactionGeneratorConfiguration().maxDuration ??
- Constants.DEFAULT_ATG_MAX_DURATION,
- this.chargingStation.getAutomaticTransactionGeneratorConfiguration().minDuration ??
- Constants.DEFAULT_ATG_MIN_DURATION
+ this.chargingStation.getAutomaticTransactionGeneratorConfiguration().maxDuration,
+ this.chargingStation.getAutomaticTransactionGeneratorConfiguration().minDuration
) * 1000;
logger.info(
`${this.logPrefix(connectorId)} transaction started with id ${this.chargingStation
this.connectorsStatus.get(connectorId).startDate = new Date();
this.connectorsStatus.get(connectorId).stopDate = new Date(
this.connectorsStatus.get(connectorId).startDate.getTime() +
- (this.chargingStation.getAutomaticTransactionGeneratorConfiguration().stopAfterHours ??
- Constants.DEFAULT_ATG_STOP_AFTER_HOURS) *
+ this.chargingStation.getAutomaticTransactionGeneratorConfiguration().stopAfterHours *
3600 *
1000 -
previousRunDuration
public getAutomaticTransactionGeneratorConfiguration():
| AutomaticTransactionGeneratorConfiguration
| undefined {
+ let automaticTransactionGeneratorConfiguration:
+ | AutomaticTransactionGeneratorConfiguration
+ | undefined;
const automaticTransactionGeneratorConfigurationFromFile =
this.getConfigurationFromFile()?.automaticTransactionGenerator;
if (automaticTransactionGeneratorConfigurationFromFile) {
- return automaticTransactionGeneratorConfigurationFromFile;
+ automaticTransactionGeneratorConfiguration =
+ automaticTransactionGeneratorConfigurationFromFile;
+ } else {
+ automaticTransactionGeneratorConfiguration =
+ this.getTemplateFromFile()?.AutomaticTransactionGenerator;
}
- return this.getTemplateFromFile()?.AutomaticTransactionGenerator;
+ return {
+ ...automaticTransactionGeneratorConfiguration,
+ ...Constants.DEFAULT_ATG_CONFIGURATION,
+ };
}
public startAutomaticTransactionGenerator(connectorIds?: number[]): void {
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: 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,
+ minDuration: 60,
+ maxDuration: 120,
+ minDelayBetweenTwoTransactions: 15,
+ maxDelayBetweenTwoTransactions: 30,
probabilityOfStart: 1,
- stopAfterHours: Constants.DEFAULT_ATG_STOP_AFTER_HOURS,
+ stopAfterHours: 0.25,
stopOnConnectionFailure: true,
});