From: Jérôme Benoit Date: Tue, 21 Sep 2021 22:37:53 +0000 (+0200) Subject: Guard transaction id fetching in ATG X-Git-Tag: v1.1.7~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8eb02b62ba8c1894f3b748f92ab14858535d39f8;p=e-mobility-charging-stations-simulator.git Guard transaction id fetching in ATG Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index a9930947..58a40f61 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -143,15 +143,16 @@ export default class AutomaticTransactionGenerator { private async stopTransaction(connectorId: number, reason: StopTransactionReason = StopTransactionReason.NONE): Promise { const measureId = 'StopTransaction with ATG'; const beginId = PerformanceStatistics.beginMeasure(measureId); - const transactionId = this.chargingStation.getConnector(connectorId).transactionId; + let transactionId = 0; let stopResponse: StopTransactionResponse; if (this.chargingStation.getConnector(connectorId)?.transactionStarted) { + transactionId = this.chargingStation.getConnector(connectorId).transactionId; stopResponse = await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId, this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId), this.chargingStation.getTransactionIdTag(transactionId), reason); } else { - logger.warn(`${this.logPrefix(connectorId)} trying to stop a not started transaction ${transactionId}`); + logger.warn(`${this.logPrefix(connectorId)} trying to stop a not started transaction${transactionId ? ' ' + transactionId.toString() : ''}`); } PerformanceStatistics.endMeasure(measureId, beginId); return stopResponse;