@@ -252,6 +252,9 @@ std::unique_ptr<ChargingSchedule> SmartChargingConnector::getCompositeSchedule(i
252252 Timestamp periodBegin = Timestamp (startSchedule);
253253 Timestamp periodStop = Timestamp (startSchedule);
254254
255+ // remember last effective limit we actually *emitted*
256+ ChargeRate lastLimit;
257+
255258 while (periodBegin - startSchedule < duration && periods.size () < MO_ChargingScheduleMaxPeriods) {
256259
257260 // calculate limit
@@ -267,11 +270,17 @@ std::unique_ptr<ChargingSchedule> SmartChargingConnector::getCompositeSchedule(i
267270 }
268271 }
269272
270- periods.emplace_back ();
271- float limit_opt = unit == ChargingRateUnitType_Optional::Watt ? limit.power : limit.current ;
272- periods.back ().limit = limit_opt != std::numeric_limits<float >::max () ? limit_opt : -1 .f ,
273- periods.back ().numberPhases = limit.nphases != std::numeric_limits<int >::max () ? limit.nphases : -1 ;
274- periods.back ().startPeriod = periodBegin - startSchedule;
273+ // coalesce: only push when the effective limit actually *changes*
274+ if (periods.empty () || limit != lastLimit) {
275+ periods.emplace_back ();
276+ float limit_opt = unit == ChargingRateUnitType_Optional::Watt ? limit.power : limit.current ;
277+ // Per OCPP 1.6 schema, limit must be > 0. Use a sane fallback (e.g. 32A or 22kW-equivalent) instead of -1 when undefined.
278+ // For numberPhases, the field is optional; if unknown we can default to 3 (typical three-phase) instead of -1.
279+ periods.back ().limit = limit_opt != std::numeric_limits<float >::max () ? limit_opt : 32 .f ;
280+ periods.back ().numberPhases = limit.nphases != std::numeric_limits<int >::max () ? limit.nphases : 3 ;
281+ periods.back ().startPeriod = periodBegin - startSchedule;
282+ lastLimit = limit;
283+ }
275284
276285 periodBegin = periodStop;
277286 }
@@ -764,6 +773,8 @@ bool SmartChargingServiceUtils::removeProfile(std::shared_ptr<FilesystemAdapter>
764773 return false ;
765774 }
766775
776+ MO_DBG_DEBUG (" Removing chargingProfile for connector %d, purpose %d, stack level %d, file %s" , connectorId, (int ) purpose, (int ) stackLevel, fn);
777+
767778 return filesystem->remove (fn);
768779}
769780
0 commit comments