Skip to content

Commit

Permalink
Added parameter ChargingRateUnit to function to get composite schedul…
Browse files Browse the repository at this point in the history
…es. This allows the user application the specify which unit to use

Signed-off-by: Piet Gömpel <[email protected]>
  • Loading branch information
Pietfried committed Oct 15, 2024
1 parent 846bc5e commit fbd4a4b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
15 changes: 10 additions & 5 deletions include/ocpp/v16/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,22 @@ class ChargePoint {
const std::optional<std::string>& data);

/// \brief Calculates ChargingProfiles configured by the CSMS of all connectors from now until now + given \p
/// duration_s
/// duration_s and the given \p unit
/// \param duration_s
/// \param unit defaults to A
/// \return ChargingSchedules of all connectors
std::map<int32_t, ChargingSchedule> get_all_composite_charging_schedules(const int32_t duration_s);
std::map<int32_t, ChargingSchedule>
get_all_composite_charging_schedules(const int32_t duration_s, const ChargingRateUnit unit = ChargingRateUnit::A);

/// \brief Calculates EnhancedChargingSchedule(s) configured by the CSMS of all connectors from now until now +
/// given \p duration_s . EnhancedChargingSchedules contain EnhancedChargingSchedulePeriod(s) that are enhanced by
/// the stackLevel that was provided for the ChargingProfile
/// given \p duration_s and the given \p unit . EnhancedChargingSchedules contain EnhancedChargingSchedulePeriod(s)
/// that are enhanced by the stackLevel that was provided for the ChargingProfile
/// \param duration_s
/// \param unit defaults to A
/// \return ChargingSchedules of all connectors
std::map<int32_t, EnhancedChargingSchedule> get_all_enhanced_composite_charging_schedules(const int32_t duration_s);
std::map<int32_t, EnhancedChargingSchedule>
get_all_enhanced_composite_charging_schedules(const int32_t duration_s,
const ChargingRateUnit unit = ChargingRateUnit::A);

/// \brief Stores the given \p powermeter values for the given \p connector . This function can be called when a new
/// meter value is present.
Expand Down
17 changes: 11 additions & 6 deletions include/ocpp/v16/charge_point_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,22 @@ class ChargePointImpl : ocpp::ChargingStationBase {
const std::optional<std::string>& data);

/// \brief Calculates ChargingProfiles configured by the CSMS of all connectors from now until now + given \p
/// duration_s
/// duration_s and the given \p unit
/// \param duration_s
/// \param unit defaults to A
/// \return ChargingSchedules of all connectors
std::map<int32_t, ChargingSchedule> get_all_composite_charging_schedules(const int32_t duration_s);
std::map<int32_t, ChargingSchedule>
get_all_composite_charging_schedules(const int32_t duration_s, const ChargingRateUnit unit = ChargingRateUnit::A);

/// \brief Calculates EnhancedChargingSchedule(s) configured by the CSMS of all connectors from now until now +
/// given \p duration_s . EnhancedChargingSchedules contain EnhancedChargingSchedulePeriod(s) that are enhanced by
/// the stackLevel that was provided for the ChargingProfile
/// given \p duration_s and the given \p unit . EnhancedChargingSchedules contain EnhancedChargingSchedulePeriod(s)
/// that are enhanced by the stackLevel that was provided for the ChargingProfile
/// \param duration_s
/// \return ChargingSchedules of all connectors
std::map<int32_t, EnhancedChargingSchedule> get_all_enhanced_composite_charging_schedules(const int32_t duration_s);
/// \param unit
/// defaults to A \return ChargingSchedules of all connectors
std::map<int32_t, EnhancedChargingSchedule>
get_all_enhanced_composite_charging_schedules(const int32_t duration_s,
const ChargingRateUnit unit = ChargingRateUnit::A);

/// \brief Stores the given \p powermeter values for the given \p connector . This function can be called when a new
/// meter value is present.
Expand Down
9 changes: 5 additions & 4 deletions lib/ocpp/v16/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ std::optional<DataTransferResponse> ChargePoint::data_transfer(const CiString<25
return this->charge_point->data_transfer(vendorId, messageId, data);
}

std::map<int32_t, ChargingSchedule> ChargePoint::get_all_composite_charging_schedules(const int32_t duration_s) {
return this->charge_point->get_all_composite_charging_schedules(duration_s);
std::map<int32_t, ChargingSchedule> ChargePoint::get_all_composite_charging_schedules(const int32_t duration_s,
const ChargingRateUnit unit) {
return this->charge_point->get_all_composite_charging_schedules(duration_s, unit);
}

std::map<int32_t, EnhancedChargingSchedule>
ChargePoint::get_all_enhanced_composite_charging_schedules(const int32_t duration_s) {
return this->charge_point->get_all_enhanced_composite_charging_schedules(duration_s);
ChargePoint::get_all_enhanced_composite_charging_schedules(const int32_t duration_s, const ChargingRateUnit unit) {
return this->charge_point->get_all_enhanced_composite_charging_schedules(duration_s, unit);
}

void ChargePoint::on_meter_values(int32_t connector, const Measurement& measurement) {
Expand Down
9 changes: 5 additions & 4 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3334,7 +3334,8 @@ IdTagInfo ChargePointImpl::authorize_id_token(CiString<20> idTag, const bool aut
return id_tag_info;
}

std::map<int32_t, ChargingSchedule> ChargePointImpl::get_all_composite_charging_schedules(const int32_t duration_s) {
std::map<int32_t, ChargingSchedule> ChargePointImpl::get_all_composite_charging_schedules(const int32_t duration_s,
const ChargingRateUnit unit) {

std::map<int32_t, ChargingSchedule> charging_schedules;

Expand All @@ -3346,15 +3347,15 @@ std::map<int32_t, ChargingSchedule> ChargePointImpl::get_all_composite_charging_
const auto valid_profiles =
this->smart_charging_handler->get_valid_profiles(start_time, end_time, connector_id);
const auto composite_schedule = this->smart_charging_handler->calculate_composite_schedule(
valid_profiles, start_time, end_time, connector_id, ChargingRateUnit::A);
valid_profiles, start_time, end_time, connector_id, unit);
charging_schedules[connector_id] = composite_schedule;
}

return charging_schedules;
}

std::map<int32_t, EnhancedChargingSchedule>
ChargePointImpl::get_all_enhanced_composite_charging_schedules(const int32_t duration_s) {
ChargePointImpl::get_all_enhanced_composite_charging_schedules(const int32_t duration_s, const ChargingRateUnit unit) {

std::map<int32_t, EnhancedChargingSchedule> charging_schedules;

Expand All @@ -3366,7 +3367,7 @@ ChargePointImpl::get_all_enhanced_composite_charging_schedules(const int32_t dur
const auto valid_profiles =
this->smart_charging_handler->get_valid_profiles(start_time, end_time, connector_id);
const auto composite_schedule = this->smart_charging_handler->calculate_enhanced_composite_schedule(
valid_profiles, start_time, end_time, connector_id, ChargingRateUnit::A);
valid_profiles, start_time, end_time, connector_id, unit);
charging_schedules[connector_id] = composite_schedule;
}

Expand Down

0 comments on commit fbd4a4b

Please sign in to comment.