Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/notify ev charging needs #93

Merged
merged 12 commits into from
Mar 17, 2025
Next Next commit
Added base params for notify_ev_charging_needs
Signed-off-by: AssemblyJohn <ioan.bogdann@gmail.com>
  • Loading branch information
AssemblyJohn committed Mar 17, 2025
commit 6aa052e224f4d8a394fc41dd2d3b3e390a25b5cc
1 change: 1 addition & 0 deletions include/iso15118/message/common_types.hpp
Original file line number Diff line number Diff line change
@@ -115,6 +115,7 @@ enum class ChargingSession {

enum class AcConnector {
SinglePhase = 1,
// TODO(ioan): two phase missing?
ThreePhase = 3,
};
enum class DcConnector {
9 changes: 9 additions & 0 deletions include/iso15118/session/feedback.hpp
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@

namespace iso15118::session {

namespace dt = message_20::datatypes;

namespace feedback {

enum class Signal {
@@ -51,6 +53,10 @@ struct Callbacks {
std::function<void(const message_20::Type&)> v2g_message;
std::function<void(const std::string&)> evccid;
std::function<void(const std::string&)> selected_protocol;

std::function<void(const dt::ServiceCategory&, const dt::AcConnector&, const dt::ControlMode&,
const dt::MobilityNeedsMode&)>
notify_ev_charging_needs;
};

} // namespace feedback
@@ -67,6 +73,9 @@ class Feedback {
void evcc_id(const std::string&) const;
void selected_protocol(const std::string&) const;

void notify_ev_charging_needs(const dt::ServiceCategory&, const dt::AcConnector&, const dt::ControlMode&,
const dt::MobilityNeedsMode&) const;

private:
feedback::Callbacks callbacks;
};
15 changes: 14 additions & 1 deletion src/iso15118/d20/state/schedule_exchange.cpp
Original file line number Diff line number Diff line change
@@ -128,13 +128,26 @@ Result ScheduleExchange::feed(Event ev) {

dt::RationalNumber max_charge_power = {0, 0};

const auto selected_energy_service = m_ctx.session.get_selected_services().selected_energy_service;
const auto& selected_services = m_ctx.session.get_selected_services();
const auto selected_energy_service = selected_services.selected_energy_service;

if (selected_energy_service == dt::ServiceCategory::DC or
selected_energy_service == dt::ServiceCategory::DC_BPT) {
max_charge_power = m_ctx.session_config.dc_limits.charge_limits.power.max;
}

// We will pass the raw data to the listener, the
// listener will construct the full required type
dt::AcConnector ac_connector = dt::AcConnector::SinglePhase;
if (std::holds_alternative<dt::AcConnector>(selected_services.selected_connector)) {
ac_connector = std::get<dt::AcConnector>(selected_services.selected_connector);
}

// Send the charging feedback
this->m_ctx.feedback.notify_ev_charging_needs(selected_energy_service, ac_connector,
selected_services.selected_control_mode,
selected_services.selected_mobility_needs_mode);

const auto res = handle_request(*req, m_ctx.session, max_charge_power, dynamic_parameters);

m_ctx.respond(res);
4 changes: 4 additions & 0 deletions src/iso15118/session/feedback.cpp
Original file line number Diff line number Diff line change
@@ -37,4 +37,8 @@ void Feedback::selected_protocol(const std::string& selected_protocol) const {
call_if_available(callbacks.selected_protocol, selected_protocol);
}

void Feedback::notify_ev_charging_needs(const dt::ServiceCategory&, const dt::AcConnector&, const dt::ControlMode&,
const dt::MobilityNeedsMode&) const {
}

} // namespace iso15118::session