X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2FAutomaticTransactionGenerator.ts;h=b806d5cf0044dfbd8ea473c7c52267412d39ce49;hb=ccb1d6e97cc0248cd96a9505cf5e8f037d66984c;hp=a8bd79ac06d846ac6d3f0313a25de57c234856a3;hpb=794aea9d3e6b713d55bf5adb06faa211206cfa77;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index a8bd79ac..b806d5cf 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -274,14 +274,14 @@ export default class AutomaticTransactionGenerator { let startResponse: StartTransactionResponse; if (this.chargingStation.hasAuthorizedTags()) { const idTag = this.chargingStation.getRandomIdTag(); - if (this.chargingStation.getAutomaticTransactionGeneratorRequireAuthorize()) { + if (this.getRequireAuthorize()) { this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag; // Authorize idTag const authorizeResponse: AuthorizeResponse = - await this.chargingStation.ocppRequestService.sendMessageHandler< + await this.chargingStation.ocppRequestService.requestHandler< AuthorizeRequest, AuthorizeResponse - >(RequestCommand.AUTHORIZE, { + >(this.chargingStation, RequestCommand.AUTHORIZE, { idTag, }); this.connectorsStatus.get(connectorId).authorizeRequests++; @@ -289,10 +289,10 @@ export default class AutomaticTransactionGenerator { this.connectorsStatus.get(connectorId).acceptedAuthorizeRequests++; logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag); // Start transaction - startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler< + startResponse = await this.chargingStation.ocppRequestService.requestHandler< StartTransactionRequest, StartTransactionResponse - >(RequestCommand.START_TRANSACTION, { + >(this.chargingStation, RequestCommand.START_TRANSACTION, { connectorId, idTag, }); @@ -305,10 +305,10 @@ export default class AutomaticTransactionGenerator { } logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag); // Start transaction - startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler< + startResponse = await this.chargingStation.ocppRequestService.requestHandler< StartTransactionRequest, StartTransactionResponse - >(RequestCommand.START_TRANSACTION, { + >(this.chargingStation, RequestCommand.START_TRANSACTION, { connectorId, idTag, }); @@ -316,10 +316,10 @@ export default class AutomaticTransactionGenerator { return startResponse; } logger.info(this.logPrefix(connectorId) + ' start transaction without an idTag'); - startResponse = await this.chargingStation.ocppRequestService.sendMessageHandler< + startResponse = await this.chargingStation.ocppRequestService.requestHandler< StartTransactionRequest, StartTransactionResponse - >(RequestCommand.START_TRANSACTION, { connectorId }); + >(this.chargingStation, RequestCommand.START_TRANSACTION, { connectorId }); PerformanceStatistics.endMeasure(measureId, beginId); return startResponse; } @@ -345,19 +345,19 @@ export default class AutomaticTransactionGenerator { connectorId, this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId) ); - await this.chargingStation.ocppRequestService.sendMessageHandler< + await this.chargingStation.ocppRequestService.requestHandler< MeterValuesRequest, MeterValuesResponse - >(RequestCommand.METER_VALUES, { + >(this.chargingStation, RequestCommand.METER_VALUES, { connectorId, transactionId, meterValue: transactionEndMeterValue, }); } - stopResponse = await this.chargingStation.ocppRequestService.sendMessageHandler< + stopResponse = await this.chargingStation.ocppRequestService.requestHandler< StopTransactionRequest, StopTransactionResponse - >(RequestCommand.STOP_TRANSACTION, { + >(this.chargingStation, RequestCommand.STOP_TRANSACTION, { transactionId, meterStop: this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId), idTag: this.chargingStation.getTransactionIdTag(transactionId), @@ -375,6 +375,12 @@ export default class AutomaticTransactionGenerator { return stopResponse; } + private getRequireAuthorize(): boolean { + return ( + this.chargingStation.stationInfo?.AutomaticTransactionGenerator?.requireAuthorize ?? true + ); + } + private logPrefix(connectorId?: number): string { if (connectorId) { return Utils.logPrefix(