-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainGUI.cpp
163 lines (119 loc) · 4.69 KB
/
mainGUI.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <string>
#include <thread>
#include <mutex>
#include <imgui_demo.cpp>
#include <thread_exo.h>
ThreadExo * ATIMX1;
ThreadExo * XsensRead;
ThreadExo * XSENSLeo;
ThreadExo * EposEXO1;
ThreadExo * EposEXOCAN1;
ThreadExo * MarkovMao1;
ThreadExo * XsensGaitPhase1;
ThreadExo * EXOSquatDavid1;
#include "threads/threadATIMX.hpp"
#include "threads/threadXsensRead.hpp"
#include "threads/threadEposEXO.hpp"
#include "threads/threadEposEXO_CAN.hpp"
#include "threads/threadXsensLeo.hpp"
#include "threads/threadXsensGaitPhase.hpp"
#include "threads/threadMarkovMauricio.hpp"
#include "threads/threadEXOSquatDavid.hpp"
int mainGUI(){
ATIMX1 = new ThreadExo(new ThreadATIMX(),"ATIMX 1",1/200.0f,7);
XsensRead = new ThreadExo(new ThreadXsensRead(),"XSens Read 1",1/100.0f,25);
EposEXO1 = new ThreadExo(new ThreadEposEXO(),"EposEXO 1",1/200.0f,4);
EposEXOCAN1 = new ThreadExo(new ThreadEposEXO_CAN(),"EposEXO CAN 1",1/400.0f,4);
MarkovMao1 = new ThreadExo(new ThreadMarkovMao1(),"MarkovMao 1",1/200.0f,20);
XSENSLeo = new ThreadExo(new ThreadXsensLeo(), "XSens Leo 1", 1 / 75.0f, 11);
XsensGaitPhase1 = new ThreadExo(new ThreadXsensGaitPhase(), "XSens Gait Phase 1", 1 / 100.0f, 4);
EXOSquatDavid1 = new ThreadExo(new ThreadEXOSquatDavid(), "EXO Squat David", 1 / 200.0f, 4);
return 0;
}
void loopGUI(bool * exit){
static bool show = true;
static fromATIMX atimx{0};
static char tex [255];
static bool isRunning = false;
isRunning = threadsExo.RUNNING();
show = !isRunning;
ImGui::ShowDemoWindow();
ImGui::Begin("ControlPanel",&show,0);
if (ImGui::Button("Exit")) {
(*exit) = true;
return;
}
if (ImGui::CollapsingHeader(isRunning? "RUNNING" : "PAUSED" , ImGuiTreeNodeFlags_Leaf)){
if(!isRunning){
ImGui::Columns(2, NULL, false);
if(ImGui::Button("CLEAR")){
ItALL{
cur_->toRUNfromGUI = false;
}
}ImGui::NextColumn();
if(ImGui::Button("TEST ATIMX 1")){
ATIMX1->toRUNfromGUI = true;
}ImGui::NextColumn();
if(ImGui::Button("TEST Xsens Leo")){
XsensRead->toRUNfromGUI = true;
XSENSLeo->toRUNfromGUI = true;
}ImGui::NextColumn();
if(ImGui::Button("Controle Markoviano")){
ATIMX1->toRUNfromGUI = true;
EposEXOCAN1->toRUNfromGUI = true;
XsensRead->toRUNfromGUI = true;
XSENSLeo->toRUNfromGUI = true;
MarkovMao1->toRUNfromGUI = true;
}ImGui::NextColumn();
ImGui::Columns(1);
}
if(!isRunning){
ImGui::Columns(3, NULL, false);
ItALL{
ImGui::Checkbox(("RUN : " + cur_->getName()).c_str(),&cur_->toRUNfromGUI);
ImGui::NextColumn();
}
ImGui::Columns(1);
}
if(ImGui::Button("FORCE STOP")){
GUI.FORCE_STOP = true;
}
if(!isRunning){
ImGui::Columns(4, NULL, false);
static float Time = 1.0f;
static bool INIT = false;
ImGui::DragFloat("##time_count", &Time, 0.1f, 2, 60, "%.2f Segundos");
if(Time <= 0) Time = 10;
ImGui::SameLine();
if(ImGui::Button("RUN")){
INIT = true;
}
static float ti[] = {5.0f,10.0f,20.0f,30.0f,40.0f,50.0f,60.0f};
static char ti_labels[50];
for(int i_ti = 0 ; i_ti < 7 ; i_ti ++){
sprintf(ti_labels,"RUN: %.2f s ##%d",ti[i_ti],i_ti);
ImGui::NextColumn();
if(ImGui::Button(ti_labels)){
INIT = true;
Time = ti[i_ti];
}
}
ImGui::Columns(1);
if(INIT){
INIT = false;
threadsExo.clear();
ItALL{
if(cur_->toRUNfromGUI) threadsExo.add(cur_);
}
threadsExo.run(Time);
}
}
}
ImGui::End();
ItALL{
if(cur_->toRUNfromGUI)
cur_->updateGUI();
}
//threadsExo.updateGUI();
return;
}