Skip to content

Commit

Permalink
Adding SupportedEnergyMode. This type contains the supported enegery …
Browse files Browse the repository at this point in the history
…mode and if the mode supports bidi.

Signed-off-by: Sebastian Lukas <[email protected]>
  • Loading branch information
SebaLukas committed Sep 30, 2024
1 parent c32ceec commit c57baaf
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 57 deletions.
9 changes: 3 additions & 6 deletions interfaces/ISO15118_charger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ cmds:
description: Available energy transfer modes supported by the EVSE
type: array
items:
description: The different energy modes supported by the SECC
type: string
$ref: /iso15118_charger#/EnergyTransferMode
description: The different energy modes supported by the SECC
type: object
$ref: /iso15118_charger#/SupportedEnergyMode
minItems: 1
maxItems: 6
sae_j2847_mode:
Expand All @@ -26,9 +26,6 @@ cmds:
debug_mode:
description: Enable/Disable debug mode
type: boolean
bidirectional:
description: Set true if the powersupply (AC or DC) supports bidi mode
type: boolean
set_charging_parameters:
description: >-
At startup, set the the charging parameters at least once. May be updated later on.
Expand Down
4 changes: 2 additions & 2 deletions modules/DummyV2G/main/ISO15118_chargerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ void ISO15118_chargerImpl::ready() {

void ISO15118_chargerImpl::handle_setup(
types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::EnergyTransferMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode, bool& bidirectional) {
std::vector<types::iso15118_charger::SupportedEnergyMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode) {
// your code for cmd setup goes here
}

Expand Down
8 changes: 4 additions & 4 deletions modules/DummyV2G/main/ISO15118_chargerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class ISO15118_chargerImpl : public ISO15118_chargerImplBase {

protected:
// command handler functions (virtual)
virtual void handle_setup(types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::EnergyTransferMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode,
bool& bidirectional) override;
virtual void
handle_setup(types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::SupportedEnergyMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode) override;
virtual void handle_set_charging_parameters(types::iso15118_charger::SetupPhysicalValues& physical_values) override;
virtual void handle_session_setup(std::vector<types::iso15118_charger::PaymentOption>& payment_options,
bool& supported_certificate_service) override;
Expand Down
28 changes: 15 additions & 13 deletions modules/Evse15118D20/charger/ISO15118_chargerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,28 +177,30 @@ iso15118::session::feedback::Callbacks ISO15118_chargerImpl::create_callbacks()

void ISO15118_chargerImpl::handle_setup(
types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::EnergyTransferMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode, bool& bidirectional) {
std::vector<types::iso15118_charger::SupportedEnergyMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode) {

std::scoped_lock lock(GEL);
setup_config.evse_id = evse_id.evse_id; // TODO(SL): Check format for d20

std::vector<iso15118::message_20::ServiceCategory> services;

for (auto mode : supported_energy_transfer_modes) {
if (mode == types::iso15118_charger::EnergyTransferMode::AC_single_phase_core ||
mode == types::iso15118_charger::EnergyTransferMode::AC_three_phase_core) {
services.push_back(iso15118::message_20::ServiceCategory::AC);
if (bidirectional) {
for (const auto& mode : supported_energy_transfer_modes) {
if (mode.energy_transfer_mode == types::iso15118_charger::EnergyTransferMode::AC_single_phase_core ||
mode.energy_transfer_mode == types::iso15118_charger::EnergyTransferMode::AC_three_phase_core) {
if (mode.bidirectional) {
services.push_back(iso15118::message_20::ServiceCategory::AC_BPT);
} else {
services.push_back(iso15118::message_20::ServiceCategory::AC);
}
} else if (mode == types::iso15118_charger::EnergyTransferMode::DC_core ||
mode == types::iso15118_charger::EnergyTransferMode::DC_extended ||
mode == types::iso15118_charger::EnergyTransferMode::DC_combo_core ||
mode == types::iso15118_charger::EnergyTransferMode::DC_unique) {
services.push_back(iso15118::message_20::ServiceCategory::DC);
if (bidirectional) {
} else if (mode.energy_transfer_mode == types::iso15118_charger::EnergyTransferMode::DC_core ||
mode.energy_transfer_mode == types::iso15118_charger::EnergyTransferMode::DC_extended ||
mode.energy_transfer_mode == types::iso15118_charger::EnergyTransferMode::DC_combo_core ||
mode.energy_transfer_mode == types::iso15118_charger::EnergyTransferMode::DC_unique) {
if (mode.bidirectional) {
services.push_back(iso15118::message_20::ServiceCategory::DC_BPT);
} else {
services.push_back(iso15118::message_20::ServiceCategory::DC);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions modules/Evse15118D20/charger/ISO15118_chargerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ISO15118_chargerImpl : public ISO15118_chargerImplBase {

protected:
// command handler functions (virtual)
virtual void handle_setup(types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::EnergyTransferMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode,
bool& bidirectional) override;
virtual void
handle_setup(types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::SupportedEnergyMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode) override;
virtual void handle_set_charging_parameters(types::iso15118_charger::SetupPhysicalValues& physical_values) override;
virtual void handle_session_setup(std::vector<types::iso15118_charger::PaymentOption>& payment_options,
bool& supported_certificate_service) override;
Expand Down
40 changes: 21 additions & 19 deletions modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,29 @@ void EvseManager::ready() {

auto sae_mode = types::iso15118_charger::SaeJ2847BidiMode::None;

bool support_bidi = false;

// Set up energy transfer modes for HLC. For now we only support either DC or AC, not both at the same time.
std::vector<types::iso15118_charger::EnergyTransferMode> transfer_modes;
std::vector<types::iso15118_charger::SupportedEnergyMode> transfer_modes;
if (config.charge_mode == "AC") {
types::iso15118_charger::SetupPhysicalValues setup_physical_values;
setup_physical_values.ac_nominal_voltage = config.ac_nominal_voltage;
r_hlc[0]->call_set_charging_parameters(setup_physical_values);

constexpr auto support_bidi = false;

// FIXME: we cannot change this during run time at the moment. Refactor ISO interface to exclude transfer
// modes from setup
// transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::AC_single_phase_core);
transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::AC_three_phase_core);
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::AC_three_phase_core, support_bidi});

} else if (config.charge_mode == "DC") {
transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::DC_extended);
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::DC_extended, false});

const auto caps = get_powersupply_capabilities();
update_powersupply_capabilities(caps);

support_bidi = caps.bidirectional;
if (caps.bidirectional) {
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::DC_extended, true});
}

// Set present measurements on HLC to sane defaults
types::iso15118_charger::DcEvsePresentVoltageCurrent present_values;
Expand Down Expand Up @@ -533,7 +535,7 @@ void EvseManager::ready() {

r_hlc[0]->call_receipt_is_required(config.ev_receipt_required);

r_hlc[0]->call_setup(evseid, transfer_modes, sae_mode, config.session_logging, support_bidi);
r_hlc[0]->call_setup(evseid, transfer_modes, sae_mode, config.session_logging);

// reset error flags
r_hlc[0]->call_reset_error();
Expand Down Expand Up @@ -1016,12 +1018,13 @@ void EvseManager::setup_fake_DC_mode() {
types::iso15118_charger::EVSEID evseid = {config.evse_id, config.evse_id_din};

// Set up energy transfer modes for HLC. For now we only support either DC or AC, not both at the same time.
std::vector<types::iso15118_charger::EnergyTransferMode> transfer_modes;
std::vector<types::iso15118_charger::SupportedEnergyMode> transfer_modes;
constexpr auto support_bidi = false;

transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::DC_core);
transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::DC_extended);
transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::DC_combo_core);
transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::DC_unique);
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::DC_core, support_bidi});
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::DC_extended, support_bidi});
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::DC_combo_core, support_bidi});
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::DC_unique, support_bidi});

types::iso15118_charger::DcEvsePresentVoltageCurrent present_values;
present_values.evse_present_voltage = 400; // FIXME: set a correct values
Expand All @@ -1041,9 +1044,8 @@ void EvseManager::setup_fake_DC_mode() {
r_hlc[0]->call_update_dc_minimum_limits(evse_min_limits);

constexpr auto sae_mode = types::iso15118_charger::SaeJ2847BidiMode::None;
constexpr auto support_bidi = false;

r_hlc[0]->call_setup(evseid, transfer_modes, sae_mode, config.session_logging, support_bidi);
r_hlc[0]->call_setup(evseid, transfer_modes, sae_mode, config.session_logging);
}

void EvseManager::setup_AC_mode() {
Expand All @@ -1055,21 +1057,21 @@ void EvseManager::setup_AC_mode() {
types::iso15118_charger::EVSEID evseid = {config.evse_id, config.evse_id_din};

// Set up energy transfer modes for HLC. For now we only support either DC or AC, not both at the same time.
std::vector<types::iso15118_charger::EnergyTransferMode> transfer_modes;
std::vector<types::iso15118_charger::SupportedEnergyMode> transfer_modes;
constexpr auto support_bidi = false;

transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::AC_single_phase_core);
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::AC_single_phase_core, support_bidi});

if (get_hw_capabilities().max_phase_count_import == 3) {
transfer_modes.push_back(types::iso15118_charger::EnergyTransferMode::AC_three_phase_core);
transfer_modes.push_back({types::iso15118_charger::EnergyTransferMode::AC_three_phase_core, support_bidi});
}

types::iso15118_charger::SetupPhysicalValues setup_physical_values;

constexpr auto sae_mode = types::iso15118_charger::SaeJ2847BidiMode::None;
constexpr auto support_bidi = false;

if (get_hlc_enabled()) {
r_hlc[0]->call_setup(evseid, transfer_modes, sae_mode, config.session_logging, support_bidi);
r_hlc[0]->call_setup(evseid, transfer_modes, sae_mode, config.session_logging);
}
}

Expand Down
15 changes: 10 additions & 5 deletions modules/EvseV2G/charger/ISO15118_chargerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void ISO15118_chargerImpl::ready() {

void ISO15118_chargerImpl::handle_setup(
types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::EnergyTransferMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode, bool& bidirectional) {
std::vector<types::iso15118_charger::SupportedEnergyMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode) {

uint8_t len = evse_id.evse_id.length();
if (len < iso2_EVSEID_CHARACTER_SIZE) {
Expand All @@ -89,9 +89,14 @@ void ISO15118_chargerImpl::handle_setup(

v2g_ctx->is_dc_charger = true;

for (auto& energy_transfer_mode : supported_energy_transfer_modes) {
for (const auto& mode : supported_energy_transfer_modes) {

switch (energy_transfer_mode) {
if (mode.bidirectional) {
dlog(DLOG_LEVEL_INFO, "Ignoring bidirectional SupportedEnergyTransferMode");
continue;
}

switch (mode.energy_transfer_mode) {
case types::iso15118_charger::EnergyTransferMode::AC_single_phase_core:
energyArray[(energyArrayLen)++] = iso2_EnergyTransferModeType_AC_single_phase_core;
v2g_ctx->is_dc_charger = false;
Expand All @@ -116,7 +121,7 @@ void ISO15118_chargerImpl::handle_setup(
if (energyArrayLen == 0) {

dlog(DLOG_LEVEL_WARNING, "Unable to configure SupportedEnergyTransferMode %s",
types::iso15118_charger::energy_transfer_mode_to_string(energy_transfer_mode).c_str());
types::iso15118_charger::energy_transfer_mode_to_string(mode.energy_transfer_mode).c_str());
}
break;
}
Expand Down
8 changes: 4 additions & 4 deletions modules/EvseV2G/charger/ISO15118_chargerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class ISO15118_chargerImpl : public ISO15118_chargerImplBase {

protected:
// command handler functions (virtual)
virtual void handle_setup(types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::EnergyTransferMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode,
bool& bidirectional) override;
virtual void
handle_setup(types::iso15118_charger::EVSEID& evse_id,
std::vector<types::iso15118_charger::SupportedEnergyMode>& supported_energy_transfer_modes,
types::iso15118_charger::SaeJ2847BidiMode& sae_j2847_mode, bool& debug_mode) override;
virtual void handle_set_charging_parameters(types::iso15118_charger::SetupPhysicalValues& physical_values) override;
virtual void handle_session_setup(std::vector<types::iso15118_charger::PaymentOption>& payment_options,
bool& supported_certificate_service) override;
Expand Down
15 changes: 15 additions & 0 deletions types/iso15118_charger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,21 @@ types:
description: This contains the responder URL
type: string
maxLength: 512
SupportedEnergyMode:
description: Supported energy mode & if the mode supports bidirectional
type: object
additionalProperties: false
required:
- energy_transfer_mode
- bidirectional
properties:
energy_transfer_mode:
description: The energy mode supported by the SECC
ype: string
$ref: /iso15118_charger#/EnergyTransferMode
bidirectional:
description: Set true if the powersupply (AC or DC) supports bidi mode
type: boolean
DisplayParameters:
description: Parameters that may be displayed on the EVSE
type: object
Expand Down

0 comments on commit c57baaf

Please sign in to comment.