Skip to content

Commit

Permalink
Add return value if profile was transformed
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Suess <[email protected]>
  • Loading branch information
Matthias-NIDEC committed Dec 12, 2024
1 parent c234ccc commit 66ae654
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/ocpp/v16/ocpp_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct ChargingSchedule {
std::optional<int32_t> duration;
std::optional<ocpp::DateTime> startSchedule;
std::optional<float> minChargingRate;
bool profileTransformed = false; // indicates that a profile was transformed from chargingRateUnit
};
/// \brief Conversion from a given ChargingSchedule \p k to a given json object \p j
void to_json(json& j, const ChargingSchedule& k);
Expand Down
1 change: 1 addition & 0 deletions include/ocpp/v16/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ struct EnhancedChargingSchedule {
std::optional<int32_t> duration;
std::optional<ocpp::DateTime> startSchedule;
std::optional<float> minChargingRate;
bool profileTransformed = false; // indicates that a profile was transformed from chargingRateUnit
};

/// \brief Conversion from a given EnhancedChargingSchedule \p k to a given json object \p j
Expand Down
5 changes: 4 additions & 1 deletion lib/ocpp/v16/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ EnhancedChargingSchedule calculate_composite_schedule(std::vector<period_entry_t
(in_charging_rate_unit) ? in_charging_rate_unit.value() : ChargingRateUnit::A;
const auto now = floor_seconds(in_now);
const auto end = floor_seconds(in_end);
EnhancedChargingSchedule composite{selected_unit, {}, elapsed_seconds(end, now), now, std::nullopt};
EnhancedChargingSchedule composite{selected_unit, {}, elapsed_seconds(end, now), now, std::nullopt, false};

// sort the combined_schedules in stack priority order
struct {
Expand Down Expand Up @@ -447,6 +447,9 @@ EnhancedChargingSchedule calculate_composite_schedule(std::vector<period_entry_t
// there is a schedule to use
const auto [limit, number_phases] =
convert_limit(chosen, selected_unit, default_number_phases, supply_voltage);
if (selected_unit != chosen->charging_rate_unit) {
composite.profileTransformed = true;
}
composite.chargingSchedulePeriod.push_back(
{elapsed_seconds(current, now), limit, number_phases, chosen->stack_level});
if (chosen->end < next_earliest) {
Expand Down
1 change: 1 addition & 0 deletions lib/ocpp/v16/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ ChargingSchedule SmartChargingHandler::calculate_composite_schedule(
composite_schedule.duration = enhanced_composite_schedule.duration;
composite_schedule.startSchedule = enhanced_composite_schedule.startSchedule;
composite_schedule.minChargingRate = enhanced_composite_schedule.minChargingRate;
composite_schedule.profileTransformed = enhanced_composite_schedule.profileTransformed;
for (const auto enhanced_period : enhanced_composite_schedule.chargingSchedulePeriod) {
ChargingSchedulePeriod period;
period.startPeriod = enhanced_period.startPeriod;
Expand Down

0 comments on commit 66ae654

Please sign in to comment.