diff --git a/interfaces/ISO15118_ev.yaml b/interfaces/ISO15118_ev.yaml index a060145c97..2ad5364ded 100644 --- a/interfaces/ISO15118_ev.yaml +++ b/interfaces/ISO15118_ev.yaml @@ -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) diff --git a/modules/EV/EvManager/EvManager.hpp b/modules/EV/EvManager/EvManager.hpp index 4f367ff985..1318504204 100644 --- a/modules/EV/EvManager/EvManager.hpp +++ b/modules/EV/EvManager/EvManager.hpp @@ -52,6 +52,7 @@ struct Conf { int soc; bool keep_cross_boot_plugin_state; std::string plugin_commands; + bool force_payment_option; }; class EvManager : public Everest::ModuleBase { diff --git a/modules/EV/EvManager/main/car_simulation.cpp b/modules/EV/EvManager/main/car_simulation.cpp index b5b72e1b3c..bfd5ae8ef4 100644 --- a/modules/EV/EvManager/main/car_simulation.cpp +++ b/modules/EV/EvManager/main/car_simulation.cpp @@ -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 { diff --git a/modules/EV/EvManager/main/car_simulatorImpl.cpp b/modules/EV/EvManager/main/car_simulatorImpl.cpp index d15d541d01..0554377b9e 100644 --- a/modules/EV/EvManager/main/car_simulatorImpl.cpp +++ b/modules/EV/EvManager/main/car_simulatorImpl.cpp @@ -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) { diff --git a/modules/EV/EvManager/manifest.yaml b/modules/EV/EvManager/manifest.yaml index 1ef8acaabc..fa6a6b2cea 100644 --- a/modules/EV/EvManager/manifest.yaml +++ b/modules/EV/EvManager/manifest.yaml @@ -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 diff --git a/modules/EV/PyEvJosev/module.py b/modules/EV/PyEvJosev/module.py index eec896a0ca..5506298ee0 100644 --- a/modules/EV/PyEvJosev/module.py +++ b/modules/EV/PyEvJosev/module.py @@ -106,6 +106,11 @@ def _handler_start_charging(self, args) -> bool: 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 @@ -140,3 +145,4 @@ def _handler_enable_sae_j2847_v2g_v2h(self, args): py_ev_josev = PyEVJosevModule() py_ev_josev.start_evcc_handler() + diff --git a/types/iso15118.yaml b/types/iso15118.yaml index 7160eb1fb0..86a05b60f0 100644 --- a/types/iso15118.yaml +++ b/types/iso15118.yaml @@ -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