Commit d6beb5f7 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

gui: rename simulation_status enumeration

parent b00c1b82
Pipeline #16855 passed with stage
in 1 minute and 8 seconds
......@@ -2238,10 +2238,10 @@ editor::show_model_dynamics(model& mdl) noexcept
if (simulation_show_value &&
match(st,
simulation_status::success,
simulation_status::running_once,
simulation_status::running_once_need_join,
simulation_status::running_step)) {
editor_status::success,
editor_status::running_once,
editor_status::running_once_need_join,
editor_status::running_step)) {
sim.dispatch(mdl.type, [&](const auto& d_array) {
const auto& dyn = d_array.get(mdl.id);
......@@ -2273,10 +2273,10 @@ editor::show_top() noexcept
const auto id = std::get<model_id>(top.children[i].first);
if (auto* mdl = sim.models.try_to_get(id); mdl) {
if (match(st,
simulation_status::success,
simulation_status::running_once,
simulation_status::running_once_need_join,
simulation_status::running_step) &&
editor_status::success,
editor_status::running_once,
editor_status::running_once_need_join,
editor_status::running_step) &&
models_make_transition[get_index(id)]) {
imnodes::PushColorStyle(imnodes::ColorStyle_TitleBar,
......@@ -2816,10 +2816,10 @@ show_plot_box(bool* show_plot)
static editor_id current = undefined<editor_id>();
if (auto* ed = make_combo_editor_name(current); ed) {
if (match(ed->st,
simulation_status::success,
simulation_status::running_once,
simulation_status::running_once_need_join,
simulation_status::running_step)) {
editor_status::success,
editor_status::running_once,
editor_status::running_once_need_join,
editor_status::running_step)) {
if (ImPlot::BeginPlot("simulation", "t", "s")) {
ImPlot::PushStyleVar(ImPlotStyleVar_LineWeight, 1.f);
for (const auto& obs : ed->observation_outputs) {
......
......@@ -113,7 +113,7 @@ enum class cluster_id : u64;
using child_id = std::variant<model_id, cluster_id>;
enum class simulation_status
enum class editor_status
{
success,
running_once,
......@@ -263,7 +263,7 @@ struct editor
int simulation_during_bag;
std::thread simulation_thread;
simulation_status st = simulation_status::success;
editor_status st = editor_status::success;
bool simulation_show_value = false;
bool stop = false;
......
......@@ -162,7 +162,7 @@ run_simulation(window_logger& log_w,
double begin,
double end,
double& current,
simulation_status& st,
editor_status& st,
const bool& stop) noexcept
{
current = begin;
......@@ -170,36 +170,36 @@ run_simulation(window_logger& log_w,
log_w.log(3,
"Simulation initialization failure (%s)\n",
irt::status_string(ret));
st = simulation_status::success;
st = editor_status::success;
return;
}
do {
if (auto ret = sim.run(current); irt::is_bad(ret)) {
log_w.log(3, "Simulation failure (%s)\n", irt::status_string(ret));
st = simulation_status::success;
st = editor_status::success;
return;
}
} while (current < end && !stop);
sim.clean();
st = simulation_status::running_once_need_join;
st = editor_status::running_once_need_join;
}
static void
show_simulation_run_once(window_logger& log_w, editor& ed)
{
if (ed.st == simulation_status::running_once_need_join) {
if (ed.st == editor_status::running_once_need_join) {
if (ed.simulation_thread.joinable()) {
ed.simulation_thread.join();
ed.st = simulation_status::success;
ed.st = editor_status::success;
}
} else {
if (ImGui::Button("run")) {
initialize_observation(log_w, ed);
ed.st = simulation_status::running_once;
ed.st = editor_status::running_once;
ed.stop = false;
ed.simulation_thread = std::thread(&run_simulation,
......@@ -213,7 +213,7 @@ show_simulation_run_once(window_logger& log_w, editor& ed)
}
}
if (ed.st == simulation_status::running_once) {
if (ed.st == editor_status::running_once) {
ImGui::SameLine();
if (ImGui::Button("Force stop"))
ed.stop = true;
......@@ -237,20 +237,20 @@ simulation_init(window_logger& log_w, editor& ed)
log_w.log(3,
"Simulation initialisation failure (%s)\n",
irt::status_string(ret));
ed.st = simulation_status::success;
ed.st = editor_status::success;
} else {
ed.simulation_next_time = ed.sim.sched.empty()
? time_domain<time>::infinity
: ed.sim.sched.tn();
ed.simulation_bag_id = 0;
ed.st = simulation_status::running_step;
ed.st = editor_status::running_step;
}
}
static void
show_simulation_run_debug(window_logger& log_w, editor& ed)
{
if (ed.st == simulation_status::success) {
if (ed.st == editor_status::success) {
ImGui::Text("simulation finished");
if (ImGui::Button("init."))
......@@ -268,7 +268,7 @@ show_simulation_run_debug(window_logger& log_w, editor& ed)
if (ImGui::Button("Next bag")) {
if (auto ret = ed.sim.run(ed.simulation_current); is_bad(ret)) {
ed.st = simulation_status::success;
ed.st = editor_status::success;
}
++ed.simulation_bag_id;
}
......@@ -278,7 +278,7 @@ show_simulation_run_debug(window_logger& log_w, editor& ed)
if (ImGui::Button("Bag >> 10")) {
for (int i = 0; i < 10; ++i) {
if (auto ret = ed.sim.run(ed.simulation_current); is_bad(ret)) {
ed.st = simulation_status::success;
ed.st = editor_status::success;
break;
}
++ed.simulation_bag_id;
......@@ -290,7 +290,7 @@ show_simulation_run_debug(window_logger& log_w, editor& ed)
if (ImGui::Button("Bag >> 100")) {
for (int i = 0; i < 100; ++i) {
if (auto ret = ed.sim.run(ed.simulation_current); is_bad(ret)) {
ed.st = simulation_status::success;
ed.st = editor_status::success;
break;
}
++ed.simulation_bag_id;
......@@ -305,7 +305,7 @@ show_simulation_run_debug(window_logger& log_w, editor& ed)
const auto end = ed.simulation_current + ed.simulation_during_date;
while (ed.simulation_current < end) {
if (auto ret = ed.sim.run(ed.simulation_current); is_bad(ret)) {
ed.st = simulation_status::success;
ed.st = editor_status::success;
break;
}
++ed.simulation_bag_id;
......@@ -319,14 +319,14 @@ show_simulation_run_debug(window_logger& log_w, editor& ed)
if (ImGui::Button("run##bag")) {
for (int i = 0, e = ed.simulation_during_bag; i != e; ++i) {
if (auto ret = ed.sim.run(ed.simulation_current); is_bad(ret)) {
ed.st = simulation_status::success;
ed.st = editor_status::success;
break;
}
++ed.simulation_bag_id;
}
}
if (ed.st == simulation_status::running_step) {
if (ed.st == editor_status::running_step) {
ed.simulation_next_time = ed.sim.sched.empty()
? time_domain<time>::infinity
: ed.sim.sched.tn();
......@@ -485,10 +485,10 @@ show_simulation_box(window_logger& log_w, bool* show_simulation)
// }
if (match(ed->st,
simulation_status::success,
simulation_status::running_once,
simulation_status::running_once_need_join,
simulation_status::running_step)) {
editor_status::success,
editor_status::running_once,
editor_status::running_once_need_join,
editor_status::running_step)) {
ImGui::Text("Current: %g", ed->simulation_current);
const double duration = ed->simulation_end - ed->simulation_begin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment