From: Jérôme Benoit Date: Fri, 4 Aug 2023 10:22:37 +0000 (+0200) Subject: fix: fix gap in schedule periods in composeChargingSchedules() X-Git-Tag: v1.2.20~20 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c4ab56bac3353a08b0b7e058e9edfcfc0e629c94;p=e-mobility-charging-stations-simulator.git fix: fix gap in schedule periods in composeChargingSchedules() Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index af2f6d03..537449df 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -1046,7 +1046,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { }; }), ...compositeChargingScheduleLower!.chargingSchedulePeriod - .filter((schedulePeriod) => { + .filter((schedulePeriod, index) => { if ( higherFirst && isWithinInterval( @@ -1062,6 +1062,33 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { ) { return false; } + if ( + higherFirst && + index < compositeChargingScheduleLower!.chargingSchedulePeriod.length - 1 && + !isWithinInterval( + addSeconds( + compositeChargingScheduleLowerInterval.start, + schedulePeriod.startPeriod, + ), + { + start: compositeChargingScheduleLowerInterval.start, + end: compositeChargingScheduleHigherInterval.end, + }, + ) && + isWithinInterval( + addSeconds( + compositeChargingScheduleLowerInterval.start, + compositeChargingScheduleLower!.chargingSchedulePeriod[index + 1].startPeriod, + ), + { + start: compositeChargingScheduleLowerInterval.start, + end: compositeChargingScheduleHigherInterval.end, + }, + ) + ) { + schedulePeriod.startPeriod = 0; + return false; + } if ( !higherFirst && isWithinInterval(