From e268356bed036cbf1485fc35f60ebf9f511636b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 1 Feb 2021 00:53:42 +0100 Subject: [PATCH] Remove void before async call. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/AutomaticTransactionGenerator.ts | 8 ++++---- src/charging-station/ChargingStation.ts | 8 ++++---- .../ocpp/1.6/OCCP16IncomingRequestService.ts | 6 +++--- src/charging-station/ocpp/OCPPRequestService.ts | 1 - 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 3f821c8e..92992754 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -23,17 +23,17 @@ export default class AutomaticTransactionGenerator { } } - public start(): void { + public async start(): Promise { this.timeToStop = false; if (this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours && this.chargingStation.stationInfo.AutomaticTransactionGenerator.stopAfterHours > 0) { - setTimeout(() => { - void this.stop(); + setTimeout(async (): Promise => { + 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)); diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index bc7f63f9..863d5111 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -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 => { 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 diff --git a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts index 0425c58c..f94f410b 100644 --- a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts @@ -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 { 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; } diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index b91102be..e09e15e8 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -118,5 +118,4 @@ export default abstract class OCPPRequestService { public abstract sendStopTransaction(transactionId: number, meterStop: number, idTag?: string, reason?: StopTransactionReason): Promise; public abstract sendMeterValues(connectorId: number, transactionId: number, interval: number, self: OCPPRequestService): Promise; public abstract sendError(messageId: string, error: OCPPError, commandName: RequestCommand | IncomingRequestCommand): Promise; - } -- 2.34.1