From 0f040ac07b841b0eb9ed5e65d76c85adbb084aa2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 29 May 2023 12:58:57 +0200 Subject: [PATCH] fix: ensure internal counters are zeroed at simulator stop MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/Bootstrap.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 35f67a95..cebd8c8f 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -60,8 +60,8 @@ export class Bootstrap extends EventEmitter { // Enable unconditionally for now handleUnhandledRejection(); handleUncaughtException(); - this.initializedCounters = false; this.started = false; + this.initializedCounters = false; this.initializeCounters(); this.workerImplementation = null; this.workerScript = path.join( @@ -148,6 +148,7 @@ export class Bootstrap extends EventEmitter { this.workerImplementation = null; this.uiServer?.stop(); await this.storage?.close(); + this.resetCounters(); this.initializedCounters = false; this.started = false; } else { @@ -259,8 +260,7 @@ export class Bootstrap extends EventEmitter { private initializeCounters() { if (this.initializedCounters === false) { - this.numberOfChargingStationTemplates = 0; - this.numberOfChargingStations = 0; + this.resetCounters(); const stationTemplateUrls = Configuration.getStationTemplateUrls(); if (Utils.isNotEmptyArray(stationTemplateUrls)) { this.numberOfChargingStationTemplates = stationTemplateUrls.length; @@ -279,11 +279,16 @@ export class Bootstrap extends EventEmitter { ); process.exit(exitCodes.noChargingStationTemplates); } - this.numberOfStartedChargingStations = 0; this.initializedCounters = true; } } + private resetCounters(): void { + this.numberOfChargingStationTemplates = 0; + this.numberOfChargingStations = 0; + this.numberOfStartedChargingStations = 0; + } + private async startChargingStation( index: number, stationTemplateUrl: StationTemplateUrl -- 2.34.1