From: Jérôme Benoit Date: Tue, 20 Oct 2020 14:58:41 +0000 (+0200) Subject: Cleanups. X-Git-Tag: v1.0.1-0~268 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=546dec0fafb76402766ba55c89866b9f8b329895;p=e-mobility-charging-stations-simulator.git Cleanups. Signed-off-by: Jérôme Benoit --- 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;