Fix template reload.
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 19 Oct 2020 11:40:31 +0000 (13:40 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 19 Oct 2020 11:40:31 +0000 (13:40 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.js

index be4f161380c6fad845520e4cb2b5139fe79fd621..3e0f9bfcdfc73ab236e6ac7daf6a8609ef0875e6 100644 (file)
@@ -95,6 +95,9 @@ class ChargingStation {
         logger.debug(this._basicFormatLog() + ' Template file ' + this._stationTemplateFile + ' have changed, reload');
         // Initialize
         this._initialize();
+        this._addConfigurationKey('HeartBeatInterval', Utils.convertToInt(this._heartbeatInterval ? this._heartbeatInterval : 0));
+        this._addConfigurationKey('HeartbeatInterval', Utils.convertToInt(this._heartbeatInterval ? this._heartbeatInterval : 0), false, false);
+        this._addConfigurationKey('NumberOfConnectors', this._getMaxConnectors(), true);
       } catch (error) {
         logger.error(this._basicFormatLog() + ' Charging station template file monitoring error: ' + error);
       }
@@ -440,13 +443,7 @@ class ChargingStation {
           this._connectors[lastConnector] = connectorsConfig[lastConnector];
         }
       }
-      let maxConnectors = 0;
-      if (Array.isArray(this._stationInfo.numberOfConnectors)) {
-        // Generate some connectors
-        maxConnectors = this._stationInfo.numberOfConnectors[(this._index - 1) % this._stationInfo.numberOfConnectors.length];
-      } else {
-        maxConnectors = this._stationInfo.numberOfConnectors;
-      }
+      const maxConnectors = this._getMaxConnectors();
       this._addConfigurationKey('NumberOfConnectors', maxConnectors, true);
       // Generate all connectors
       for (let index = 1; index <= maxConnectors; index++) {
@@ -835,6 +832,17 @@ class ChargingStation {
   _getConnector(number) {
     return this._stationInfo.Connectors[number];
   }
+
+  _getMaxConnectors() {
+    let maxConnectors = 0;
+    if (Array.isArray(this._stationInfo.numberOfConnectors)) {
+      // Generate some connectors
+      maxConnectors = this._stationInfo.numberOfConnectors[(this._index - 1) % this._stationInfo.numberOfConnectors.length];
+    } else {
+      maxConnectors = this._stationInfo.numberOfConnectors;
+    }
+    return maxConnectors;
+  }
 }
 
 module.exports = ChargingStation;