X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.js;h=2bed5ff0ef5ffc69c209248bccfb1ab2fc85b8c5;hb=83045896422827d214fa8795795967d1688d1533;hp=b0a461fadd6f8269af2c902f727dccbecffc40a7;hpb=72766a82a1372713a48d9e7143a0348d7fd56a29;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index b0a461fa..2bed5ff0 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -24,7 +24,7 @@ class ChargingStation { this._isSocketRestart = false; - this._authorizedTags = this._getAuthorizedTags(); + this._authorizedTags = this._loadAndGetAuthorizedTags(); } _initialize() { @@ -32,7 +32,7 @@ class ChargingStation { this._bootNotificationMessage = { chargePointModel: this._stationInfo.chargePointModel, chargePointVendor: this._stationInfo.chargePointVendor, - // chargePointSerialNumber: this._stationInfo.chargePointSerialNumber, + chargePointSerialNumber: this._stationInfo.chargePointSerialNumberPrefix ? this._stationInfo.chargePointSerialNumberPrefix : '', firmwareVersion: this._stationInfo.firmwareVersion ? this._stationInfo.firmwareVersion : '', }; this._configuration = this._getConfiguration(); @@ -57,7 +57,7 @@ class ChargingStation { return this._stationInfo.authorizationFile ? this._stationInfo.authorizationFile : ''; } - _getAuthorizedTags() { + _loadAndGetAuthorizedTags() { let authorizedTags = []; const authorizationFile = this._getAuthorizationFile(); if (authorizationFile) { @@ -81,7 +81,7 @@ class ChargingStation { try { logger.debug(this._basicFormatLog() + ' Authorization file ' + this._getAuthorizationFile() + ' have changed, reload'); // Initialize _authorizedTags - this._authorizedTags = this._getAuthorizedTags(); + this._authorizedTags = this._loadAndGetAuthorizedTags(); } catch (error) { logger.error(this._basicFormatLog() + ' Authorization file monitoring error: ' + error); } @@ -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'); }