- // eslint-disable-next-line consistent-this
- private async startTransaction(connectorId: number, self: AutomaticTransactionGenerator): Promise<StartTransactionResponse | AuthorizeResponse> {
- if (self.chargingStation.hasAuthorizedTags()) {
- const tagId = self.chargingStation.getRandomTagId();
- if (self.chargingStation.stationInfo.AutomaticTransactionGenerator.requireAuthorize) {
- // Authorize tagId
- const authorizeResponse = await self.chargingStation.sendAuthorize(tagId);
+ private stopConnector(connectorId: number): void {
+ this.connectorsStatus.set(connectorId, { ...this.connectorsStatus.get(connectorId), start: false });
+ }
+
+ private initStartConnectorStatus(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).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)
+ ? (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.chargingStation.stationInfo?.AutomaticTransactionGenerator?.stopAfterHours ?? Constants.CHARGING_STATION_ATG_DEFAULT_STOP_AFTER_HOURS) * 3600 * 1000
+ - previousRunDuration);
+ this.connectorsStatus.get(connectorId).start = true;
+ }
+
+ 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 idTag = this.chargingStation.getRandomIdTag();
+ if (this.chargingStation.getAutomaticTransactionGeneratorRequireAuthorize()) {
+ // Authorize idTag
+ const authorizeResponse = await this.chargingStation.ocppRequestService.sendAuthorize(connectorId, idTag);
+ this.connectorsStatus.get(connectorId).authorizeRequests++;