Fix heartbeat initialization
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Oct 2020 00:25:09 +0000 (02:25 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Oct 2020 00:25:09 +0000 (02:25 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/assets/station-templates/abb.station-template.json
src/assets/station-templates/evlink.station-template.json
src/assets/station-templates/keba.station-template.json
src/assets/station-templates/schneider-imredd.station-template.json
src/assets/station-templates/schneider.station-template.json
src/assets/station-templates/siemens.mougins69.station-template.json
src/assets/station-templates/virtual-simple-atg.station-template.json
src/assets/station-templates/virtual-simple.station-template.json
src/assets/station-templates/virtual.station-template.json
src/charging-station/AutomaticTransactionGenerator.js
src/charging-station/ChargingStation.js

index 1fef0e8abccefb9d44d9c5bcf981fb2e4f0d8ac5..2b25cf4976ad8a64d2fe7d82db5c25761ba50092 100644 (file)
@@ -48,8 +48,8 @@
     "enable": true,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": true
index 41ba8e3ebafedf9f393733b810b61234cdff1635..936f95cbae9e11d59482a58b08246b5f4502ac1b 100644 (file)
@@ -40,8 +40,8 @@
     "enable": false,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index 9366edd38d4b760a33c35fde2a42ba84fcd845be..d9b7bab90caeac089299ed035f9b7598d036076d 100644 (file)
@@ -41,8 +41,8 @@
     "enable": false,
     "minDuration": 30,
     "maxDuration": 60,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index 0c7c53b6a8e960fc5fe32ea68207c9b653cdd3ed..56a6a837880663164e843230b2bda91dfdd0b3ca 100644 (file)
@@ -40,8 +40,8 @@
     "enable": false,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index 0c7c53b6a8e960fc5fe32ea68207c9b653cdd3ed..56a6a837880663164e843230b2bda91dfdd0b3ca 100644 (file)
@@ -40,8 +40,8 @@
     "enable": false,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index 9eecbc4816f0fa3619d91c22e4f455e7de65b38e..eae5f6ed189a01a84b999f6f73f6448df2732f92 100644 (file)
@@ -41,8 +41,8 @@
     "enable": false,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index 808d4c0c90abef2ba7b07579c7e7fcb14ec815fe..8fe024d298d5614da712cde532480d02397224a3 100644 (file)
@@ -40,8 +40,8 @@
     "enable": true,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index f2cc557c2956d32cfa00710a084b54f2b42db286..ca0b1062b4ca59767ea6a640f7fd4af0530df398 100644 (file)
@@ -40,8 +40,8 @@
     "enable": false,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index 2b8a2bc18fc0e842ccdf40723378bfeccf3fc79c..8eb438023ce16a210adaaa7a94815a19b2d554dc 100644 (file)
@@ -40,8 +40,8 @@
     "enable": false,
     "minDuration": 60,
     "maxDuration": 80,
-    "minDelayBetweenTwoTransaction": 15,
-    "maxDelayBetweenTwoTransaction": 30,
+    "minDelayBetweenTwoTransactions": 15,
+    "maxDelayBetweenTwoTransactions": 30,
     "probabilityOfStart": 1,
     "stopAfterHours": 0.3,
     "stopOnConnectionFailure": false
index 6d46afee9c529a29506052b032ecdc83197c8202..5e5a46cf92e20e2373f2f6f4f48852f9831c598e 100644 (file)
@@ -53,8 +53,8 @@ class AutomaticTransactionGenerator {
 
   async startConnector(connectorId) {
     do {
-      const wait = Utils.getRandomInt(this._chargingStation._stationInfo.AutomaticTransactionGenerator.maxDelayBetweenTwoTransaction,
-          this._chargingStation._stationInfo.AutomaticTransactionGenerator.minDelayBetweenTwoTransaction) * 1000;
+      const wait = Utils.getRandomInt(this._chargingStation._stationInfo.AutomaticTransactionGenerator.maxDelayBetweenTwoTransactions,
+          this._chargingStation._stationInfo.AutomaticTransactionGenerator.minDelayBetweenTwoTransactions) * 1000;
       logger.info(this._basicFormatLog(connectorId) + ' wait for ' + Utils.secondstoHHMMSS(wait / 1000));
       await Utils.sleep(wait);
       if (this._timeToStop) break;
index b0a461fadd6f8269af2c902f727dccbecffc40a7..52d54958fa4e0ad003de9de88465becd944a2c35 100644 (file)
@@ -172,6 +172,14 @@ class ChargingStation {
 
   onOpen() {
     logger.info(`${this._basicFormatLog()} Is connected to server through ${this._url}`);
+    if (!this._heartbeatInterval) {
+      // Send BootNotification
+      try {
+        this.sendMessage(Utils.generateUUID(), this._bootNotificationMessage, Constants.OCPP_JSON_CALL_MESSAGE, 'BootNotification');
+      } catch (error) {
+        logger.error(this._basicFormatLog() + ' Send boot notification error: ' + error);
+      }
+    }
     if (this._isSocketRestart) {
       this._basicStartMessageSequence();
       if (this._messageQueue.length > 0) {
@@ -181,13 +189,6 @@ class ChargingStation {
           }
         });
       }
-    } else {
-      // At first start, send BootNotification
-      try {
-        this.sendMessage(Utils.generateUUID(), this._bootNotificationMessage, Constants.OCPP_JSON_CALL_MESSAGE, 'BootNotification');
-      } catch (error) {
-        logger.error(this._basicFormatLog() + ' Send boot notification error: ' + error);
-      }
     }
     this._autoReconnectRetryCount = 0;
     this._isSocketRestart = false;
@@ -286,7 +287,6 @@ class ChargingStation {
   // eslint-disable-next-line class-methods-use-this
   async _startHeartbeat(self) {
     if (self._heartbeatInterval && !self._heartbeatSetInterval) {
-      logger.info(self._basicFormatLog() + ' Heartbeat started every ' + self._heartbeatInterval + 'ms');
       self._heartbeatSetInterval = setInterval(() => {
         try {
           const payload = {
@@ -297,6 +297,7 @@ class ChargingStation {
           logger.error(self._basicFormatLog() + ' Send heartbeat error: ' + error);
         }
       }, self._heartbeatInterval);
+      logger.info(self._basicFormatLog() + ' Heartbeat started every ' + self._heartbeatInterval + 'ms');
     } else {
       logger.error(self._basicFormatLog() + ' Heartbeat interval undefined, not starting the heartbeat');
     }