INSTINCT Code Coverage Report


Directory: src/
File: internal/gui/menus/RunMenu.cpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 0 33 0.0%
Functions: 0 1 0.0%
Branches: 0 68 0.0%

Line Branch Exec Source
1 // This file is part of INSTINCT, the INS Toolkit for Integrated
2 // Navigation Concepts and Training by the Institute of Navigation of
3 // the University of Stuttgart, Germany.
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9 #include "RunMenu.hpp"
10
11 #include <imgui.h>
12
13 #include "internal/FlowExecutor.hpp"
14 #include "internal/NodeManager.hpp"
15 namespace nm = NAV::NodeManager;
16
17 #include "util/Logger.hpp"
18
19 void NAV::gui::menus::ShowRunMenu()
20 {
21 bool hasInitializedNodes = false;
22 bool hasDeInitializedNodes = false;
23 for (const auto* node : nm::m_Nodes())
24 {
25 if (node->getState() == Node::State::Initialized)
26 {
27 hasInitializedNodes = true;
28 }
29 else if (node->getState() == Node::State::Deinitialized)
30 {
31 hasDeInitializedNodes = true;
32 }
33 }
34 if (ImGui::MenuItem("Initialize all Nodes", nullptr, false, hasDeInitializedNodes))
35 {
36 for (auto* node : nm::m_Nodes())
37 {
38 if (node->getState() == Node::State::Deinitialized)
39 {
40 node->doInitialize();
41 }
42 }
43 }
44 if (ImGui::MenuItem("Reinitialize all Nodes", nullptr, false, hasInitializedNodes))
45 {
46 for (auto* node : nm::m_Nodes())
47 {
48 if (node->isInitialized())
49 {
50 node->doReinitialize();
51 }
52 else if (node->getState() == Node::State::Deinitialized)
53 {
54 node->doInitialize();
55 }
56 }
57 }
58 if (ImGui::MenuItem("Deinitialize all Nodes", nullptr, false, hasInitializedNodes))
59 {
60 for (auto* node : nm::m_Nodes())
61 {
62 if (node->isInitialized())
63 {
64 node->doDeinitialize();
65 }
66 }
67 }
68
69 ImGui::Separator();
70
71 if (ImGui::MenuItem("Run Flow", "F7", false, !FlowExecutor::isRunning()))
72 {
73 if (!FlowExecutor::isRunning())
74 {
75 LOG_INFO("Starting Flow Execution");
76 FlowExecutor::start();
77 }
78 }
79 if (ImGui::MenuItem("Stop Execution", "Esc", false, FlowExecutor::isRunning()))
80 {
81 if (FlowExecutor::isRunning())
82 {
83 LOG_INFO("Canceling Execution...");
84 FlowExecutor::stop();
85 LOG_INFO("Execution canceled");
86 }
87 }
88 }
89