+ this.connectorsStatus.get(connectorId)
+ )
+ }
+
+ private setStartConnectorStatus (
+ connectorId: number,
+ stopAbsoluteDuration = this.chargingStation.getAutomaticTransactionGeneratorConfiguration()
+ ?.stopAbsoluteDuration
+ ): void {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.connectorsStatus.get(connectorId)!.startDate = new Date()
+ if (
+ stopAbsoluteDuration === false ||
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ !isValidDate(this.connectorsStatus.get(connectorId)!.stopDate)
+ ) {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.connectorsStatus.get(connectorId)!.stopDate = new Date(
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.connectorsStatus.get(connectorId)!.startDate!.getTime() +
+ hoursToMilliseconds(
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.chargingStation.getAutomaticTransactionGeneratorConfiguration()!.stopAfterHours
+ )
+ )
+ }
+ delete this.connectorsStatus.get(connectorId)?.stoppedDate
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.connectorsStatus.get(connectorId)!.skippedConsecutiveTransactions = 0
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ this.connectorsStatus.get(connectorId)!.start = true
+ }
+
+ private canStartConnector (connectorId: number): boolean {
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ if (new Date() > this.connectorsStatus.get(connectorId)!.stopDate!) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId
+ )} entered in transaction loop while the ATG stop date has been reached`
+ )
+ return false
+ }
+ if (!this.chargingStation.inAcceptedState()) {
+ logger.error(
+ `${this.logPrefix(
+ connectorId
+ )} entered in transaction loop while the charging station is not in accepted state`
+ )
+ return false
+ }
+ if (!this.chargingStation.isChargingStationAvailable()) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId
+ )} entered in transaction loop while the charging station is unavailable`
+ )
+ return false
+ }
+ if (!this.chargingStation.isConnectorAvailable(connectorId)) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId
+ )} entered in transaction loop while the connector ${connectorId} is unavailable`
+ )
+ return false
+ }
+ const connectorStatus = this.chargingStation.getConnectorStatus(connectorId)
+ if (connectorStatus?.transactionStarted === true) {
+ logger.info(
+ `${this.logPrefix(
+ connectorId
+ )} entered in transaction loop while a transaction ${connectorStatus.transactionId} is already started on connector ${connectorId}`
+ )
+ return false
+ }
+ return true