X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FAutomaticTransactionGenerator.ts;h=c5076adce7ca9a24f7c25ea50a45a1c916a355cf;hb=b9da1bc288a2a6ffccfbca6cd19aa195bc6ccfbf;hp=948b375e13c7a377ab0ece3a57f5ff85a04e9276;hpb=721f634101285d00d1c695031ed357b090d1a8f3;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 948b375e..c5076adc 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -2,10 +2,11 @@ import { AsyncResource } from 'node:async_hooks'; -import { type ChargingStation, ChargingStationUtils, IdTagsCache } from './internal'; +import type { ChargingStation } from './ChargingStation'; +import { ChargingStationUtils } from './ChargingStationUtils'; +import { IdTagsCache } from './IdTagsCache'; import { BaseError } from '../exception'; -// import { PerformanceStatistics } from '../performance'; -import { PerformanceStatistics } from '../performance/PerformanceStatistics'; +import { PerformanceStatistics } from '../performance'; import { AuthorizationStatus, type AuthorizeRequest, @@ -264,8 +265,8 @@ export class AutomaticTransactionGenerator extends AsyncResource { await this.stopTransaction(connectorId); } } else { - this.connectorsStatus.get(connectorId).skippedConsecutiveTransactions++; - this.connectorsStatus.get(connectorId).skippedTransactions++; + ++this.connectorsStatus.get(connectorId).skippedConsecutiveTransactions; + ++this.connectorsStatus.get(connectorId).skippedTransactions; logger.info( `${this.logPrefix(connectorId)} skipped consecutively ${this.connectorsStatus .get(connectorId) @@ -302,8 +303,7 @@ export class AutomaticTransactionGenerator extends AsyncResource { this.connectorsStatus.get(connectorId).startDate = new Date(); this.connectorsStatus.get(connectorId).stopDate = new Date( this.connectorsStatus.get(connectorId).startDate.getTime() + - (this.chargingStation.getAutomaticTransactionGeneratorConfiguration().stopAfterHours ?? - Constants.CHARGING_STATION_ATG_DEFAULT_STOP_AFTER_HOURS) * + this.chargingStation.getAutomaticTransactionGeneratorConfiguration().stopAfterHours * 3600 * 1000 - previousRunDuration @@ -380,9 +380,9 @@ export class AutomaticTransactionGenerator extends AsyncResource { >(this.chargingStation, RequestCommand.AUTHORIZE, { idTag, }); - this.connectorsStatus.get(connectorId).authorizeRequests++; + ++this.connectorsStatus.get(connectorId).authorizeRequests; if (authorizeResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) { - this.connectorsStatus.get(connectorId).acceptedAuthorizeRequests++; + ++this.connectorsStatus.get(connectorId).acceptedAuthorizeRequests; logger.info(startTransactionLogMsg); // Start transaction startResponse = await this.chargingStation.ocppRequestService.requestHandler< @@ -396,7 +396,7 @@ export class AutomaticTransactionGenerator extends AsyncResource { PerformanceStatistics.endMeasure(measureId, beginId); return startResponse; } - this.connectorsStatus.get(connectorId).rejectedAuthorizeRequests++; + ++this.connectorsStatus.get(connectorId).rejectedAuthorizeRequests; PerformanceStatistics.endMeasure(measureId, beginId); return startResponse; } @@ -432,11 +432,11 @@ export class AutomaticTransactionGenerator extends AsyncResource { let stopResponse: StopTransactionResponse; if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) { stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason); - this.connectorsStatus.get(connectorId).stopTransactionRequests++; + ++this.connectorsStatus.get(connectorId).stopTransactionRequests; if (stopResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) { - this.connectorsStatus.get(connectorId).acceptedStopTransactionRequests++; + ++this.connectorsStatus.get(connectorId).acceptedStopTransactionRequests; } else { - this.connectorsStatus.get(connectorId).rejectedStopTransactionRequests++; + ++this.connectorsStatus.get(connectorId).rejectedStopTransactionRequests; } } else { const transactionId = this.chargingStation.getConnectorStatus(connectorId)?.transactionId; @@ -468,12 +468,12 @@ export class AutomaticTransactionGenerator extends AsyncResource { connectorId: number, startResponse: StartTransactionResponse ): void { - this.connectorsStatus.get(connectorId).startTransactionRequests++; + ++this.connectorsStatus.get(connectorId).startTransactionRequests; if (startResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) { - this.connectorsStatus.get(connectorId).acceptedStartTransactionRequests++; + ++this.connectorsStatus.get(connectorId).acceptedStartTransactionRequests; } else { logger.warn(`${this.logPrefix(connectorId)} start transaction rejected`); - this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests++; + ++this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests; } } }