this.connectorsStatus.get(connectorId).skippedConsecutiveTransactions = 0;
// Start transaction
const startResponse = await this.startTransaction(connectorId);
- this.connectorsStatus.get(connectorId).startTransactionRequests++;
- if (startResponse?.idTagInfo?.status !== AuthorizationStatus.ACCEPTED) {
- logger.warn(this.logPrefix(connectorId) + ' start transaction rejected');
- this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests++;
- } else {
+ if (startResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
// Wait until end of transaction
const waitTrxEnd =
Utils.getRandomInteger(this.configuration.maxDuration, this.configuration.minDuration) *
' started and will stop in ' +
Utils.formatDurationMilliSeconds(waitTrxEnd)
);
- this.connectorsStatus.get(connectorId).acceptedStartTransactionRequests++;
await Utils.sleep(waitTrxEnd);
// Stop transaction
logger.info(
}
this.connectorsStatus.get(connectorId).lastRunDate = new Date();
}
- await this.stopTransaction(connectorId);
this.connectorsStatus.get(connectorId).stoppedDate = new Date();
logger.info(
this.logPrefix(connectorId) +
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;
this.connectorsStatus.get(connectorId).skippedConsecutiveTransactions = 0;
this.connectorsStatus.get(connectorId).skippedTransactions =
this?.connectorsStatus.get(connectorId)?.skippedTransactions ?? 0;
private async startTransaction(
connectorId: number
- ): Promise<StartTransactionResponse | AuthorizeResponse> {
+ ): Promise<StartTransactionResponse | undefined> {
const measureId = 'StartTransaction with ATG';
const beginId = PerformanceStatistics.beginMeasure(measureId);
let startResponse: StartTransactionResponse;
connectorId,
idTag,
});
+ this.handleStartTransactionResponse(connectorId, startResponse);
PerformanceStatistics.endMeasure(measureId, beginId);
return startResponse;
}
this.connectorsStatus.get(connectorId).rejectedAuthorizeRequests++;
PerformanceStatistics.endMeasure(measureId, beginId);
- return authorizeResponse;
+ return startResponse;
}
logger.info(startTransactionLogMsg);
// Start transaction
connectorId,
idTag,
});
+ this.handleStartTransactionResponse(connectorId, startResponse);
PerformanceStatistics.endMeasure(measureId, beginId);
return startResponse;
}
StartTransactionRequest,
StartTransactionResponse
>(this.chargingStation, RequestCommand.START_TRANSACTION, { connectorId });
+ this.handleStartTransactionResponse(connectorId, startResponse);
PerformanceStatistics.endMeasure(measureId, beginId);
return startResponse;
}
const measureId = 'StopTransaction with ATG';
const beginId = PerformanceStatistics.beginMeasure(measureId);
let stopResponse: StopTransactionResponse;
- if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted) {
+ if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason);
this.connectorsStatus.get(connectorId).stopTransactionRequests++;
+ if (stopResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
+ this.connectorsStatus.get(connectorId).acceptedStopTransactionRequests++;
+ } else {
+ this.connectorsStatus.get(connectorId).rejectedStopTransactionRequests++;
+ }
} else {
const transactionId = this.chargingStation.getConnectorStatus(connectorId).transactionId;
logger.warn(
}:`
);
}
+
+ private handleStartTransactionResponse(
+ connectorId: number,
+ startResponse: StartTransactionResponse
+ ): void {
+ this.connectorsStatus.get(connectorId).startTransactionRequests++;
+ if (startResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
+ this.connectorsStatus.get(connectorId).acceptedStartTransactionRequests++;
+ } else {
+ logger.warn(this.logPrefix(connectorId) + ' start transaction rejected');
+ this.connectorsStatus.get(connectorId).rejectedStartTransactionRequests++;
+ }
+ }
}