X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FAutomaticTransactionGenerator.ts;h=763533ed82e12269cb56183708bf0ae7720ab6a0;hb=ce4d00ee7295ccdb12f35154eb2eb72973b6e75b;hp=3f821c8ee822df0620718c42cec23fa78228bf80;hpb=c0560973d259dbce64a24d10bab46246596fa1d5;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 3f821c8e..763533ed 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -23,17 +23,18 @@ export default class AutomaticTransactionGenerator { } } - public start(): void { + public async start(): Promise { this.timeToStop = false; if (this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours && this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours > 0) { - setTimeout(() => { - void this.stop(); + // eslint-disable-next-line @typescript-eslint/no-misused-promises + setTimeout(async (): Promise => { + await this.stop(); }, this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours * 3600 * 1000); } for (const connector in this.chargingStation.connectors) { if (Utils.convertToInt(connector) > 0) { - void this.startConnector(Utils.convertToInt(connector)); + await this.startConnector(Utils.convertToInt(connector)); } } logger.info(this.logPrefix() + ' ATG started and will stop in ' + Utils.secondsToHHMMSS(this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours * 3600)); @@ -73,7 +74,7 @@ export default class AutomaticTransactionGenerator { if (!this.chargingStation?.ocppRequestService) { logger.info(`${this.logPrefix(connectorId)} Transaction loop waiting for charging station service to be initialized`); do { - await Utils.sleep(500); + await Utils.sleep(Constants.CHARGING_STATION_ATG_INITIALIZATION_TIME); } while (!this.chargingStation?.ocppRequestService); } const wait = Utils.getRandomInt(this.chargingStation.stationInfo.AutomaticTransactionGenerator.maxDelayBetweenTwoTransactions,