Fix performance statistics handling at charging station template reload
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 14 Aug 2021 08:43:50 +0000 (10:43 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 14 Aug 2021 08:43:50 +0000 (10:43 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
.gitmodules [deleted file]
src/assets/configs-aws [deleted submodule]
src/assets/configs-scp [deleted submodule]
src/charging-station/ChargingStation.ts
src/utils/PerformanceStatistics.ts
src/utils/Utils.ts

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644 (file)
index ac1a6d1..0000000
+++ /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 (submodule)
index 2dc38e3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 2dc38e36a569dc1266e48d85e7e87ed0d3f18528
diff --git a/src/assets/configs-scp b/src/assets/configs-scp
deleted file mode 160000 (submodule)
index cf40aec..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit cf40aecc4b7c099f6b5b8bc6690f975a6db006b6
index 4fc275bcdc7cc0b5f5206b5d731748b525d30f9f..e9420089086639754f86c687007b1aa420e216a8 100644 (file)
@@ -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);
index 49f75adea6ef7fa12f43b82ad6b1aa967ea0e3ef..4ef732f7edee028756b976f316caa4f28f7218ee 100644 (file)
@@ -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);
   }
index 38a212ca20c3f081cf2a9f6a2ec12719e49c70c1..6b3349d0af83d5fb7c9c7b4c8f140762ff6adc5f 100644 (file)
@@ -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);
     }