Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions interfaces/ISO15118_ev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ cmds:
by the EVCC
type: string
$ref: /iso15118#/EnergyTransferMode
SelectedPaymentOption:
description: Selected payment option
type: object
$ref: /iso15118#/SelectedPaymentOption
DepartureTime:
description: >-
The time when the EVCC wants to leave the charging station (in seconds)
Expand Down
1 change: 1 addition & 0 deletions modules/EV/EvManager/EvManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
int soc;
bool keep_cross_boot_plugin_state;
std::string plugin_commands;
bool force_payment_option;

Check warning on line 55 in modules/EV/EvManager/EvManager.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EV/EvManager/EvManager.hpp#L55

struct member 'Conf::force_payment_option' is never used.
};

class EvManager : public Everest::ModuleBase {
Expand Down
36 changes: 29 additions & 7 deletions modules/EV/EvManager/main/car_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,22 +296,44 @@ bool CarSimulation::iso_dc_power_on(const CmdArguments& arguments) {

bool CarSimulation::iso_start_v2g_session(const CmdArguments& arguments, bool three_phases) {
const auto& energy_mode = arguments[0];
const auto& departure_time = std::stoi(arguments[1]);
const auto& e_amount = std::stoi(arguments[2]);
const auto& payment_option = arguments[1];
const auto& departure_time = std::stoi(arguments[2]);
const auto& e_amount = std::stoi(arguments[3]);

const auto selected_payment_option = [payment_option,
this](bool auto_payment_option) -> types::iso15118::SelectedPaymentOption {
if (auto_payment_option) {
return types::iso15118::SelectedPaymentOption{};
}
auto selected_payment_option =
types::iso15118::SelectedPaymentOption{std::nullopt, config.force_payment_option};

if (payment_option == "externalpayment") {
selected_payment_option.payment_option = types::iso15118::PaymentOption::ExternalPayment;
} else if (payment_option == "contract") {
selected_payment_option.payment_option = types::iso15118::PaymentOption::Contract;
} else {
EVLOG_warning << "Go back to auto payment because payment_option was not recognized";
selected_payment_option.enforce_payment_option.reset();
}

return selected_payment_option;
}(payment_option == "auto");

if (energy_mode == constants::AC) {
sim_data.energy_mode = EnergyMode::AC;
if (not three_phases) {
r_ev[0]->call_start_charging(types::iso15118::EnergyTransferMode::AC_single_phase_core, departure_time,
e_amount);
r_ev[0]->call_start_charging(types::iso15118::EnergyTransferMode::AC_single_phase_core,
selected_payment_option, departure_time, e_amount);
charge_mode = ChargeMode::AC;
} else {
r_ev[0]->call_start_charging(types::iso15118::EnergyTransferMode::AC_three_phase_core, departure_time,
e_amount);
r_ev[0]->call_start_charging(types::iso15118::EnergyTransferMode::AC_three_phase_core,
selected_payment_option, departure_time, e_amount);
charge_mode = ChargeMode::ACThreePhase;
}
} else if (energy_mode == constants::DC) {
r_ev[0]->call_start_charging(types::iso15118::EnergyTransferMode::DC_extended, departure_time, e_amount);
r_ev[0]->call_start_charging(types::iso15118::EnergyTransferMode::DC_extended, selected_payment_option,
departure_time, e_amount);
sim_data.energy_mode = EnergyMode::DC;
charge_mode = ChargeMode::DC;
} else {
Expand Down
20 changes: 17 additions & 3 deletions modules/EV/EvManager/main/car_simulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,29 @@ void car_simulatorImpl::register_all_commands() {
return this->car_simulation->iso_dc_power_on(arguments);
});
command_registry->register_command("iso_start_v2g_session", 1, [this](const CmdArguments& arguments) {
constexpr auto payment_option = "auto";
EVLOG_debug << "Using default payment_options, departure time and eamount";
CmdArguments args{arguments[0], payment_option, std::to_string(mod->config.departure_time),
std::to_string(mod->config.e_amount)};
return this->car_simulation->iso_start_v2g_session(args, mod->config.three_phases);
});
command_registry->register_command("iso_start_v2g_session", 2, [this](const CmdArguments& arguments) {
EVLOG_debug << "Using default departure time and eamount";
CmdArguments args{arguments[0], std::to_string(mod->config.departure_time),
CmdArguments args{arguments[0], arguments[1], std::to_string(mod->config.departure_time),
std::to_string(mod->config.e_amount)};
return this->car_simulation->iso_start_v2g_session(args, mod->config.three_phases);
});
command_registry->register_command("iso_start_v2g_session", 3, [this](const CmdArguments& arguments) {
constexpr auto payment_option = "auto";
EVLOG_debug << "Using default payment_options";
CmdArguments args{arguments[0], payment_option, arguments[1], arguments[2]};
return this->car_simulation->iso_start_v2g_session(args, mod->config.three_phases);
});
command_registry->register_command("iso_start_v2g_session", 4, [this](const CmdArguments& arguments) {
// 1. Argument: EnergyMode
// 2. Argument: DepartureTime
// 3. Argument: EAmount
// 2. Argument: PaymentOption
// 3. Argument: DepartureTime
// 4. Argument: EAmount
return this->car_simulation->iso_start_v2g_session(arguments, mod->config.three_phases);
});
command_registry->register_command("iso_stop_charging", 0, [this](const CmdArguments& arguments) {
Expand Down
4 changes: 4 additions & 0 deletions modules/EV/EvManager/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ config:
Simulation commands for the EV on "plugin" sim command, e.g. sleep 1;iec_wait_pwr_ready;sleep 1;draw_power_regulated 16,3;sleep 30;unplug
type: string
default: ""
force_payment_option:
description: Force the use of the selected payment option
type: boolean
default: false
provides:
main:
interface: car_simulator
Expand Down
6 changes: 6 additions & 0 deletions modules/EV/PyEvJosev/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
self._es.EAmount_kWh = args['EAmount']
self._es.EnergyTransferMode = args['EnergyTransferMode']

if "payment_option" in args['SelectedPaymentOption']:
self._es.PaymentOption = args['SelectedPaymentOption']['payment_option']
if "enforce_payment_option" in args['SelectedPaymentOption']:
self._es.enforce_payment_option = args['SelectedPaymentOption']['enforce_payment_option']

self._ready_event.set()

return True
Expand Down Expand Up @@ -140,3 +145,4 @@

py_ev_josev = PyEVJosevModule()
py_ev_josev.start_evcc_handler()

Check notice on line 148 in modules/EV/PyEvJosev/module.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/EV/PyEvJosev/module.py#L148

Trailing newlines (trailing-newlines)
12 changes: 12 additions & 0 deletions types/iso15118.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,18 @@ types:
type: string
$ref: /iso15118#/GridCodeIslandingDetectionMethod
# EV Side
SelectedPaymentOption:
description: The selected payment option for the Ev.
type: object
additionalProperties: false
properties:
payment_option:
description: Selected payment option
type: string
$ref: /iso15118#/PaymentOption
enforce_payment_option:
description: Enforce the selected payment option
type: boolean
DcEvParameters:
description: Target settings for dc charging
type: object
Expand Down
Loading