+ private setStartConnectorStatus(connectorId: number): void {
+ this.connectorsStatus.get(connectorId).skippedConsecutiveTransactions = 0;
+ const previousRunDuration =
+ this?.connectorsStatus.get(connectorId)?.startDate &&
+ this?.connectorsStatus.get(connectorId)?.lastRunDate
+ ? this.connectorsStatus.get(connectorId).lastRunDate.getTime() -
+ this.connectorsStatus.get(connectorId).startDate.getTime()
+ : 0;
+ this.connectorsStatus.get(connectorId).startDate = new Date();
+ this.connectorsStatus.get(connectorId).stopDate = new Date(
+ this.connectorsStatus.get(connectorId).startDate.getTime() +
+ (this.configuration.stopAfterHours ??
+ Constants.CHARGING_STATION_ATG_DEFAULT_STOP_AFTER_HOURS) *
+ 3600 *
+ 1000 -
+ previousRunDuration
+ );
+ this.connectorsStatus.get(connectorId).start = true;
+ }
+
+ private initializeConnectorsStatus(): void {
+ for (const connectorId of this.chargingStation.connectors.keys()) {
+ if (connectorId > 0) {
+ this.connectorsStatus.set(connectorId, {
+ start: false,
+ authorizeRequests: 0,
+ acceptedAuthorizeRequests: 0,
+ rejectedAuthorizeRequests: 0,
+ startTransactionRequests: 0,
+ acceptedStartTransactionRequests: 0,
+ rejectedStartTransactionRequests: 0,
+ stopTransactionRequests: 0,
+ acceptedStopTransactionRequests: 0,
+ rejectedStopTransactionRequests: 0,
+ skippedConsecutiveTransactions: 0,
+ skippedTransactions: 0,
+ });
+ }
+ }
+ }
+
+ private async startTransaction(
+ connectorId: number
+ ): Promise<StartTransactionResponse | undefined> {
+ const measureId = 'StartTransaction with ATG';
+ const beginId = PerformanceStatistics.beginMeasure(measureId);
+ let startResponse: StartTransactionResponse;
+ if (this.chargingStation.hasAuthorizedTags()) {
+ const idTag = this.getIdTag(connectorId);
+ const startTransactionLogMsg = `${this.logPrefix(
+ connectorId
+ )} start transaction with an idTag '${idTag}'`;
+ if (this.getRequireAuthorize()) {
+ this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag;
+ // Authorize idTag
+ const authorizeResponse: AuthorizeResponse =
+ await this.chargingStation.ocppRequestService.requestHandler<
+ AuthorizeRequest,
+ AuthorizeResponse
+ >(this.chargingStation, RequestCommand.AUTHORIZE, {
+ idTag,
+ });
+ this.connectorsStatus.get(connectorId).authorizeRequests++;