Remove void before async call.
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 31 Jan 2021 23:53:42 +0000 (00:53 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 31 Jan 2021 23:53:42 +0000 (00:53 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts
src/charging-station/ocpp/OCPPRequestService.ts

index 3f821c8ee822df0620718c42cec23fa78228bf80..929927541d502d7670ce57000c1eb76e821d39dc 100644 (file)
@@ -23,17 +23,17 @@ export default class AutomaticTransactionGenerator {
     }
   }
 
-  public start(): void {
+  public async start(): Promise<void> {
     this.timeToStop = false;
     if (this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours &&
       this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours > 0) {
-      setTimeout(() => {
-        void this.stop();
+      setTimeout(async (): Promise<void> => {
+        await this.stop();
       }, this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours * 3600 * 1000);
     }
     for (const connector in this.chargingStation.connectors) {
       if (Utils.convertToInt(connector) > 0) {
-        void this.startConnector(Utils.convertToInt(connector));
+        await this.startConnector(Utils.convertToInt(connector));
       }
     }
     logger.info(this.logPrefix() + ' ATG started and will stop in ' + Utils.secondsToHHMMSS(this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours * 3600));
index bc7f63f9e43e0a6f8524abab29eb32bb8ed424aa..863d5111210f1181a063ed53c2f46dab374ec133 100644 (file)
@@ -703,7 +703,7 @@ export default class ChargingStation {
         this.automaticTransactionGeneration = new AutomaticTransactionGenerator(this);
       }
       if (this.automaticTransactionGeneration.timeToStop) {
-        this.automaticTransactionGeneration.start();
+        await this.automaticTransactionGeneration.start();
       }
     }
     if (this.getEnableStatistics()) {
@@ -823,7 +823,7 @@ export default class ChargingStation {
   }
 
   private startStationTemplateFileMonitoring(): void {
-    fs.watch(this.stationTemplateFile).on('change', (e) => {
+    fs.watch(this.stationTemplateFile).on('change', async (e): Promise<void> => {
       try {
         logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload');
         // Initialize
@@ -831,7 +831,7 @@ export default class ChargingStation {
         // Stop the ATG
         if (!this.stationInfo.AutomaticTransactionGenerator.enable &&
           this.automaticTransactionGeneration) {
-          this.automaticTransactionGeneration.stop().catch(() => { });
+          await this.automaticTransactionGeneration.stop();
         }
         // Start the ATG
         if (this.stationInfo.AutomaticTransactionGenerator.enable) {
@@ -839,7 +839,7 @@ export default class ChargingStation {
             this.automaticTransactionGeneration = new AutomaticTransactionGenerator(this);
           }
           if (this.automaticTransactionGeneration.timeToStop) {
-            this.automaticTransactionGeneration.start();
+            await this.automaticTransactionGeneration.start();
           }
         }
         // FIXME?: restart heartbeat and WebSocket ping when their interval values have changed
index 0425c58ced76e706a19e9562d7c9866844dbd649..f94f410b948a6ef335ca61cdf01f89adec82c084 100644 (file)
@@ -213,7 +213,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     return Constants.OCPP_CLEAR_CHARGING_PROFILE_RESPONSE_UNKNOWN;
   }
 
-  private handleRequestChangeAvailability(commandPayload: ChangeAvailabilityRequest): ChangeAvailabilityResponse {
+  private async handleRequestChangeAvailability(commandPayload: ChangeAvailabilityRequest): Promise<ChangeAvailabilityResponse> {
     const connectorId: number = commandPayload.connectorId;
     if (!this.chargingStation.getConnector(connectorId)) {
       logger.error(`${this.chargingStation.logPrefix()} Trying to change the availability of a non existing connector Id ${connectorId.toString()}`);
@@ -228,7 +228,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         }
         this.chargingStation.getConnector(Utils.convertToInt(connector)).availability = commandPayload.type;
         if (response === Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED) {
-          void this.chargingStation.ocppRequestService.sendStatusNotification(Utils.convertToInt(connector), chargePointStatus);
+          await this.chargingStation.ocppRequestService.sendStatusNotification(Utils.convertToInt(connector), chargePointStatus);
           this.chargingStation.getConnector(Utils.convertToInt(connector)).status = chargePointStatus;
         }
       }
@@ -239,7 +239,7 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
         return Constants.OCPP_AVAILABILITY_RESPONSE_SCHEDULED;
       }
       this.chargingStation.getConnector(connectorId).availability = commandPayload.type;
-      void this.chargingStation.ocppRequestService.sendStatusNotification(connectorId, chargePointStatus);
+      await this.chargingStation.ocppRequestService.sendStatusNotification(connectorId, chargePointStatus);
       this.chargingStation.getConnector(connectorId).status = chargePointStatus;
       return Constants.OCPP_AVAILABILITY_RESPONSE_ACCEPTED;
     }
index b91102be2460901ae49a8e2101e17525712da28a..e09e15e8e7c324eb64a80a42818a5bb7f6299526 100644 (file)
@@ -118,5 +118,4 @@ export default abstract class OCPPRequestService {
   public abstract sendStopTransaction(transactionId: number, meterStop: number, idTag?: string, reason?: StopTransactionReason): Promise<StopTransactionResponse>;
   public abstract sendMeterValues(connectorId: number, transactionId: number, interval: number, self: OCPPRequestService): Promise<void>;
   public abstract sendError(messageId: string, error: OCPPError, commandName: RequestCommand | IncomingRequestCommand): Promise<unknown>;
-
 }