From 087a502dd0b03aa2107ebd6355062397e86d5e7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 14 Aug 2021 10:43:50 +0200 Subject: [PATCH] Fix performance statistics handling at charging station template reload MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .gitmodules | 8 -------- src/assets/configs-aws | 1 - src/assets/configs-scp | 1 - src/charging-station/ChargingStation.ts | 8 ++++++-- src/utils/PerformanceStatistics.ts | 11 ++++++++--- src/utils/Utils.ts | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) delete mode 100644 .gitmodules delete mode 160000 src/assets/configs-aws delete mode 160000 src/assets/configs-scp diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index ac1a6d12..00000000 --- a/.gitmodules +++ /dev/null @@ -1,8 +0,0 @@ -[submodule "src/assets/configs-aws"] - path = src/assets/configs-aws - url = ../../E-Mobility/ev-aws.git - branch = master -[submodule "src/assets/configs-scp"] - path = src/assets/configs-scp - url = ../../E-Mobility/ev-scp-config.git - branch = master-qa diff --git a/src/assets/configs-aws b/src/assets/configs-aws deleted file mode 160000 index 2dc38e36..00000000 --- a/src/assets/configs-aws +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2dc38e36a569dc1266e48d85e7e87ed0d3f18528 diff --git a/src/assets/configs-scp b/src/assets/configs-scp deleted file mode 160000 index cf40aecc..00000000 --- a/src/assets/configs-scp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cf40aecc4b7c099f6b5b8bc6690f975a6db006b6 diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 4fc275bc..e9420089 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -992,13 +992,17 @@ export default class ChargingStation { logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload'); // Initialize this.initialize(); - // Stop the ATG + // Restart the ATG if (!this.stationInfo.AutomaticTransactionGenerator.enable && this.automaticTransactionGeneration) { await this.automaticTransactionGeneration.stop(); } - // Start the ATG this.startAutomaticTransactionGenerator(); + if (this.getEnableStatistics()) { + this.performanceStatistics.restart(); + } else { + this.performanceStatistics.stop(); + } // FIXME?: restart heartbeat and WebSocket ping when their interval values have changed } catch (error) { logger.error(this.logPrefix() + ' Charging station template file monitoring error: %j', error); diff --git a/src/utils/PerformanceStatistics.ts b/src/utils/PerformanceStatistics.ts index 49f75ade..4ef732f7 100644 --- a/src/utils/PerformanceStatistics.ts +++ b/src/utils/PerformanceStatistics.ts @@ -79,17 +79,22 @@ export default class PerformanceStatistics { clearInterval(this.displayInterval); } performance.clearMarks(); - this.performanceObserver.disconnect(); + this.performanceObserver?.disconnect(); + } + + public restart(): void { + this.stop(); + this.start(); } private initializePerformanceObserver(): void { this.performanceObserver = new PerformanceObserver((list) => { - this.logPerformanceEntry(list.getEntries()[0]); + this.addPerformanceEntry(list.getEntries()[0]); }); this.performanceObserver.observe({ entryTypes: ['measure'] }); } - private logPerformanceEntry(entry: PerformanceEntry): void { + private addPerformanceEntry(entry: PerformanceEntry): void { this.addPerformanceStatistic(entry.name, entry.duration); logger.debug(`${this.logPrefix()} '${entry.name}' performance entry: %j`, entry); } diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 38a212ca..6b3349d0 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -61,7 +61,7 @@ export default class Utils { return value; } // Check - if (typeof value === 'string') { + if (Utils.isString(value)) { // Create Object changedValue = parseInt(value); } @@ -74,7 +74,7 @@ export default class Utils { return 0; } // Check - if (typeof value === 'string') { + if (Utils.isString(value)) { // Create Object changedValue = parseFloat(value); } -- 2.34.1