@@ -323,6 +323,80 @@ TEST_SUITE("Get composite schedule - multiple OCPP profiles")
323323 CHECK_EQ (schedule.chargingSchedulePeriod [4 ].numberPhases .value (), 1 );
324324 }
325325
326+ TEST_CASE (" 1 profile (relative) + local limitations - charging" )
327+ {
328+ SmartChargingManager smartcharging_mgr (
329+ stack_config, ocpp_config, database, event_handler, timer_pool, worker_pool, connectors, msgs_converter, msg_dispatcher);
330+ clearAllProfiles (smartcharging_mgr);
331+
332+ DateTime now = DateTime::now ();
333+
334+ Connector* connector = connectors.getConnector (1 );
335+ connector->transaction_id = 1 ;
336+ connector->transaction_start = DateTime (now.timestamp () - 100 );
337+
338+ ChargingProfile profile1;
339+ profile1.chargingProfileId = 1 ;
340+ profile1.stackLevel = 5 ;
341+ profile1.chargingProfilePurpose = ChargingProfilePurposeType::TxDefaultProfile;
342+ profile1.chargingProfileKind = ChargingProfileKindType::Relative;
343+
344+ ChargingSchedulePeriod charging_period;
345+ charging_period.limit = 16 .f ;
346+ charging_period.startPeriod = 0 ;
347+ charging_period.numberPhases = 1 ;
348+ profile1.chargingSchedule .chargingSchedulePeriod .push_back (charging_period);
349+ charging_period.limit = 10 .f ;
350+ charging_period.startPeriod = 1000 ;
351+ charging_period.numberPhases = 2 ;
352+ profile1.chargingSchedule .chargingSchedulePeriod .push_back (charging_period);
353+ charging_period.limit = 32 .f ;
354+ charging_period.startPeriod = 1700 ;
355+ charging_period.numberPhases = 3 ;
356+ profile1.chargingSchedule .chargingSchedulePeriod .push_back (charging_period);
357+ profile1.chargingSchedule .chargingRateUnit = ChargingRateUnitType::A;
358+ profile1.chargingSchedule .startSchedule = DateTime (now.timestamp () + 300 );
359+ CHECK (installProfile (1 , profile1, smartcharging_mgr));
360+
361+ ChargingSchedule& local_schedule = event_handler.schedule ;
362+ local_schedule.chargingSchedulePeriod .clear ();
363+ charging_period.limit = 8 .f ;
364+ charging_period.startPeriod = 0 ;
365+ charging_period.numberPhases = 2 ;
366+ local_schedule.chargingSchedulePeriod .push_back (charging_period);
367+ charging_period.limit = 20 .f ;
368+ charging_period.startPeriod = 200 ;
369+ charging_period.numberPhases = 3 ;
370+ local_schedule.chargingSchedulePeriod .push_back (charging_period);
371+ charging_period.limit = 18 .f ;
372+ charging_period.startPeriod = 1400 ;
373+ charging_period.numberPhases = 3 ;
374+ local_schedule.chargingSchedulePeriod .push_back (charging_period);
375+ local_schedule.chargingRateUnit = ChargingRateUnitType::A;
376+
377+ ChargingSchedule schedule;
378+ CHECK (getCompositeSchedule (1 , 3600 , ChargingRateUnitType::A, schedule, smartcharging_mgr));
379+
380+ CHECK_EQ (schedule.duration , 3600 );
381+ CHECK_EQ (schedule.chargingRateUnit , ChargingRateUnitType::A);
382+ CHECK_GE (schedule.startSchedule .value (), now);
383+ CHECK_LE (schedule.startSchedule .value (), DateTime (now.timestamp () + 1 ));
384+ CHECK_EQ (schedule.chargingSchedulePeriod .size (), 4 );
385+
386+ CHECK_EQ (schedule.chargingSchedulePeriod [0 ].startPeriod , 0 );
387+ CHECK_EQ (schedule.chargingSchedulePeriod [0 ].limit , 8 .f );
388+ CHECK_EQ (schedule.chargingSchedulePeriod [0 ].numberPhases .value (), 2 );
389+ CHECK_EQ (schedule.chargingSchedulePeriod [1 ].startPeriod , 200 );
390+ CHECK_EQ (schedule.chargingSchedulePeriod [1 ].limit , 16 .f );
391+ CHECK_EQ (schedule.chargingSchedulePeriod [1 ].numberPhases .value (), 1 );
392+ CHECK_EQ (schedule.chargingSchedulePeriod [2 ].startPeriod , 900 );
393+ CHECK_EQ (schedule.chargingSchedulePeriod [2 ].limit , 10 .f );
394+ CHECK_EQ (schedule.chargingSchedulePeriod [2 ].numberPhases .value (), 2 );
395+ CHECK_EQ (schedule.chargingSchedulePeriod [3 ].startPeriod , 1600 );
396+ CHECK_EQ (schedule.chargingSchedulePeriod [3 ].limit , 18 .f );
397+ CHECK_EQ (schedule.chargingSchedulePeriod [3 ].numberPhases .value (), 3 );
398+ }
399+
326400 TEST_CASE (" Cleanup" )
327401 {
328402 CHECK (database.close ());
0 commit comments