Remove uneeded condition on transaction status in ATG
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Sep 2021 22:24:55 +0000 (00:24 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Sep 2021 22:24:55 +0000 (00:24 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
manifest-cf-template.yml
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index 91fc9172c2e69435b1078ba8fc0953ef39ec6db1..4fac17bc862aa75b19752916aff4c347ae10d640 100644 (file)
@@ -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
index de11a76f5f2efa9dbae1577a4c658d6ae1af2cd7..a9930947f19b40384c2da629114c1674c2965700 100644 (file)
@@ -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++;
index 38b89249e86f7da308b6334465a418def18332a6..be94daddfe0fadeaf61c6b5778d13e0a947a6d1b 100644 (file)
@@ -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);
index 930c4b81dfde1b0ba038dfc8dcc729ee72cb6735..2301a0fec0d54a744db8f8a8adfc7a993ded3c7d 100644 (file)
@@ -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;