0.4.1
Loading...
Searching...
No Matches
RunMenu.cpp
Go to the documentation of this file.
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
15namespace nm = NAV::NodeManager;
16
17#include "util/Logger.hpp"
18
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 {
74 {
75 LOG_INFO("Starting Flow Execution");
77 }
78 }
79 if (ImGui::MenuItem("Stop Execution", "Esc", false, FlowExecutor::isRunning()))
80 {
82 {
83 LOG_INFO("Canceling Execution...");
85 LOG_INFO("Execution canceled");
86 }
87 }
88}
Flow Executor Thread.
Utility class for logging to console and file.
#define LOG_INFO
Info to the user on the state of the program.
Definition Logger.hpp:69
Manages all Nodes.
Run Menu.
@ Initialized
Node is initialized (green)
Definition Node.hpp:181
@ Deinitialized
Node is deinitialized (red)
Definition Node.hpp:178
bool isRunning() noexcept
Checks if the thread is running.
void start()
Starts the Thread.
void stop()
Stops the Thread.
const std::vector< Node * > & m_Nodes()
List of all registered Nodes.
void ShowRunMenu()
Show the run menu dropdown.
Definition RunMenu.cpp:19