X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FChargingStation.ts;h=8341fe30a71612a1b52ff5da90ca5245dde53d09;hb=4faad557cd49253297c7d0230db2eecfd850b4f4;hp=b8ac0233f8abb66ff4c17d4e0da0ad803eaab2c0;hpb=ef6076c1764c5e4a8fcd6adcec68aa72b2a64ac4;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index b8ac0233..8341fe30 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -75,9 +75,9 @@ export default class ChargingStation { let instanceIndex = process.env.CF_INSTANCE_INDEX ? process.env.CF_INSTANCE_INDEX : 0; instanceIndex = instanceIndex > 0 ? instanceIndex : ''; - const idSuffix = Configuration.getChargingStationIdSuffix(); + const idSuffix = stationTemplate.nameSuffix ? stationTemplate.nameSuffix : ''; - return stationTemplate.fixedName ? stationTemplate.baseName : stationTemplate.baseName + '-' + instanceIndex + ('000000000' + this._index.toString()).substr(('000000000' + this._index.toString()).length - 4) + idSuffix; + return stationTemplate.fixedName ? stationTemplate.baseName : stationTemplate.baseName + '-' + instanceIndex.toString() + ('000000000' + this._index.toString()).substr(('000000000' + this._index.toString()).length - 4) + idSuffix; } _buildStationInfo(): ChargingStationInfo { @@ -527,7 +527,7 @@ export default class ChargingStation { } _startAuthorizationFileMonitoring(): void { - fs.watch(this._getAuthorizationFile()).on("change", e => { + fs.watch(this._getAuthorizationFile()).on('change', (e) => { try { logger.debug(this._logPrefix() + ' Authorization file ' + this._getAuthorizationFile() + ' have changed, reload'); // Initialize _authorizedTags @@ -539,7 +539,7 @@ export default class ChargingStation { } _startStationTemplateFileMonitoring(): void { - fs.watch(this._stationTemplateFile).on("change", e => { + fs.watch(this._stationTemplateFile).on('change', (e) => { try { logger.debug(this._logPrefix() + ' Template file ' + this._stationTemplateFile + ' have changed, reload'); // Initialize @@ -828,7 +828,7 @@ export default class ChargingStation { async sendAuthorize(idTag?: string): Promise { try { const payload: AuthorizeRequest = { - ...!Utils.isUndefined(idTag) ? { idTag } : { idTag: Constants.TRANSACTION_DEFAULT_IDTAG }, + ...!Utils.isUndefined(idTag) ? { idTag } : { idTag: Constants.TRANSACTION_DEFAULT_TAGID }, }; return await this.sendMessage(Utils.generateUUID(), payload, MessageType.CALL_MESSAGE, RequestCommand.AUTHORIZE) as AuthorizeResponse; } catch (error) { @@ -840,7 +840,7 @@ export default class ChargingStation { try { const payload: StartTransactionRequest = { connectorId, - ...!Utils.isUndefined(idTag) ? { idTag } : { idTag: Constants.TRANSACTION_DEFAULT_IDTAG }, + ...!Utils.isUndefined(idTag) ? { idTag } : { idTag: Constants.TRANSACTION_DEFAULT_TAGID }, meterStart: 0, timestamp: new Date().toISOString(), }; @@ -1009,7 +1009,7 @@ export default class ChargingStation { return; } - if (payload.idTagInfo.status === AuthorizationStatus.ACCEPTED) { + if (payload?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) { this.getConnector(connectorId).transactionStarted = true; this.getConnector(connectorId).transactionId = payload.transactionId; this.getConnector(connectorId).idTag = requestPayload.idTag; @@ -1023,7 +1023,7 @@ export default class ChargingStation { this._startMeterValues(connectorId, configuredMeterValueSampleInterval ? Utils.convertToInt(configuredMeterValueSampleInterval.value) * 1000 : 60000); } else { - logger.error(this._logPrefix() + ' Starting transaction id ' + payload.transactionId.toString() + ' REJECTED with status ' + payload.idTagInfo.status + ', idTag ' + requestPayload.idTag); + logger.error(this._logPrefix() + ' Starting transaction id ' + payload.transactionId.toString() + ' REJECTED with status ' + payload?.idTagInfo?.status + ', idTag ' + requestPayload.idTag); this._resetTransactionOnConnector(connectorId); await this.sendStatusNotification(connectorId, ChargePointStatus.AVAILABLE); }