Skip to content

Commit

Permalink
fixes rcd error
Browse files Browse the repository at this point in the history
Signed-off-by: MarzellT <[email protected]>
  • Loading branch information
MarzellT committed Jul 1, 2024
1 parent f55fb47 commit 1b82402
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
15 changes: 14 additions & 1 deletion config/config-sil-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ active_modules:
module: EvseV2G
config_module:
device: auto
tls_security: allow
tls_security: force
tls_key_logging: true
connections:
security:
- module_id: evse_security
Expand All @@ -14,6 +15,17 @@ active_modules:
device: auto
supported_DIN70121: true
supported_ISO15118_2: true
tls_active: true
enforce_tls: true
packet_sniffer:
module: PacketSniffer
config_module:
device: "wlp0s20f3"
session_logging_path: /tmp/everest-logs
connections:
evse_manager:
- module_id: evse_manager
implementation_id: evse
evse_manager:
module: EvseManager
config_module:
Expand All @@ -26,6 +38,7 @@ active_modules:
session_logging_path: /tmp/everest-logs
charge_mode: DC
hack_allow_bpt_with_iso2: true
payment_enable_contract: false
connections:
bsp:
- module_id: yeti_driver
Expand Down
1 change: 1 addition & 0 deletions interfaces/evse_board_support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,4 @@ vars:
$ref: /evse_manager#/StopTransactionRequest
errors:
- reference: /errors/evse_board_support
- reference: /errors/ac_rcd
20 changes: 20 additions & 0 deletions modules/EvManager/main/CarSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ bool CarSimulation::iso_wait_pwm_is_running(const CmdArguments& arguments) {
sim_data.state = SimState::PLUGGED_IN;
return (sim_data.pwm_duty_cycle > 4.0f && sim_data.pwm_duty_cycle < 97.0f);
}

bool CarSimulation::draw_power_regulated(const CmdArguments& arguments) {
r_ev_board_support->call_set_ac_max_current(std::stod(arguments[0]));
if (arguments[1] == constants::THREE_PHASES) {
Expand All @@ -122,6 +123,7 @@ bool CarSimulation::draw_power_regulated(const CmdArguments& arguments) {
sim_data.state = SimState::CHARGING_REGULATED;
return true;
}

bool CarSimulation::draw_power_fixed(const CmdArguments& arguments) {
r_ev_board_support->call_set_ac_max_current(std::stod(arguments[0]));
if (arguments[1] == constants::THREE_PHASES) {
Expand All @@ -132,26 +134,33 @@ bool CarSimulation::draw_power_fixed(const CmdArguments& arguments) {
sim_data.state = SimState::CHARGING_FIXED;
return true;
}

bool CarSimulation::pause(const CmdArguments& arguments) {
sim_data.state = SimState::PLUGGED_IN;
return true;
}

bool CarSimulation::unplug(const CmdArguments& arguments) {
sim_data.state = SimState::UNPLUGGED;
return true;
}

bool CarSimulation::error_e(const CmdArguments& arguments) {
sim_data.state = SimState::ERROR_E;
return true;
}

bool CarSimulation::diode_fail(const CmdArguments& arguments) {
sim_data.state = SimState::DIODE_FAIL;
return true;
}

bool CarSimulation::rcd_current(const CmdArguments& arguments) {
sim_data.rcd_current_ma = std::stof(arguments[0]);
r_ev_board_support->call_set_rcd_error(sim_data.rcd_current_ma);
return true;
}

bool CarSimulation::iso_wait_slac_matched(const CmdArguments& arguments) {
sim_data.state = SimState::PLUGGED_IN;

Expand All @@ -170,13 +179,15 @@ bool CarSimulation::iso_wait_slac_matched(const CmdArguments& arguments) {
}
return false;
}

bool CarSimulation::iso_wait_pwr_ready(const CmdArguments& arguments) {
if (sim_data.iso_pwr_ready) {
sim_data.state = SimState::ISO_POWER_READY;
return true;
}
return false;
}

bool CarSimulation::iso_dc_power_on(const CmdArguments& arguments) {
sim_data.state = SimState::ISO_POWER_READY;
if (sim_data.dc_power_on) {
Expand All @@ -186,6 +197,7 @@ bool CarSimulation::iso_dc_power_on(const CmdArguments& arguments) {
}
return false;
}

bool CarSimulation::iso_start_v2g_session(const CmdArguments& arguments, bool three_phases) {
const auto& energy_mode = arguments[0];

Expand All @@ -202,6 +214,7 @@ bool CarSimulation::iso_start_v2g_session(const CmdArguments& arguments, bool th
}
return true;
}

bool CarSimulation::iso_draw_power_regulated(const CmdArguments& arguments) {
r_ev_board_support->call_set_ac_max_current(std::stod(arguments[0]));
if (arguments[1] == constants::THREE_PHASES) {
Expand All @@ -212,12 +225,14 @@ bool CarSimulation::iso_draw_power_regulated(const CmdArguments& arguments) {
sim_data.state = SimState::ISO_CHARGING_REGULATED;
return true;
}

bool CarSimulation::iso_stop_charging(const CmdArguments& arguments) {
r_ev[0]->call_stop_charging();
r_ev_board_support->call_allow_power_on(false);
sim_data.state = SimState::PLUGGED_IN;
return true;
}

bool CarSimulation::iso_wait_for_stop(const CmdArguments& arguments, size_t loop_interval_ms) {
if (!sim_data.sleep_ticks_left.has_value()) {
sim_data.sleep_ticks_left =
Expand All @@ -238,21 +253,25 @@ bool CarSimulation::iso_wait_for_stop(const CmdArguments& arguments, size_t loop
}
return false;
}

bool CarSimulation::iso_wait_v2g_session_stopped(const CmdArguments& arguments) {
if (sim_data.v2g_finished) {
return true;
}
return false;
}

bool CarSimulation::iso_pause_charging(const CmdArguments& arguments) {
r_ev[0]->call_pause_charging();
sim_data.state = SimState::PLUGGED_IN;
sim_data.iso_pwr_ready = false;
return true;
}

bool CarSimulation::iso_wait_for_resume(const CmdArguments& arguments) {
return false;
}

bool CarSimulation::iso_start_bcb_toggle(const CmdArguments& arguments) {
sim_data.state = SimState::BCB_TOGGLE;
if (sim_data.bcb_toggles >= std::stoul(arguments[0]) || sim_data.bcb_toggles == 3) {
Expand All @@ -262,6 +281,7 @@ bool CarSimulation::iso_start_bcb_toggle(const CmdArguments& arguments) {
}
return false;
}

bool CarSimulation::wait_for_real_plugin(const CmdArguments& arguments) {
using types::board_support_common::Event;
if (sim_data.actual_bsp_event == Event::A) {
Expand Down
2 changes: 1 addition & 1 deletion modules/EvManager/main/CarSimulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CarSimulation {
sim_data.pp = pp;
}

void setr_rcd_current(float rcd_current) {
void set_rcd_current(float rcd_current) {
sim_data.rcd_current_ma = rcd_current;
}

Expand Down
20 changes: 13 additions & 7 deletions modules/EvManager/main/car_simulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ void car_simulatorImpl::handle_executeChargingSession(std::string& value) {
return;
}

execution_active = false;
set_execution_active(false);
reset_car_simulation_defaults();

update_command_queue(value);

const std::lock_guard<std::mutex> lock{car_simulation_mutex};
if (!command_queue.empty()) {
execution_active = true;
set_execution_active(true);
}
}

Expand All @@ -72,13 +72,13 @@ void car_simulatorImpl::handle_modifyChargingSession(std::string& value) {
return;
}

execution_active = false;
set_execution_active(false);

update_command_queue(value);

const std::lock_guard<std::mutex> lock{car_simulation_mutex};
if (!command_queue.empty()) {
execution_active = true;
set_execution_active(true);
}
}

Expand All @@ -90,7 +90,7 @@ void car_simulatorImpl::run() {

if (finished) {
EVLOG_info << "Finished simulation.";
this->execution_active = false;
set_execution_active(false);

reset_car_simulation_defaults();

Expand Down Expand Up @@ -228,7 +228,7 @@ void car_simulatorImpl::subscribe_to_variables_on_init() {
car_simulation->set_bsp_event(bsp_event.event);
if (bsp_event.event == types::board_support_common::Event::Disconnected &&
car_simulation->get_state() != SimState::UNPLUGGED) {
execution_active = false;
set_execution_active(false);
car_simulation->set_state(SimState::UNPLUGGED);
}
});
Expand All @@ -237,7 +237,7 @@ void car_simulatorImpl::subscribe_to_variables_on_init() {
using types::board_support_common::BspMeasurement;
mod->r_ev_board_support->subscribe_bsp_measurement([this](const auto& measurement) {
car_simulation->set_pp(measurement.proximity_pilot.ampacity);
car_simulation->setr_rcd_current(measurement.rcd_current_mA.value());
car_simulation->set_rcd_current(measurement.rcd_current_mA.value());
car_simulation->set_pwm_duty_cycle(measurement.cp_pwm_duty_cycle);
});

Expand Down Expand Up @@ -304,6 +304,7 @@ void car_simulatorImpl::subscribe_to_external_mqtt() {
handle_modifyChargingSession(data_copy);
});
}

void car_simulatorImpl::reset_car_simulation_defaults() {
const std::lock_guard<std::mutex> lock{car_simulation_mutex};
car_simulation->reset();
Expand All @@ -313,4 +314,9 @@ void car_simulatorImpl::update_command_queue(std::string& value) {
const std::lock_guard<std::mutex> lock{car_simulation_mutex};
command_queue = SimulationCommand::parse_sim_commands(value, *command_registry);
}

void car_simulatorImpl::set_execution_active(bool value) {
execution_active = value;
}

} // namespace module::main
1 change: 1 addition & 0 deletions modules/EvManager/main/car_simulatorImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class car_simulatorImpl : public car_simulatorImplBase {
void subscribe_to_external_mqtt();
void reset_car_simulation_defaults();
void update_command_queue(std::string& value);
void set_execution_active(bool value);

std::unique_ptr<CommandRegistry> command_registry;

Expand Down
11 changes: 10 additions & 1 deletion modules/simulation/JsYetiSimulator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,19 @@ function publish_event(mod, event) {
function check_error_rcd(mod) {
if (mod.simulation_data.rcd_current > 5.0) {
if (!mod.rcd_error_reported) {
mod.provides.rcd.raise.ac_rcd_DC('Simulated fault event', 'High');
let error = mod.provides.board_support.error_factory.create_error(
'ac_rcd/DC',
'',
'Simulated fault event',
'High'
);
mod.provides.board_support.raise_error(error);
mod.rcd_error_reported = true;
}
} else {
if (mod.rcd_error_reported) {
mod.provides.board_support.clear_error('ac_rcd/DC');
}
mod.rcd_error_reported = false;
}
mod.provides.rcd.publish.rcd_current_mA = mod.simulation_data.rcd_current;
Expand Down

0 comments on commit 1b82402

Please sign in to comment.