-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainhandler.cpp
229 lines (186 loc) · 8.53 KB
/
mainhandler.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#include "mainhandler.h"
MainHandler::MainHandler(QObject *parent) : QObject(parent)
{
//qDebug()<<" debug 2";
loggerClass = new loggerThread();
thrd = new QThread(loggerClass);
loggerClass->moveToThread(thrd);
thrd->start(QThread::HighestPriority);
QProcess process;
process.start("mount /dev/mmcblk0p4 /home/root/DAQ_Logs/");
process.waitForFinished();
// QProcess process2;
// process2.setWorkingDirectory("/home/grullo");
// QString Command; //Contains the command to be executed
// QStringList args; //Contains arguments of the command
// Command = "ls";
// args<<"-l"<<"/home/root/DAQ_Logs";
// process2.start(Command, args, QIODevice::ReadOnly); //Starts execution of command
// process2.waitForFinished();
//qDebug()<<" debug 3";
timer_SingleShots = new QTimer();
index_singleShot = 0;
connect(timer_SingleShots, SIGNAL(timeout()), SLOT(on_timer_SingleShot_elapsed()));
timer_SingleShots->setSingleShot(true);
//qDebug()<<" debug 4";
timer_generateGUI = new QTimer();
connect(timer_generateGUI, SIGNAL(timeout()), SLOT(on_timer_generateGUI_Elapsed()));
timer_generateGUI->setSingleShot(true);;
//qDebug()<<" debug 5";
}
void MainHandler::initial_Start()
{
timer_SingleShots->start(300);
}
void MainHandler::on_timer_SingleShot_elapsed()
{
qDebug()<<" Single Shot elapsed ";
switch (index_singleShot) {
case 0: {
GUIobjectInitializer();
//generate_firstWindow();
//generate_ConfigCHWin();
generate_logConfig();
break;
}
}
}
void MainHandler::on_timer_generateGUI_Elapsed()
{
qDebug()<<" \t\t Timer generateGUI elapsed :: " <<local_generateGUI;
switch (local_generateGUI) {
case gui_CONFIG_CH_WIN: {
generate_ConfigCHWin();
break;
}
case gui_CONFIRMATION_WIN: {
break;
}
case gui_FIRST_WIN: {
//qDebug()<<" First Window Switch Statement"<<firstWin->isWidgetType();
//firstWin->show();
if(firstWin == nullptr ) generate_firstWindow();
else firstWin->show();
break;
}
case gui_GRAPH_WIN: {
generate_graphWin();
break;
}
case gui_LOG_CONFIG_WIN: {
generate_logConfig();
break;
}
case gui_DEBUG_WIN: {
generate_DebugWin();
break;
}
} // end of Switch statement
}
void MainHandler::rx_generate_ThisGUI(GUI_WIN guiEnum)
{
qDebug()<<" Singal Received genrate_ThisGUI:: "<<guiEnum;
local_generateGUI = guiEnum;
timer_generateGUI->start(100);
}
void MainHandler::generate_firstWindow()
{
firstWin = new FirstWindow();
connect(firstWin, SIGNAL(tx_generate_ThisGUI(GUI_WIN)), this, SLOT(rx_generate_ThisGUI(GUI_WIN)));
connect(firstWin, SIGNAL(tx_ClosingWindow_FirstWin(bool)), this, SLOT(rx_ClosingWindow_FirstWin(bool)));
firstWin->setModal(true);
firstWin->show();
}
void MainHandler::generate_logConfig()
{
logConfig = new MainWindow();
connect(loggerClass, SIGNAL(tx_channel_Value(int,uint32_t,float,float)), logConfig, SLOT(rx_ChannelValue(int,uint32_t,float,float)));
connect(logConfig, SIGNAL(tx_setChannelEnable(int, bool)), loggerClass, SLOT(rx_setChannelEnableDisable(int, bool)));
connect(logConfig, SIGNAL(tx_setSampleTime(int)), loggerClass, SLOT(rx_setSampleTime(int)));
connect(loggerClass, SIGNAL(tx_loggingStarted_andFileOpenSuccess(bool)), logConfig, SLOT(rx_loggingStarted_andFileOpenSuccess(bool)));
connect(logConfig, SIGNAL(tx_sendFactorsAndPGAs_AllChnls()), loggerClass, SLOT(rx_sendFactorsAndPGAs_AllChnls()));
connect(loggerClass, SIGNAL(tx_sendingFactorsAndPGAs(int, float, float, bool)), logConfig, SLOT(rx_sendingFactorsAndPGAs(int, float, float, bool)));
connect(logConfig, SIGNAL(tx_loggingStartStop(bool, QString)), loggerClass, SLOT(rx_loggingStartStop(bool, QString)));
connect(loggerClass, SIGNAL(tx_ramdomOP(int,float, QString)), logConfig, SLOT(rx_ramdomOP(int,float, QString)));
connect(logConfig, SIGNAL(tx_ClosingWindow_logConfig()), this, SLOT(rx_ClosingWindow_logConfig()));
connect(logConfig, SIGNAL(tx_generate_ThisGUI(GUI_WIN)), this, SLOT(rx_generate_ThisGUI(GUI_WIN)));
logConfig->show();
}
void MainHandler::generate_graphWin()
{
grphW = new graphWin();
connect(grphW, SIGNAL(tx_GraphWindowIsOpen(bool)), loggerClass, SLOT(rx_GraphWindowIsOpen(bool)));
connect(grphW, SIGNAL(tx_AddNewChannelToGraph(int, int)), loggerClass, SLOT(rx_AddNewChannelToGraph(int, int)));
connect(grphW, SIGNAL(tx_RemoveChannelToGraph(int, int)), loggerClass, SLOT(rx_RemoveChannelToGraph(int, int)));
connect(grphW, SIGNAL(tx_giveMeEnablesChannels()), loggerClass, SLOT(rx_giveMeEnablesChannels()));
//connect(grphW, SIGNAL(tx_loggingStartStop(bool, QString)), loggerClass, SLOT(rx_loggingStartStop(bool, QString)));
//connect(grphW, SIGNAL(tx_generate_ThisGUI(GUI_WIN)), this, SLOT(rx_generate_ThisGUI(GUI_WIN)));
connect(grphW, SIGNAL(tx_ClosingWindow_graphWin()), this, SLOT(rx_ClosingWindow_graphWin()));
connect(loggerClass, SIGNAL(tx_EnableChannelsAre(int)), grphW, SLOT(rx_EnableChannelsAre(int)));
connect(loggerClass, SIGNAL(tx_GraphChannelValue(int,int,float)), grphW, SLOT(rx_GraphChannelValue(int,int,float)));
connect(loggerClass, SIGNAL(tx_ramdomOP(int,float, QString)), grphW, SLOT(rx_ramdomOP(int,float, QString)));
grphW->setModal(true);
grphW->show();
}
void MainHandler::generate_ConfigCHWin()
{
configCH = new ConfigChWin();
connect(configCH, SIGNAL(tx_setChannelNewSettings(int,float,CHANNEL_PGA,CHANNEL_TYPE,CHANNEL_REFERENCE, bool)), loggerClass, SLOT(rx_setChannelNewSettings(int,float,CHANNEL_PGA,CHANNEL_TYPE,CHANNEL_REFERENCE, bool)));
connect(configCH, SIGNAL(tx_ClosingWindow_ConfigCHWin()), this, SLOT(rx_ClosingWindow_ConfigCHWin()));
connect(configCH, SIGNAL(tx_generate_ThisGUI(GUI_WIN)), this, SLOT(rx_generate_ThisGUI(GUI_WIN)));
connect(configCH, SIGNAL(tx_giveMechannelSettings(int)), loggerClass, SLOT(rx_giveMechannelSettings(int)));
connect(configCH, SIGNAL(tx_ChannelSettingsWindowIsOpen(bool)), loggerClass, SLOT(rx_ChannelSettingsWindowIsOpen(bool)));
connect(configCH, SIGNAL(tx_startReadingTimer(bool)), loggerClass, SLOT(rx_startReadingTimer(bool)));
connect(configCH, SIGNAL(tx_setSampleTime(int)), loggerClass, SLOT(rx_setSampleTime(int)));
connect(loggerClass, SIGNAL(tx_EnableChannelsAre(int)), configCH, SLOT(rx_EnableChannelsAre(int)));
connect(loggerClass, SIGNAL(tx_ramdomOP(int,float, QString)), configCH, SLOT(rx_ramdomOP(int,float, QString)));
connect(loggerClass, SIGNAL(tx_ChannelOLDSettings(int,float,CHANNEL_PGA,CHANNEL_TYPE,CHANNEL_REFERENCE, bool)), configCH, SLOT(rx_ChannelOLDSettings(int,float,CHANNEL_PGA,CHANNEL_TYPE,CHANNEL_REFERENCE, bool)));
connect(loggerClass, SIGNAL(tx_channel_Value_Config(int, uint32_t, float,float)), configCH, SLOT(rx_ChannelValue_Config(int, uint32_t, float,float)));
configCH->setModal(true);
configCH->show();
}
void MainHandler::generate_DebugWin()
{
debgWn = new NewDebug();
// connect(configCH, SIGNAL(tx_setChannelNewSettings(int,float,float,CHANNEL_TYPE,CHANNEL_REFERENCE)), loggerClass, SLOT(rx_setChannelNewSettings(int,float,float,CHANNEL_TYPE,CHANNEL_REFERENCE)));
connect(debgWn, SIGNAL(tx_ClosingWindow_DebugWin()), this, SLOT(rx_ClosingWindow_DebugWin()));
connect(debgWn, SIGNAL(tx_generate_ThisGUI(GUI_WIN)), this, SLOT(rx_generate_ThisGUI(GUI_WIN)));
debgWn->setModal(true);
debgWn->show();
}
// ----------------- Closing Windows --------------------
void MainHandler::rx_ClosingWindow_FirstWin(bool shutDown)
{
qDebug()<<" First Window is CLosed ::"<<shutDown;
firstWin->hide();
if(shutDown) {
QCoreApplication::quit();
}
}
void MainHandler::rx_ClosingWindow_logConfig()
{
qDebug()<<" LogConfig Window is CLosed ";
logConfig->hide();
}
void MainHandler::rx_ClosingWindow_graphWin()
{
qDebug()<<" GraphWindow Window is CLosed ";
//grphW->hide();
grphW->~graphWin();
grphW = nullptr;
}
void MainHandler::rx_ClosingWindow_ConfigCHWin()
{
qDebug()<<" Conifg Channel Window is CLosed ";
//configCH->hide();
configCH->~ConfigChWin();
configCH = nullptr;
}
void MainHandler::rx_ClosingWindow_DebugWin()
{
qDebug()<<" Debug Window is CLosed ";
debgWn->hide();
}
void MainHandler::GUIobjectInitializer()
{
}