Fix unit conversion.
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStation.js
index 30330463a774397bfc16fdd1dda6d360659b147a..1f5c9b45d9c25568fa2c2d93d5709c41b46694da 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 / 1000 : 0));
+        this._addConfigurationKey('HeartbeatInterval', Utils.convertToInt(this._heartbeatInterval ? this._heartbeatInterval / 1000 : 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++) {
@@ -635,13 +632,13 @@ class ChargingStation {
         });
       }
     } else {
-      for (const configuration of commandPayload.key) {
-        const keyFound = this._getConfigurationKey(configuration);
+      for (const configurationKey of commandPayload.key) {
+        const keyFound = this._getConfigurationKey(configurationKey);
         if (keyFound) {
           if (Utils.isUndefined(keyFound.visible)) {
             keyFound.visible = true;
           } else {
-            keyFound.visible = Utils.convertToBoolean(configuration.visible);
+            keyFound.visible = Utils.convertToBoolean(configurationKey.visible);
           }
           if (!keyFound.visible) {
             continue;
@@ -652,7 +649,7 @@ class ChargingStation {
             value: keyFound.value,
           });
         } else {
-          unknownKey.push(configuration);
+          unknownKey.push(configurationKey);
         }
       }
     }
@@ -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;