From 7b872eaa46d0131c6487d52a8ce9886663e99eae Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 24 Mar 2022 11:03:52 +0100 Subject: [PATCH] Charging profiles: Fix timestamp value unit handling 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 79fc4f43..02c7a0e0 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -247,12 +247,12 @@ export default class ChargingStation { ) : DCElectricUtils.power(this.getVoltageOut(), this.getAmperageLimitation()); } - const connectorChargingProfilePowerLimit = this.getChargingProfilePowerLimit(connectorId); 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, isNaN(connectorAmperageLimitationPowerLimit) @@ -731,7 +731,7 @@ export default class ChargingStation { timestamp >= chargingProfile.chargingSchedule?.startSchedule.getTime() && timestamp < chargingProfile.chargingSchedule?.startSchedule.getTime() + - chargingProfile.chargingSchedule.duration && + chargingProfile.chargingSchedule.duration * 1000 && chargingProfile?.stackLevel === Math.max(...chargingProfiles.map((cp) => cp?.stackLevel)) ); if (!Utils.isEmptyArray(chargingProfiles)) { @@ -742,12 +742,13 @@ export default class ChargingStation { (chargingSchedulePeriod, index) => { timestamp >= chargingProfile.chargingSchedule.startSchedule.getTime() + - chargingSchedulePeriod.startPeriod && + chargingSchedulePeriod.startPeriod * 1000 && chargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1] && timestamp < chargingProfile.chargingSchedule.startSchedule.getTime() + chargingProfile.chargingSchedule.chargingSchedulePeriod[index + 1] - ?.startPeriod; + ?.startPeriod * + 1000; } ); if (!Utils.isEmptyArray(chargingSchedulePeriods)) { -- 2.34.1