From 083fb002e7ae10bf53cc5890d1e403d556c549f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 1 Oct 2022 20:21:44 +0200 Subject: [PATCH] ATG: Cleanup connector statuses initialization MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../AutomaticTransactionGenerator.ts | 28 ++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 46c595f9..fb6e9d28 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -138,8 +138,7 @@ export default class AutomaticTransactionGenerator extends AsyncResource { } private async internalStartConnector(connectorId: number): Promise { - this.setConnectorStatus(connectorId); - this.connectorsStatus.get(connectorId).start = true; + this.setStartConnectorStatus(connectorId); logger.info( this.logPrefix(connectorId) + ' started on connector and will run for ' + @@ -252,28 +251,8 @@ export default class AutomaticTransactionGenerator extends AsyncResource { ); } - private setConnectorStatus(connectorId: number): void { - this.connectorsStatus.get(connectorId).authorizeRequests = - this?.connectorsStatus.get(connectorId)?.authorizeRequests ?? 0; - this.connectorsStatus.get(connectorId).acceptedAuthorizeRequests = - this?.connectorsStatus.get(connectorId)?.acceptedAuthorizeRequests ?? 0; - this.connectorsStatus.get(connectorId).rejectedAuthorizeRequests = - this?.connectorsStatus.get(connectorId)?.rejectedAuthorizeRequests ?? 0; - this.connectorsStatus.get(connectorId).startTransactionRequests = - this?.connectorsStatus.get(connectorId)?.startTransactionRequests ?? 0; - this.connectorsStatus.get(connectorId).acceptedStartTransactionRequests = - this?.connectorsStatus.get(connectorId)?.acceptedStartTransactionRequests ?? 0; - this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests = - this?.connectorsStatus.get(connectorId)?.rejectedStartTransactionRequests ?? 0; - this.connectorsStatus.get(connectorId).stopTransactionRequests = - this?.connectorsStatus.get(connectorId)?.stopTransactionRequests ?? 0; - this.connectorsStatus.get(connectorId).acceptedStopTransactionRequests = - this?.connectorsStatus.get(connectorId)?.acceptedStopTransactionRequests ?? 0; - this.connectorsStatus.get(connectorId).rejectedStopTransactionRequests = - this?.connectorsStatus.get(connectorId)?.rejectedStopTransactionRequests ?? 0; + private setStartConnectorStatus(connectorId: number): void { this.connectorsStatus.get(connectorId).skippedConsecutiveTransactions = 0; - this.connectorsStatus.get(connectorId).skippedTransactions = - this?.connectorsStatus.get(connectorId)?.skippedTransactions ?? 0; const previousRunDuration = this?.connectorsStatus.get(connectorId)?.startDate && this?.connectorsStatus.get(connectorId)?.lastRunDate @@ -289,8 +268,7 @@ export default class AutomaticTransactionGenerator extends AsyncResource { 1000 - previousRunDuration ); - this.connectorsStatus.get(connectorId).start = - this?.connectorsStatus.get(connectorId)?.start ?? false; + this.connectorsStatus.get(connectorId).start = true; } private initializeConnectorsStatus(): void { -- 2.34.1