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

Small EvManager fixes to work on real hw #805

Merged
merged 1 commit into from
Aug 2, 2024
Merged
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
12 changes: 7 additions & 5 deletions modules/EvManager/main/car_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ void CarSimulation::state_machine() {
};

bool CarSimulation::sleep(const CmdArguments& arguments, size_t loop_interval_ms) {
if (!sim_data.sleep_ticks_left.has_value()) {
if (not sim_data.sleep_ticks_left.has_value()) {
const auto sleep_time = std::stold(arguments[0]);
const auto sleep_time_ms = sleep_time * 1000;
sim_data.sleep_ticks_left = static_cast<long long>(sleep_time_ms / loop_interval_ms) + 1;
}
sim_data.sleep_ticks_left.value() -= 1;
if (not(sim_data.sleep_ticks_left.value() > 0)) {
auto& sleep_ticks_left = sim_data.sleep_ticks_left.value();
sleep_ticks_left -= 1;
if (not(sleep_ticks_left > 0)) {
sim_data.sleep_ticks_left.reset();
return true;
} else {
Expand Down Expand Up @@ -238,8 +239,9 @@ bool CarSimulation::iso_wait_for_stop(const CmdArguments& arguments, size_t loop
const auto sleep_time_ms = std::stold(arguments[0]) * 1000;
sim_data.sleep_ticks_left = static_cast<long long>(sleep_time_ms / loop_interval_ms) + 1;
}
sim_data.sleep_ticks_left.value() -= 1;
if (not(sim_data.sleep_ticks_left.value() > 0)) {
auto& sleep_ticks_left = sim_data.sleep_ticks_left.value();
sleep_ticks_left -= 1;
if (not(sleep_ticks_left > 0)) {
r_ev[0]->call_stop_charging();
r_ev_board_support->call_allow_power_on(false);
sim_data.state = SimState::PLUGGED_IN;
Expand Down
4 changes: 3 additions & 1 deletion modules/EvManager/main/car_simulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ 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->set_rcd_current(measurement.rcd_current_mA.value());
car_simulation->set_pwm_duty_cycle(measurement.cp_pwm_duty_cycle);
if (measurement.rcd_current_mA.has_value()) {
car_simulation->set_rcd_current(measurement.rcd_current_mA.value());
}
});

// subscribe slac_state
Expand Down
2 changes: 1 addition & 1 deletion modules/EvManager/main/simulation_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ struct SimulationData {

bool dc_power_on{false};

types::board_support_common::Event actual_bsp_event{};
types::board_support_common::Event actual_bsp_event{types::board_support_common::Event::Disconnected};
};
Loading