From 035742f7433c00edbd0259966e7af6a1cfa2f0a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 4 Apr 2021 22:13:11 +0200 Subject: [PATCH] Linter fixes. 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 | 3 ++- .../ocpp/1.6/OCCP16IncomingRequestService.ts | 6 ++++-- src/charging-station/ocpp/1.6/OCPP16RequestService.ts | 6 ++++-- src/charging-station/ocpp/OCPPRequestService.ts | 3 ++- src/utils/Utils.ts | 8 ++++---- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index 763533ed..bb8d75b3 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -46,7 +46,8 @@ export default class AutomaticTransactionGenerator { const transactionId = this.chargingStation.getConnector(Utils.convertToInt(connector)).transactionId; if (this.chargingStation.getConnector(Utils.convertToInt(connector)).transactionStarted) { logger.info(this.logPrefix(Utils.convertToInt(connector)) + ' ATG OVER. Stop transaction ' + transactionId.toString()); - await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId, this.chargingStation.getTransactionMeterStop(transactionId), this.chargingStation.getTransactionIdTag(transactionId), reason); + await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId, this.chargingStation.getTransactionMeterStop(transactionId), + this.chargingStation.getTransactionIdTag(transactionId), reason); } } this.timeToStop = true; diff --git a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts index 0f7e4dab..5a41771d 100644 --- a/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCCP16IncomingRequestService.ts @@ -62,7 +62,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer } if (this.chargingStation.getConnector(connectorId)?.transactionStarted) { const transactionId = this.chargingStation.getConnector(connectorId).transactionId; - const stopResponse = await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId, this.chargingStation.getTransactionMeterStop(transactionId), this.chargingStation.getTransactionIdTag(transactionId), OCPP16StopTransactionReason.UNLOCK_COMMAND); + const stopResponse = await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId, this.chargingStation.getTransactionMeterStop(transactionId), + this.chargingStation.getTransactionIdTag(transactionId), OCPP16StopTransactionReason.UNLOCK_COMMAND); if (stopResponse.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) { return Constants.OCPP_RESPONSE_UNLOCKED; } @@ -295,7 +296,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer if (Utils.convertToInt(connector) > 0 && this.chargingStation.getConnector(Utils.convertToInt(connector))?.transactionId === transactionId) { await this.chargingStation.ocppRequestService.sendStatusNotification(Utils.convertToInt(connector), OCPP16ChargePointStatus.FINISHING); this.chargingStation.getConnector(Utils.convertToInt(connector)).status = OCPP16ChargePointStatus.FINISHING; - await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId, this.chargingStation.getTransactionMeterStop(transactionId), this.chargingStation.getTransactionIdTag(transactionId)); + await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId, this.chargingStation.getTransactionMeterStop(transactionId), + this.chargingStation.getTransactionIdTag(transactionId)); return Constants.OCPP_RESPONSE_ACCEPTED; } } diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 7470b342..4e828453 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -45,7 +45,8 @@ export default class OCPP16RequestService extends OCPPRequestService { } } - public async sendStatusNotification(connectorId: number, status: OCPP16ChargePointStatus, errorCode: OCPP16ChargePointErrorCode = OCPP16ChargePointErrorCode.NO_ERROR): Promise { + public async sendStatusNotification(connectorId: number, status: OCPP16ChargePointStatus, + errorCode: OCPP16ChargePointErrorCode = OCPP16ChargePointErrorCode.NO_ERROR): Promise { try { const payload: StatusNotificationRequest = { connectorId, @@ -83,7 +84,8 @@ export default class OCPP16RequestService extends OCPPRequestService { } } - public async sendStopTransaction(transactionId: number, meterStop: number, idTag?: string, reason: OCPP16StopTransactionReason = OCPP16StopTransactionReason.NONE): Promise { + public async sendStopTransaction(transactionId: number, meterStop: number, idTag?: string, + reason: OCPP16StopTransactionReason = OCPP16StopTransactionReason.NONE): Promise { try { const payload: StopTransactionRequest = { transactionId, diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 2c2a8a5b..290316cc 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -21,7 +21,8 @@ export default abstract class OCPPRequestService { this.ocppResponseService = ocppResponseService; } - public async sendMessage(messageId: string, commandParams: any, messageType: MessageType = MessageType.CALL_RESULT_MESSAGE, commandName: RequestCommand | IncomingRequestCommand): Promise { + public async sendMessage(messageId: string, commandParams: any, messageType: MessageType = MessageType.CALL_RESULT_MESSAGE, + commandName: RequestCommand | IncomingRequestCommand): Promise { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; // Send a message through wsConnection diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 1a0d7b70..e4bc6a7b 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -104,14 +104,14 @@ export default class Utils { return Math.floor(Math.random() * max + 1); } - static roundTo(number: number, scale: number): number { + static roundTo(numberValue: number, scale: number): number { const roundPower = Math.pow(10, scale); - return Math.round(number * roundPower) / roundPower; + return Math.round(numberValue * roundPower) / roundPower; } - static truncTo(number: number, scale: number): number { + static truncTo(numberValue: number, scale: number): number { const truncPower = Math.pow(10, scale); - return Math.trunc(number * truncPower) / truncPower; + return Math.trunc(numberValue * truncPower) / truncPower; } static getRandomFloatRounded(max: number, min = 0, scale = 2): number { -- 2.34.1