From c4ab56bac3353a08b0b7e058e9edfcfc0e629c94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 4 Aug 2023 12:22:37 +0200 Subject: [PATCH] fix: fix gap in schedule periods in composeChargingSchedules() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16ServiceUtils.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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( -- 2.34.1