-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyellowdolphindownloader.cpp
More file actions
302 lines (248 loc) · 10.6 KB
/
yellowdolphindownloader.cpp
File metadata and controls
302 lines (248 loc) · 10.6 KB
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#include "yellowdolphindownloader.h"
YellowDolphinDownloader::YellowDolphinDownloader(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
this->refresh_interfaces_list();
//Register Type for slot/signal usage
int i= qRegisterMetaType<Fluke::Fluke189::RCT_QD0>();
std::cout<<"Reg:"<<i<<std::endl;
i=qRegisterMetaType<Fluke::Fluke189QD0Logging::Fluke189Value_t>();
std::cout<<"Reg:"<<i<<std::endl;
//primary plot
primaryPlot =new QFlukePlotter();
primaryPlot->setCanvasBackground(Qt::black);
primaryValueCurve=new QFlukePlotCurve();
primaryMaxCurve=new QFlukePlotCurve();
primaryMinCurve=new QFlukePlotCurve();
primaryAvgCurve=new QFlukePlotCurve();
primaryValueCurve->attach(primaryPlot);
primaryMaxCurve->attach(primaryPlot);
primaryMinCurve->attach(primaryPlot);
primaryAvgCurve->attach(primaryPlot);
primaryValueCurve->setPen(QPen(Qt::yellow,1));
primaryMaxCurve->setPen(QPen(Qt::red,1));
primaryMinCurve->setPen(QPen(Qt::blue,1));
primaryAvgCurve->setPen(QPen(QColor(255,255,0,255),1));
primaryValueCurve->setSymbol(new QwtSymbol(QwtSymbol::XCross,QBrush(Qt::transparent),QPen(Qt::yellow,1),QSize(7,7)));
primaryMaxCurve->setSymbol(new QwtSymbol(QwtSymbol::Triangle,QBrush(Qt::transparent),QPen(Qt::red,1),QSize(7,7)));
primaryMinCurve->setSymbol(new QwtSymbol(QwtSymbol::DTriangle,QBrush(Qt::transparent),QPen(Qt::blue,1),QSize(7,7)));
primaryAvgCurve->setSymbol(new QwtSymbol(QwtSymbol::Diamond,QBrush(Qt::transparent),QPen(QColor(255,255,0,100),1),QSize(7,7)));
//secondary plot
secondaryPlot =new QFlukePlotter();
secondaryPlot->setCanvasBackground(Qt::black);
secondaryValueCurve=new QFlukePlotCurve();
secondaryMaxCurve=new QFlukePlotCurve();
secondaryMinCurve=new QFlukePlotCurve();
secondaryAvgCurve=new QFlukePlotCurve();
secondaryValueCurve->attach(secondaryPlot);
secondaryMaxCurve->attach(secondaryPlot);
secondaryMinCurve->attach(secondaryPlot);
secondaryAvgCurve->attach(secondaryPlot);
secondaryValueCurve->setPen(QPen(Qt::yellow,1));
secondaryMaxCurve->setPen(QPen(Qt::red,1));
secondaryMinCurve->setPen(QPen(Qt::blue,1));
secondaryAvgCurve->setPen(QPen(QColor(255,255,0,255),1));
secondaryValueCurve->setSymbol(new QwtSymbol(QwtSymbol::XCross,QBrush(Qt::transparent),QPen(Qt::yellow,1),QSize(7,7)));
secondaryMaxCurve->setSymbol(new QwtSymbol(QwtSymbol::Triangle,QBrush(Qt::transparent),QPen(Qt::red,1),QSize(7,7)));
secondaryMinCurve->setSymbol(new QwtSymbol(QwtSymbol::DTriangle,QBrush(Qt::transparent),QPen(Qt::blue,1),QSize(7,7)));
secondaryAvgCurve->setSymbol(new QwtSymbol(QwtSymbol::Diamond,QBrush(Qt::transparent),QPen(QColor(255,255,0,100),1),QSize(7,7)));
//Adding plots to window
ui.verticalLayout_VP->addWidget(primaryPlot);
ui.verticalLayout_VP->addWidget(secondaryPlot);
//Connections
connect(this->ui.interfacesCombo,SIGNAL(editTextChanged(QString)),&remlog,SLOT(setInterface(QString)));
connect(&remlog,SIGNAL(handOverSerialResponse(Fluke::Fluke189::RCT_QD0)),&remanalysis,SLOT(getFluke189_QD0(Fluke::Fluke189::RCT_QD0)));
connect(&remanalysis,SIGNAL(updateCurrentValues(QString,QString,QString,QString,QString,QString,QString,QString)),this,SLOT(updateCurrentValues(QString,QString,QString,QString,QString,QString,QString,QString)));
connect(&remanalysis,SIGNAL(setGraph(uint,uint,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t)),this,SLOT(addPlotValues(uint,uint,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t,Fluke::Fluke189QD0Logging::Fluke189Value_t)));
connect(&remanalysis,SIGNAL(primary_reset()), this, SLOT(reset_primary_plot()));
connect(&remanalysis,SIGNAL(secondary_reset()), this, SLOT(reset_secondary_plot()));
connect(this->ui.pushButton_ResetPri,SIGNAL(clicked(void)),&remanalysis,SLOT(reset_primary(void)));
connect(this->ui.pushButton_ResetPri,SIGNAL(clicked(void)),this->ui.label_priMax,SLOT(clear(void)));
connect(this->ui.pushButton_ResetPri,SIGNAL(clicked(void)),this->ui.label_priMin,SLOT(clear(void)));
connect(this->ui.pushButton_ResetPri,SIGNAL(clicked(void)),this->ui.label_priAverage,SLOT(clear(void)));
connect(this->ui.pushButton_resetSec,SIGNAL(clicked(void)),&remanalysis,SLOT(reset_secondary(void)));
connect(this->ui.pushButton_resetSec,SIGNAL(clicked(void)),this->ui.label_secMax,SLOT(clear(void)));
connect(this->ui.pushButton_resetSec,SIGNAL(clicked(void)),this->ui.label_secMin,SLOT(clear(void)));
connect(this->ui.pushButton_resetSec,SIGNAL(clicked(void)),this->ui.label_secAverage,SLOT(clear(void)));
}
YellowDolphinDownloader::~YellowDolphinDownloader()
{
//terminate running processes on quit...
if(remlog.isRunning())
{
remlog.stop();
}
if(remanalysis.isRunning())
{
remanalysis.stop();
}
remlog.wait();
remanalysis.wait();
}
void YellowDolphinDownloader::refresh_interfaces_list()
{
using namespace std;
ui.interfacesCombo->clear();
DIR *hdir;
struct dirent *entry;
hdir = opendir("/dev");
string filename;
unsigned int i=0;
std::cout<<"Searching for interfaces: \n";
while((entry = readdir(hdir)))
{
i++;
filename=entry->d_name;
if((filename.find("ttyS") == 0)||(filename.find("ttyUSB") == 0))
{
filename="/dev/"+filename;
cout<<"Found serial interface: "<<filename<<endl;
ui.interfacesCombo->addItem(filename.c_str());
remlog.setInterface(ui.interfacesCombo->currentText());
}
}
closedir(hdir);
if(i==0)
{
ui.interfacesCombo->addItem("No serial interface found");
}
}
//SLOTS
void YellowDolphinDownloader::on_searchmultimeter_clicked()
{
Fluke::Fluke189 FlukeMM(ui.interfacesCombo->currentText().toStdString());
Fluke::Fluke189::RCT_ID ID_Data = FlukeMM.CMD_ID(true, 0,0);
QString DeviceName(ID_Data.Data()->I_DeviceName);
if(DeviceName == "FLUKE 189")
{
QString ID("Fluke 189 found: ");
ID.append(ID_Data.Data()->I_ID);
ui.searchmultimeter->setText(ID);
}
else
{
ui.searchmultimeter->setText("No Fluke 189 found - Search Again");
}
}
void YellowDolphinDownloader::on_refreshInterfacesBut_clicked()
{
refresh_interfaces_list();
}
void YellowDolphinDownloader::on_downloadButton_clicked()
{
ui.downloadOutputBox->setDisabled(1);
ui.downloadButton->setDisabled(1);
ui.downloadSelectBox->setDisabled(1);
ui.tab_remote->setDisabled(1);
ui.tab_settings->setDisabled(1);
if(ui.radioDownloadSave->isChecked())
{
Fluke::Fluke189 FlukeMM(ui.interfacesCombo->currentText().toStdString());
std::cout<<"Downloading SAVE data.."<<std::endl;
Fluke::Fluke189::RCT_QD4 DATA = FlukeMM.CMD_QD4(true, this, YellowDolphinDownloader::Wrapper_to_progress_bar);
std::cout<<DATA.Data()->I_DataCount<<std::endl;
}
else if(ui.radioDownloadLog->isChecked())
{
Fluke::Fluke189 FlukeMM(ui.interfacesCombo->currentText().toStdString());
std::cout<<"Downloading LOG data.."<<std::endl;
Fluke::Fluke189::RCT_QD0 CURSTAT = FlukeMM.CMD_QD0(true, 0,0);
Fluke::Fluke189::RCT_QD2 DATA;
//Look if LOG is displayed / And if we are not in MEM View -> If so ask User if we shall proceed
if(CURSTAT.Data()->I_QDInfo.I_S_Log && CURSTAT.Data()->I_QDInfo.I_MEMclr!=3)
{
switch( QMessageBox::information( this, "YellowDolphinDownloader - Multimeter in LOG Mode!",
"The Multimeter on this interface is currently in logging mode\n"
"Your download will possibly take longer,\n"
"because of junk data from previous logs.\n"
"(progress bar will not be used)\n\n"
"Do you want go ahead with downloading?\n(NOT RECOMMENDED)",
"&Download", "&Stop",
0, // Enter == button 0
2 ) ) { // Escape == button 2
case 0: // Save clicked or Alt+D pressed or Enter pressed.
DATA = FlukeMM.CMD_QD2(true, 0,0);
break;
}
}
else
{
DATA = FlukeMM.CMD_QD2(true, this, YellowDolphinDownloader::Wrapper_to_progress_bar);
}
}
else if(ui.radioUseBinFileDL->isChecked())
{
std::cout<<"Importing data from binary file.."<<std::endl;
}
else
{
QMessageBox::warning( this, "YellowDolphinDownloader - Error",
"There is no radioButton selected for download!\n"
"Huh? That should never happen - to resolve this select one" );
}
ui.downloadOutputBox->setEnabled(1);
ui.downloadButton->setEnabled(1);
ui.downloadSelectBox->setEnabled(1);
ui.tab_remote->setEnabled(1);
ui.tab_settings->setEnabled(1);
}
void YellowDolphinDownloader::on_pushButton_remlog_query_clicked()
{
static bool on_Noff;
if(!on_Noff)
{
on_Noff=true;
this->ui.pushButton_remlog_query->setText("Stop Querying");
remlog.start();
remanalysis.start();
}
else
{
on_Noff=false;
this->ui.pushButton_remlog_query->setText("Start Querying");
remlog.stop();
remanalysis.stop();
//Wait for Processes to End
//if we do not wait here and the user does a double click
//it will not start again in the current session
//There is no other thing necessary here (like a process) or something...
//It should not take long to end it
remlog.wait();
remanalysis.wait();
}
}
void YellowDolphinDownloader::updateCurrentValues(QString priValue,
QString priMin,
QString priMax,
QString priAvg,
QString secValue,
QString secMin,
QString secMax,
QString secAvg)
{
this->ui.label_priValue->setText(priValue);
this->ui.label_priMin->setText(priMin);
this->ui.label_priMax->setText(priMax);
this->ui.label_priAverage->setText(priAvg);
this->ui.label_secValue->setText(secValue);
this->ui.label_secMin->setText(secMin);
this->ui.label_secMax->setText(secMax);
this->ui.label_secAverage->setText(secAvg);
}
void YellowDolphinDownloader::reset_primary_plot()
{
this->primaryValueCurve->clearData();
this->primaryMinCurve->clearData();
this->primaryMaxCurve->clearData();
this->primaryAvgCurve->clearData();
this->primaryPlot->replot();
}
void YellowDolphinDownloader::reset_secondary_plot()
{
this->secondaryValueCurve->clearData();
this->secondaryMinCurve->clearData();
this->secondaryMaxCurve->clearData();
this->secondaryAvgCurve->clearData();
this->secondaryPlot->replot();
}