From: Jérôme Benoit Date: Wed, 2 Aug 2023 14:44:53 +0000 (+0200) Subject: fix: ensure the latest schedule period within the charging profile X-Git-Tag: v1.2.20~41 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ccfa30bcb2406fa394faf8fb2402a1d409c1a409;p=e-mobility-charging-stations-simulator.git fix: ensure the latest schedule period within the charging profile duration is used Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 1856007e..1dfc0f80 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -826,14 +826,13 @@ const getLimitFromChargingProfiles = ( if ( index === chargingSchedule.chargingSchedulePeriod.length - 1 || (index < chargingSchedule.chargingSchedulePeriod.length - 1 && - chargingSchedule.duration! > - differenceInSeconds( - addSeconds( - chargingSchedule.startSchedule!, - chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod, - ), + differenceInSeconds( + addSeconds( chargingSchedule.startSchedule!, - )) + chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod, + ), + chargingSchedule.startSchedule!, + ) > chargingSchedule.duration!) ) { const result: ChargingProfilesLimit = { limit: previousChargingSchedulePeriod.limit, @@ -862,6 +861,12 @@ export const prepareChargingProfileKind = ( prepareRecurringChargingProfile(chargingProfile, currentDate, logPrefix); break; case ChargingProfileKindType.RELATIVE: + if (!isNullOrUndefined(chargingProfile.chargingSchedule.startSchedule)) { + logger.warn( + `${logPrefix} ${moduleName}.prepareChargingProfileKind: Charging profile id ${chargingProfile.chargingProfileId} has a startSchedule property defined. It will be ignored or set to the connector current transaction start date`, + ); + delete chargingProfile.chargingSchedule.startSchedule; + } connectorStatus?.transactionStarted && (chargingProfile.chargingSchedule.startSchedule = connectorStatus?.transactionStart); break;