cloneObject,
formatDurationMilliSeconds,
getRandomInteger,
+ isValidTime,
logPrefix,
logger,
secureRandom,
}
} else {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.skippedConsecutiveTransactions!
+ ++this.connectorsStatus.get(connectorId)!.skippedConsecutiveTransactions
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.skippedTransactions!
+ ++this.connectorsStatus.get(connectorId)!.skippedTransactions
logger.info(
`${this.logPrefix(connectorId)} skipped consecutively ${this.connectorsStatus.get(
connectorId
}
private setStartConnectorStatus (connectorId: number): void {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.connectorsStatus.get(connectorId)!.skippedConsecutiveTransactions = 0
const previousRunDuration =
- this.connectorsStatus.get(connectorId)?.startDate != null &&
- this.connectorsStatus.get(connectorId)?.lastRunDate != null
+ isValidTime(this.connectorsStatus.get(connectorId)?.startDate) &&
+ isValidTime(this.connectorsStatus.get(connectorId)?.lastRunDate)
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.connectorsStatus.get(connectorId)!.lastRunDate!.getTime() -
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
) -
previousRunDuration
)
+ 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()) {
private getConnectorStatus (connectorId: number): Status {
const connectorStatus =
- this.chargingStation.getAutomaticTransactionGeneratorStatuses()?.[connectorId] != null
+ this.chargingStation.getAutomaticTransactionGeneratorStatuses()?.[connectorId - 1] != null
? cloneObject<Status>(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.chargingStation.getAutomaticTransactionGeneratorStatuses()![connectorId]
+ this.chargingStation.getAutomaticTransactionGeneratorStatuses()![connectorId - 1]
)
: undefined
this.resetConnectorStatus(connectorStatus)
if (connectorStatus == null) {
return
}
- delete connectorStatus.startDate
- delete connectorStatus.lastRunDate
- delete connectorStatus.stopDate
- delete connectorStatus.stoppedDate
if (
!this.started &&
(connectorStatus.start ||
)} start transaction with an idTag '${idTag}'`
if (this.getRequireAuthorize()) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.authorizeRequests!
+ ++this.connectorsStatus.get(connectorId)!.authorizeRequests
if (await isIdTagAuthorized(this.chargingStation, connectorId, idTag)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.acceptedAuthorizeRequests!
+ ++this.connectorsStatus.get(connectorId)!.acceptedAuthorizeRequests
logger.info(startTransactionLogMsg)
// Start transaction
startResponse = await this.chargingStation.ocppRequestService.requestHandler<
return startResponse
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.rejectedAuthorizeRequests!
+ ++this.connectorsStatus.get(connectorId)!.rejectedAuthorizeRequests
PerformanceStatistics.endMeasure(measureId, beginId)
return startResponse
}
)
stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.stopTransactionRequests!
+ ++this.connectorsStatus.get(connectorId)!.stopTransactionRequests
if (stopResponse.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.acceptedStopTransactionRequests!
+ ++this.connectorsStatus.get(connectorId)!.acceptedStopTransactionRequests
} else {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.rejectedStopTransactionRequests!
+ ++this.connectorsStatus.get(connectorId)!.rejectedStopTransactionRequests
}
} else {
const transactionId = this.chargingStation.getConnectorStatus(connectorId)?.transactionId
startResponse: StartTransactionResponse
): void {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.startTransactionRequests!
+ ++this.connectorsStatus.get(connectorId)!.startTransactionRequests
if (startResponse.idTagInfo.status === AuthorizationStatus.ACCEPTED) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.acceptedStartTransactionRequests!
+ ++this.connectorsStatus.get(connectorId)!.acceptedStartTransactionRequests
} else {
logger.warn(`${this.logPrefix(connectorId)} start transaction rejected`)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- ++this.connectorsStatus.get(connectorId)!.rejectedStartTransactionRequests!
+ ++this.connectorsStatus.get(connectorId)!.rejectedStartTransactionRequests
}
}
}
lastRunDate?: Date
stopDate?: Date
stoppedDate?: Date
- authorizeRequests?: number
- acceptedAuthorizeRequests?: number
- rejectedAuthorizeRequests?: number
- startTransactionRequests?: number
- acceptedStartTransactionRequests?: number
- rejectedStartTransactionRequests?: number
- stopTransactionRequests?: number
- acceptedStopTransactionRequests?: number
- rejectedStopTransactionRequests?: number
- skippedConsecutiveTransactions?: number
- skippedTransactions?: number
+ authorizeRequests: number
+ acceptedAuthorizeRequests: number
+ rejectedAuthorizeRequests: number
+ startTransactionRequests: number
+ acceptedStartTransactionRequests: number
+ rejectedStartTransactionRequests: number
+ stopTransactionRequests: number
+ acceptedStopTransactionRequests: number
+ rejectedStopTransactionRequests: number
+ skippedConsecutiveTransactions: number
+ skippedTransactions: number
}
export interface ChargingStationAutomaticTransactionGeneratorConfiguration {