From d20f43b5644d96a9a166cd2ec5ddf87945ea45d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 25 Mar 2022 12:27:47 +0100 Subject: [PATCH] Only compute amperage limitation when needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 3051abb7..40e2c1b1 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -236,9 +236,9 @@ export default class ChargingStation { } public getConnectorMaximumAvailablePower(connectorId: number): number { - let amperageLimitationPowerLimit: number; + let connectorAmperageLimitationPowerLimit: number; if (this.getAmperageLimitation() < this.stationInfo.maximumAmperage) { - amperageLimitationPowerLimit = + const amperageLimitationPowerLimit = this.getCurrentOutType() === CurrentType.AC ? ACElectricUtils.powerTotal( this.getNumberOfPhases(), @@ -246,12 +246,12 @@ export default class ChargingStation { this.getAmperageLimitation() * this.getNumberOfConnectors() ) : DCElectricUtils.power(this.getVoltageOut(), this.getAmperageLimitation()); + connectorAmperageLimitationPowerLimit = + amperageLimitationPowerLimit / this.stationInfo.powerDivider; } const connectorMaximumPower = ((this.stationInfo['maxPower'] as number) ?? this.stationInfo.maximumPower) / this.stationInfo.powerDivider; - const connectorAmperageLimitationPowerLimit = - amperageLimitationPowerLimit / this.stationInfo.powerDivider; const connectorChargingProfilePowerLimit = this.getChargingProfilePowerLimit(connectorId); return Math.min( isNaN(connectorMaximumPower) ? Infinity : connectorMaximumPower, -- 2.34.1