From 85d206672d2dc688827177e4de87a069c4b2cdc1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 22 Sep 2021 00:24:55 +0200 Subject: [PATCH] Remove uneeded condition on transaction status in ATG MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- manifest-cf-template.yml | 2 +- src/charging-station/AutomaticTransactionGenerator.ts | 6 ++---- src/charging-station/ChargingStation.ts | 6 +++--- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/manifest-cf-template.yml b/manifest-cf-template.yml index 91fc9172..4fac17bc 100644 --- a/manifest-cf-template.yml +++ b/manifest-cf-template.yml @@ -7,7 +7,7 @@ applications: - https://github.com/cloudfoundry/nodejs-buildpack no-route: true health-check-type: process - health-check-invocation-timeout: 30 + health-check-invocation-timeout: 10 command: node -r source-map-support/register dist/start.js env: # OPTIMIZE_MEMORY: true diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index de11a76f..a9930947 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -95,10 +95,8 @@ export default class AutomaticTransactionGenerator { logger.info(this.logPrefix(connectorId) + ' transaction ' + this.chargingStation.getConnector(connectorId).transactionId.toString() + ' will stop in ' + Utils.formatDurationMilliSeconds(waitTrxEnd)); await Utils.sleep(waitTrxEnd); // Stop transaction - if (this.chargingStation.getConnector(connectorId)?.transactionStarted) { - logger.info(this.logPrefix(connectorId) + ' stop transaction ' + this.chargingStation.getConnector(connectorId).transactionId.toString()); - await this.stopTransaction(connectorId); - } + logger.info(this.logPrefix(connectorId) + ' stop transaction ' + this.chargingStation.getConnector(connectorId).transactionId.toString()); + await this.stopTransaction(connectorId); } } else { skippedTransactions++; diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 38b89249..be94dadd 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -538,7 +538,7 @@ export default class ChargingStation { delete this.stationInfo.Connectors; // Initialize transaction attributes on connectors for (const connector in this.connectors) { - if (Utils.convertToInt(connector) > 0 && !this.getConnector(Utils.convertToInt(connector)).transactionStarted) { + if (Utils.convertToInt(connector) > 0 && !this.getConnector(Utils.convertToInt(connector))?.transactionStarted) { this.initTransactionAttributesOnConnector(Utils.convertToInt(connector)); } } @@ -766,7 +766,7 @@ export default class ChargingStation { private getNumberOfRunningTransactions(): number { let trxCount = 0; for (const connector in this.connectors) { - if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionStarted) { + if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector))?.transactionStarted) { trxCount++; } } @@ -883,7 +883,7 @@ export default class ChargingStation { this.automaticTransactionGenerator.stop(); } else { for (const connector in this.connectors) { - if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector)).transactionStarted) { + if (Utils.convertToInt(connector) > 0 && this.getConnector(Utils.convertToInt(connector))?.transactionStarted) { const transactionId = this.getConnector(Utils.convertToInt(connector)).transactionId; await this.ocppRequestService.sendStopTransaction(transactionId, this.getEnergyActiveImportRegisterByTransactionId(transactionId), this.getTransactionIdTag(transactionId), reason); diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 930c4b81..2301a0fe 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -242,7 +242,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer if (connectorId === 0) { let response: ChangeAvailabilityResponse = Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED; for (const connector in this.chargingStation.connectors) { - if (this.chargingStation.getConnector(Utils.convertToInt(connector)).transactionStarted) { + if (this.chargingStation.getConnector(Utils.convertToInt(connector))?.transactionStarted) { response = Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED; } this.chargingStation.getConnector(Utils.convertToInt(connector)).availability = commandPayload.type; -- 2.34.1