Permit to disable persistent configuration storage.
[e-mobility-charging-stations-simulator.git] / src / charging-station / AutomaticTransactionGenerator.ts
index a8bd79ac06d846ac6d3f0313a25de57c234856a3..b806d5cf0044dfbd8ea473c7c52267412d39ce49 100644 (file)
@@ -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(