- async startTransaction(connectorId: number, self: AutomaticTransactionGenerator): Promise<unknown> {
- if (self._chargingStation.hasAuthorizedTags()) {
- const tagId = self._chargingStation.getRandomTagId();
- logger.info(self._logPrefix(connectorId) + ' start transaction for tagID ' + tagId);
- return await self._chargingStation.sendStartTransaction(connectorId, tagId);
+ private async startTransaction(connectorId: number): Promise<StartTransactionResponse | AuthorizeResponse> {
+ const measureId = 'StartTransaction with ATG';
+ const beginId = PerformanceStatistics.beginMeasure(measureId);
+ let startResponse: StartTransactionResponse;
+ if (this.chargingStation.hasAuthorizedTags()) {
+ const tagId = this.chargingStation.getRandomTagId();
+ if (this.chargingStation.getAutomaticTransactionGeneratorRequireAuthorize()) {
+ // Authorize tagId
+ const authorizeResponse = await this.chargingStation.ocppRequestService.sendAuthorize(connectorId, tagId);
+ if (authorizeResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
+ logger.info(this.logPrefix(connectorId) + ' start transaction for tagID ' + tagId);
+ // Start transaction
+ startResponse = await this.chargingStation.ocppRequestService.sendStartTransaction(connectorId, tagId);
+ PerformanceStatistics.endMeasure(measureId, beginId);
+ return startResponse;
+ }
+ PerformanceStatistics.endMeasure(measureId, beginId);
+ return authorizeResponse;
+ }
+ logger.info(this.logPrefix(connectorId) + ' start transaction for tagID ' + tagId);
+ // Start transaction
+ startResponse = await this.chargingStation.ocppRequestService.sendStartTransaction(connectorId, tagId);
+ PerformanceStatistics.endMeasure(measureId, beginId);
+ return startResponse;