): AutomaticTransactionGenerator | undefined {
if (AutomaticTransactionGenerator.instances.has(chargingStation.stationInfo.hashId) === false) {
AutomaticTransactionGenerator.instances.set(
chargingStation.stationInfo.hashId,
): AutomaticTransactionGenerator | undefined {
if (AutomaticTransactionGenerator.instances.has(chargingStation.stationInfo.hashId) === false) {
AutomaticTransactionGenerator.instances.set(
chargingStation.stationInfo.hashId,
this.runInAsyncScope(
this.internalStartConnector.bind(this) as (
this: AutomaticTransactionGenerator,
this.runInAsyncScope(
this.internalStartConnector.bind(this) as (
this: AutomaticTransactionGenerator,
).catch(Constants.EMPTY_FUNCTION);
} else if (this.connectorsStatus.get(connectorId)?.start === true) {
logger.warn(`${this.logPrefix(connectorId)} is already started on connector`);
).catch(Constants.EMPTY_FUNCTION);
} else if (this.connectorsStatus.get(connectorId)?.start === true) {
logger.warn(`${this.logPrefix(connectorId)} is already started on connector`);
throw new BaseError(`Connector ${connectorId} does not exist`);
}
if (this.connectorsStatus.get(connectorId)?.start === true) {
throw new BaseError(`Connector ${connectorId} does not exist`);
}
if (this.connectorsStatus.get(connectorId)?.start === true) {
} else if (this.connectorsStatus.get(connectorId)?.start === false) {
logger.warn(`${this.logPrefix(connectorId)} is already stopped on connector`);
}
} else if (this.connectorsStatus.get(connectorId)?.start === false) {
logger.warn(`${this.logPrefix(connectorId)} is already stopped on connector`);
}
- this.connectorsStatus.get(connectorId).stopDate.getTime() -
- this.connectorsStatus.get(connectorId).startDate.getTime()
- )}`
+ this.connectorsStatus.get(connectorId)!.stopDate!.getTime() -
+ this.connectorsStatus.get(connectorId)!.startDate!.getTime(),
+ )}`,
this.chargingStation.getAutomaticTransactionGeneratorConfiguration()
.maxDelayBetweenTwoTransactions,
this.chargingStation.getAutomaticTransactionGeneratorConfiguration()
this.chargingStation.getAutomaticTransactionGeneratorConfiguration()
.maxDelayBetweenTwoTransactions,
this.chargingStation.getAutomaticTransactionGeneratorConfiguration()
// Start transaction
const startResponse = await this.startTransaction(connectorId);
if (startResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
// Start transaction
const startResponse = await this.startTransaction(connectorId);
if (startResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
) * 1000;
logger.info(
`${this.logPrefix(connectorId)} transaction started with id ${this.chargingStation
.getConnectorStatus(connectorId)
?.transactionId?.toString()} and will stop in ${formatDurationMilliSeconds(
) * 1000;
logger.info(
`${this.logPrefix(connectorId)} transaction started with id ${this.chargingStation
.getConnectorStatus(connectorId)
?.transactionId?.toString()} and will stop in ${formatDurationMilliSeconds(
);
await sleep(waitTrxEnd);
// Stop transaction
logger.info(
`${this.logPrefix(connectorId)} stop transaction with id ${this.chargingStation
.getConnectorStatus(connectorId)
);
await sleep(waitTrxEnd);
// Stop transaction
logger.info(
`${this.logPrefix(connectorId)} stop transaction with id ${this.chargingStation
.getConnectorStatus(connectorId)
- ++this.connectorsStatus.get(connectorId).skippedConsecutiveTransactions;
- ++this.connectorsStatus.get(connectorId).skippedTransactions;
+ ++this.connectorsStatus.get(connectorId)!.skippedConsecutiveTransactions!;
+ ++this.connectorsStatus.get(connectorId)!.skippedTransactions!;
logger.info(
`${this.logPrefix(connectorId)} skipped consecutively ${this.connectorsStatus
.get(connectorId)
?.skippedConsecutiveTransactions?.toString()}/${this.connectorsStatus
.get(connectorId)
logger.info(
`${this.logPrefix(connectorId)} skipped consecutively ${this.connectorsStatus
.get(connectorId)
?.skippedConsecutiveTransactions?.toString()}/${this.connectorsStatus
.get(connectorId)
- this.connectorsStatus.get(connectorId).stoppedDate.getTime() -
- this.connectorsStatus.get(connectorId).startDate.getTime()
- )}`
+ this.connectorsStatus.get(connectorId)!.stoppedDate!.getTime() -
+ this.connectorsStatus.get(connectorId)!.startDate!.getTime(),
+ )}`,
const previousRunDuration =
this.connectorsStatus.get(connectorId)?.startDate &&
this.connectorsStatus.get(connectorId)?.lastRunDate
const previousRunDuration =
this.connectorsStatus.get(connectorId)?.startDate &&
this.connectorsStatus.get(connectorId)?.lastRunDate
- ? this.connectorsStatus.get(connectorId).lastRunDate.getTime() -
- this.connectorsStatus.get(connectorId).startDate.getTime()
+ ? this.connectorsStatus.get(connectorId)!.lastRunDate!.getTime() -
+ this.connectorsStatus.get(connectorId)!.startDate!.getTime()
- this.connectorsStatus.get(connectorId).startDate = new Date();
- this.connectorsStatus.get(connectorId).stopDate = new Date(
- this.connectorsStatus.get(connectorId).startDate.getTime() +
+ this.connectorsStatus.get(connectorId)!.startDate = new Date();
+ this.connectorsStatus.get(connectorId)!.stopDate = new Date(
+ this.connectorsStatus.get(connectorId)!.startDate!.getTime() +
- const connectorStatus = cloneObject(
- this.chargingStation.getAutomaticTransactionGeneratorStatuses()
- )[connectorId];
+ const connectorStatus = this.chargingStation.getAutomaticTransactionGeneratorStatuses()
+ ? cloneObject(this.chargingStation.getAutomaticTransactionGeneratorStatuses()!)[connectorId]
+ : undefined;
delete connectorStatus?.startDate;
delete connectorStatus?.lastRunDate;
delete connectorStatus?.stopDate;
delete connectorStatus?.startDate;
delete connectorStatus?.lastRunDate;
delete connectorStatus?.stopDate;
): Promise<StartTransactionResponse | undefined> {
const measureId = 'StartTransaction with ATG';
const beginId = PerformanceStatistics.beginMeasure(measureId);
): Promise<StartTransactionResponse | undefined> {
const measureId = 'StartTransaction with ATG';
const beginId = PerformanceStatistics.beginMeasure(measureId);
// Authorize idTag
const authorizeResponse: AuthorizeResponse =
await this.chargingStation.ocppRequestService.requestHandler<
// Authorize idTag
const authorizeResponse: AuthorizeResponse =
await this.chargingStation.ocppRequestService.requestHandler<
logger.info(startTransactionLogMsg);
// Start transaction
startResponse = await this.chargingStation.ocppRequestService.requestHandler<
logger.info(startTransactionLogMsg);
// Start transaction
startResponse = await this.chargingStation.ocppRequestService.requestHandler<
- reason: StopTransactionReason = StopTransactionReason.LOCAL
- ): Promise<StopTransactionResponse> {
+ reason: StopTransactionReason = StopTransactionReason.LOCAL,
+ ): Promise<StopTransactionResponse | undefined> {
const measureId = 'StopTransaction with ATG';
const beginId = PerformanceStatistics.beginMeasure(measureId);
const measureId = 'StopTransaction with ATG';
const beginId = PerformanceStatistics.beginMeasure(measureId);
if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason);
if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason);
}
} else {
const transactionId = this.chargingStation.getConnectorStatus(connectorId)?.transactionId;
logger.warn(
`${this.logPrefix(connectorId)} stopping a not started transaction${
!isNullOrUndefined(transactionId) ? ` with id ${transactionId?.toString()}` : ''
}
} else {
const transactionId = this.chargingStation.getConnectorStatus(connectorId)?.transactionId;
logger.warn(
`${this.logPrefix(connectorId)} stopping a not started transaction${
!isNullOrUndefined(transactionId) ? ` with id ${transactionId?.toString()}` : ''
private logPrefix = (connectorId?: number): string => {
return logPrefix(
` ${this.chargingStation.stationInfo.chargingStationId} | ATG${
private logPrefix = (connectorId?: number): string => {
return logPrefix(
` ${this.chargingStation.stationInfo.chargingStationId} | ATG${