From 546dec0fafb76402766ba55c89866b9f8b329895 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 20 Oct 2020 16:58:41 +0200 Subject: [PATCH] Cleanups. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/AutomaticTransactionGenerator.js | 3 ++- src/charging-station/ChargingStation.js | 6 +++--- src/utils/Constants.js | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/charging-station/AutomaticTransactionGenerator.js b/src/charging-station/AutomaticTransactionGenerator.js index 90576e9e..6e2afe12 100644 --- a/src/charging-station/AutomaticTransactionGenerator.js +++ b/src/charging-station/AutomaticTransactionGenerator.js @@ -1,4 +1,5 @@ const logger = require('../utils/Logger'); +const Constants = require('../utils/Constants'); const Utils = require('../utils/Utils'); const {performance, PerformanceObserver} = require('perf_hooks'); @@ -68,7 +69,7 @@ class AutomaticTransactionGenerator { const startResponse = await startTransaction(connectorId, this); if (startResponse.idTagInfo.status !== 'Accepted') { logger.info(this._basicFormatLog(connectorId) + ' transaction rejected'); - await Utils.sleep(2000); + await Utils.sleep(Constants.CHARGING_STATION_ATG_WAIT_TIME); } else { // Wait until end of transaction const wait = Utils.getRandomInt(this._chargingStation._stationInfo.AutomaticTransactionGenerator.maxDuration, diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index f644003c..397bef20 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -268,7 +268,7 @@ class ChargingStation { await sendMeterValues(connectorID, interval, this); }, interval); } else { - logger.info(`${this._basicFormatLog()} Charging station MeterValueSampleInterval configuration set to ${interval}ms, not sending MeterValues`); + logger.error(`${this._basicFormatLog()} Charging station MeterValueSampleInterval configuration set to ${interval}ms, not sending MeterValues`); } } @@ -350,7 +350,7 @@ class ChargingStation { } if (this._isSocketRestart) { this._basicStartMessageSequence(); - if (this._messageQueue.length > 0) { + if (!Utils.isEmptyArray(this._messageQueue)) { this._messageQueue.forEach((message) => { if (this._wsConnection && this._wsConnection.readyState === WebSocket.OPEN) { this._wsConnection.send(message); @@ -740,7 +740,7 @@ class ChargingStation { } handleResponseStatusNotification(payload, requestPayload) { - logger.debug(this._basicFormatLog() + ' Status notification response received: %j to status notification request: %j', payload, requestPayload); + logger.debug(this._basicFormatLog() + ' Status notification response received: %j to StatusNotification request: %j', payload, requestPayload); } handleResponseMeterValues(payload, requestPayload) { diff --git a/src/utils/Constants.js b/src/utils/Constants.js index 38e4b221..ba2412c2 100644 --- a/src/utils/Constants.js +++ b/src/utils/Constants.js @@ -139,7 +139,8 @@ class Constants { static STATUS_NOTIFICATION_TIMEOUT = 500; static START_TRANSACTION_TIMEOUT = 500; - static CHARGING_STATION_DEFAULT_RESET_TIME = 60000 // ms; + static CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // ms + static CHARGING_STATION_ATG_WAIT_TIME = 2000; // ms } module.exports = Constants; -- 2.34.1