From 0bbcb3dc3d1b75955b816452fc0050d401e96fca Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 18 Oct 2020 02:25:09 +0200 Subject: [PATCH] Fix heartbeat initialization MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../station-templates/abb.station-template.json | 4 ++-- .../evlink.station-template.json | 4 ++-- .../keba.station-template.json | 4 ++-- .../schneider-imredd.station-template.json | 4 ++-- .../schneider.station-template.json | 4 ++-- .../siemens.mougins69.station-template.json | 4 ++-- .../virtual-simple-atg.station-template.json | 4 ++-- .../virtual-simple.station-template.json | 4 ++-- .../virtual.station-template.json | 4 ++-- .../AutomaticTransactionGenerator.js | 4 ++-- src/charging-station/ChargingStation.js | 17 +++++++++-------- 11 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/assets/station-templates/abb.station-template.json b/src/assets/station-templates/abb.station-template.json index 1fef0e8a..2b25cf49 100644 --- a/src/assets/station-templates/abb.station-template.json +++ b/src/assets/station-templates/abb.station-template.json @@ -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 diff --git a/src/assets/station-templates/evlink.station-template.json b/src/assets/station-templates/evlink.station-template.json index 41ba8e3e..936f95cb 100644 --- a/src/assets/station-templates/evlink.station-template.json +++ b/src/assets/station-templates/evlink.station-template.json @@ -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 diff --git a/src/assets/station-templates/keba.station-template.json b/src/assets/station-templates/keba.station-template.json index 9366edd3..d9b7bab9 100644 --- a/src/assets/station-templates/keba.station-template.json +++ b/src/assets/station-templates/keba.station-template.json @@ -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 diff --git a/src/assets/station-templates/schneider-imredd.station-template.json b/src/assets/station-templates/schneider-imredd.station-template.json index 0c7c53b6..56a6a837 100644 --- a/src/assets/station-templates/schneider-imredd.station-template.json +++ b/src/assets/station-templates/schneider-imredd.station-template.json @@ -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 diff --git a/src/assets/station-templates/schneider.station-template.json b/src/assets/station-templates/schneider.station-template.json index 0c7c53b6..56a6a837 100644 --- a/src/assets/station-templates/schneider.station-template.json +++ b/src/assets/station-templates/schneider.station-template.json @@ -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 diff --git a/src/assets/station-templates/siemens.mougins69.station-template.json b/src/assets/station-templates/siemens.mougins69.station-template.json index 9eecbc48..eae5f6ed 100644 --- a/src/assets/station-templates/siemens.mougins69.station-template.json +++ b/src/assets/station-templates/siemens.mougins69.station-template.json @@ -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 diff --git a/src/assets/station-templates/virtual-simple-atg.station-template.json b/src/assets/station-templates/virtual-simple-atg.station-template.json index 808d4c0c..8fe024d2 100644 --- a/src/assets/station-templates/virtual-simple-atg.station-template.json +++ b/src/assets/station-templates/virtual-simple-atg.station-template.json @@ -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 diff --git a/src/assets/station-templates/virtual-simple.station-template.json b/src/assets/station-templates/virtual-simple.station-template.json index f2cc557c..ca0b1062 100644 --- a/src/assets/station-templates/virtual-simple.station-template.json +++ b/src/assets/station-templates/virtual-simple.station-template.json @@ -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 diff --git a/src/assets/station-templates/virtual.station-template.json b/src/assets/station-templates/virtual.station-template.json index 2b8a2bc1..8eb43802 100644 --- a/src/assets/station-templates/virtual.station-template.json +++ b/src/assets/station-templates/virtual.station-template.json @@ -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 diff --git a/src/charging-station/AutomaticTransactionGenerator.js b/src/charging-station/AutomaticTransactionGenerator.js index 6d46afee..5e5a46cf 100644 --- a/src/charging-station/AutomaticTransactionGenerator.js +++ b/src/charging-station/AutomaticTransactionGenerator.js @@ -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; diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index b0a461fa..52d54958 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -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'); } -- 2.34.1