/
MReadiness.cpp
562 lines (488 loc) · 23.6 KB
/
MReadiness.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
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
#include "MReadiness.h"
#include "mainwindow.h"
#include "funcs.h"
#include <QApplication>
#include <QGraphicsEllipseItem>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QIcon>
#include <QLabel>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QProgressBar>
#include <QRadialGradient>
#include <QScrollArea>
#include <QStatusBar>
//============================================================================================
MReadiness::MReadiness(QWidget *parent) :
// QSplitter(Qt::Vertical, parent)
QSplitter(Qt::Horizontal, parent)
{
SMessageBoxTitle = QCoreApplication::instance()->applicationName()+": Readiness";
// Init();
}
//--------------------------------------------------------------------------------------------
MReadiness::~MReadiness()
{
//PPort->close();
}
//--------------------------------------------------------------------------------------------
/*
MainWindow* MReadiness::GetPMainWnd()
{
MainWindow* pMainWindow;
foreach(QWidget* pwidget, QApplication::topLevelWidgets()) {
pMainWindow = qobject_cast<MainWindow*>(pwidget);
if(pMainWindow != NULL) break;
}
// MainWindow* pMainWindow = qobject_cast<MainWindow*>(parentWidget()->parentWidget());
if(pMainWindow == NULL) {
// QString s; s.sprintf("ind = %d", ind);
QMessageBox msgBox(QMessageBox::Critical, SMessageBoxTitle, "GetPMainWnd() == NULL"); msgBox.exec();
}
return pMainWindow;
}
*/
//--------------------------------------------------------------------------------------------
void MReadiness::Init()
{
//===#### I: Left (Ekranoplan): ####===
QGraphicsScene* PSceneEkranoplan = new QGraphicsScene(this);//PMainSplitter); // scene.addText("Hello, world!");
PSceneEkranoplan->addPixmap(QPixmap(":/Ekranoplan.png"));
//scene.setSceneRect(0,0, 100,100);
QGraphicsView* PViewEkranoplan = new QGraphicsView(PSceneEkranoplan, this);
//view.setBaseSize(200,500);
// PMainSplitter->addWidget(PViewEkranoplan);
//++ addWidget(PViewEkranoplan);
//int ind = psplitter->indexOf(&view);
//QString s; s.sprintf("ind = %d", ind);
//QMessageBox msgBox; msgBox.setText(s); msgBox.exec();
//psplitter->handle(0)->setFixedWidth(100);
//psplitter->handle(0)->setMaximumWidth(100);
//psplitter->setHandleWidth(50);
//psplitter->resize(1200,500);
// InitReadiness(this, pSplitter);
// scene.addEllipse(QRectF(180,360, 40,40),QPen(),QBrush(QColor(255,0,0,255)));
int xc = 200; int yc = 380; int rc = 25;
QRadialGradient radialGradTestSpot(QPointF(xc, yc), rc);
// radialGradTestSpot.setColorAt(0, Qt::red);
radialGradTestSpot.setColorAt(0, QColor(255, 0, 0, 155)); // 255
// radialGrad.setColorAt(0.5, Qt::blue);
// radialGradTestSpot.setColorAt(1, Qt::green);
radialGradTestSpot.setColorAt(1, QColor(0, 255, 0, 155));
//radialGradTestSpot.setColorAt(0, QColor(20, 255, 180, 255)); // 255
//radialGradTestSpot.setColorAt(0.6, QColor(180, 255, 180, 155)); // 255
//radialGradTestSpot.setColorAt(1, QColor(220, 0, 0, 100)); // 255
QGraphicsEllipseItem* PTestSpot = PSceneEkranoplan->addEllipse(QRectF(xc-rc,yc-rc, 2*rc,2*rc),QPen(Qt::NoPen),QBrush(radialGradTestSpot));
//===#### II: 1) Right (Channels): ####===
QSplitter* pSplitterReadiness = new QSplitter(Qt::Vertical, this);//pSplitter);
//++ addWidget(pSplitterReadiness);
QList<int> list; list << 150 << 200; setSizes(list); list.clear();
//=== 1) ReadinessTest:
// scrollArea = new QScrollArea(centralWidget);
QScrollArea* pScrollAreaTest = new QScrollArea(pSplitterReadiness);//this);
// pScrollAreaTest->setObjectName(QStringLiteral("ScrollAreaTest"));
//+ pScrollAreaTest->setGeometry(QRect(40, 70, 611, 111));
pScrollAreaTest->setWidgetResizable(true);
//pScrollAreaTest->setBaseSize(30,40);
//addWidget(pScrollAreaTest);
QWidget* pScrollAreaTestContents = new QWidget(pSplitterReadiness);//this);
pScrollAreaTestContents->setObjectName(QStringLiteral("ScrollAreaTestContents"));
//+ pScrollAreaTestContents->setGeometry(QRect(0, 0, 609, 109));
//pScrollAreaTestContents->setBaseSize(30,40);
// pScrollAreaTestContents->setMinimumSize(609,109);
//pScrollAreaTest->setWidget(pScrollAreaTestContents);
//pScrollAreaTestContents->setParent(pScrollAreaTest);
// pScrollAreaTestContents->setMinimumSize(609,109);
QRect rect = FillReadinessTest(pScrollAreaTestContents);
pScrollAreaTestContents->setMinimumSize(rect.right()+3,rect.bottom()+3);
//pScrollAreaTest->adjustSize();
//pScrollAreaTest->setMinimumWidth(100);
//pScrollAreaTest->setMaximumWidth(200);
//pScrollAreaTestContents->setMinimumWidth(600);
//pScrollAreaTestContents->setMaximumWidth(200);
pScrollAreaTest->setWidget(pScrollAreaTestContents);
//=== 2) ReadinessStart:
QScrollArea* pScrollAreaStart = new QScrollArea(pSplitterReadiness);//this);
// pScrollAreaStart->setObjectName(QStringLiteral("ScrollAreaStart"));
pScrollAreaStart->setGeometry(QRect(40, 70, 611, 111));
pScrollAreaStart->setWidgetResizable(true);
//addWidget(pScrollAreaStart);
QWidget* pScrollAreaStartContents = new QWidget(pSplitterReadiness);//this);
// pScrollAreaStartContents->setObjectName(QStringLiteral("ScrollAreaStartContents"));
// pScrollAreaStartContents->setGeometry(QRect(0, 0, 609, 109));
// pScrollAreaStartContents->setMinimumSize(609,109);
rect = FillReadinessStart(pScrollAreaStartContents);
pScrollAreaStartContents->setMinimumSize(rect.right()+3,rect.bottom()+3);
pScrollAreaStart->setWidget(pScrollAreaStartContents);
//===
// pSplitterReadiness->addWidget(pScrollAreaTest);
// pSplitterReadiness->addWidget(pScrollAreaStart);
// list << 700 << 200; pSplitterReadiness->setSizes(list);
//++ pSplitterReadiness->addWidget(pScrollAreaTest);
//++ pSplitterReadiness->addWidget(pScrollAreaStart);
list << 800 << 200; pSplitterReadiness->setSizes(list); list.clear();
//pScrollAreaTest->setWidget(listview);
//pScrollAreaTest->setWidget(treeview);
//pScrollAreaTest->setWidget(textedit);
// MTestChannel* pTestCannel = new MTestChannel;
//=================
//=================
/*
// QSerialPort* pSerialPort = new QSerialPort(this);
QString sp;
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
sp += QObject::tr("Port: ") + info.portName() + "\n"
+ QObject::tr("Location: ") + info.systemLocation() + "\n"
+ QObject::tr("Description: ") + info.description() + "\n"
+ QObject::tr("Manufacturer: ") + info.manufacturer() + "\n"
+ QObject::tr("Vendor Identifier: ") + (info.hasVendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString()) + "\n"
+ QObject::tr("Product Identifier: ") + (info.hasProductIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()) + "\n"
+ QObject::tr("Busy: ") + (info.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) + "\n";
}
QMessageBox msgBox; msgBox.setText(sp); msgBox.exec();
*/
/*++++
//=================
// QSerialPort* pSerialPort = new QSerialPort(this);
// QString sp;
QSlider* pSlider = new QSlider(pScrollAreaTest);
//pSlider->setObjectName(QStringLiteral("verticalSlider"));
pSlider->setOrientation(Qt::Vertical);
pSlider->setGeometry(QRect(600, 120, 16, 160));
pSlider->setMinimum(0);
pSlider->setMaximum(255);
pSlider->setSingleStep(1);
pSlider->setPageStep(25);
pSlider->setValue(0);
pSlider->setTickPosition(QSlider::TicksAbove);
QString portName("COM3");
PPort = new QSerialPort(this);
PPort->setPortName(portName);
if(PPort->open(QIODevice::WriteOnly)) {
PPort->setBaudRate(QSerialPort::Baud9600);
PPort->setDataBits(QSerialPort::Data8);
PPort->setParity(QSerialPort::NoParity);
PPort->setStopBits(QSerialPort::OneStop);
PPort->setFlowControl(QSerialPort::NoFlowControl);
QMessageBox msgBox; msgBox.setText("Port \""+portName+"\" is open"); msgBox.exec();
}
else {
QMessageBox msgBox; msgBox.setText("Port \""+portName+"\" is not open"); msgBox.exec();
}
connect(pSlider, SIGNAL(valueChanged(int)), this, SLOT(SlotArduino_ControlLED(int)));
connect(PPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(SlotPortError(QSerialPort::SerialPortError)));
//=================
*/
}
//............................................................................................
/*++++
void MReadiness::SlotArduino_ControlLED(int value)
{
if(value < 0 || value > 255) return;
//==Qt 5.1.1(x86):
//byte bytes[1]; bytes[0] = (byte)value;
//==Qt 5.2.0(x64):
uchar bytes[1]; bytes[0] = (uchar)value;
//QByteArray ba(1, bvalue);
//QString sv; sv.sprintf("%d",value);
//GetPMainWnd()->statusBar()->showMessage(sv);
//QMessageBox msgBox; msgBox.setText(s); msgBox.exec();
//PPort->write(sv.toStdString().c_str());
PPort->write((char*)bytes, 1);
}
//............................................................................................
void MReadiness::SlotPortError(QSerialPort::SerialPortError ierror)
{
if(ierror == 0) return;
QString s; s.sprintf("ierror = %d\n", ierror); s += PPort->errorString();
QMessageBox msgBox; msgBox.setText(s); msgBox.exec();
*/
/*
QSerialPort::NoError 0 No error occurred.
QSerialPort::DeviceNotFoundError 1 An error occurred while attempting to open an non-existing device.
QSerialPort::PermissionError 2 An error occurred while attempting to open an already opened device by another process or a user not having enough permission and credentials to open.
QSerialPort::OpenError 3 An error occurred while attempting to open an already opened device in this object.
QSerialPort::ParityError 4 Parity error detected by the hardware while reading data.
QSerialPort::FramingError 5 Framing error detected by the hardware while reading data.
QSerialPort::BreakConditionError 6 Break condition detected by the hardware on the input line.
QSerialPort::WriteError 7 An I/O error occurred while writing the data.
QSerialPort::ReadError 8 An I/O error occurred while reading the data.
QSerialPort::ResourceError 9 An I/O error occurred when a resource becomes unavailable, e.g. when the device is unexpectedly removed from the system.
QSerialPort::UnsupportedOperationError 10 The requested device operation is not supported or prohibited by the running operating system.
QSerialPort::UnknownError 11 An unidentified error occurred.
*/
//}
//--------------------------------------------------------------------------------------------
QRect MReadiness::FillReadinessTest(QWidget* pScrollAreaTestContents)
{
QRect rectReadinessTest; QRect rect;
int yTopChannel = 0;
int count = GetPMainWnd()->GetPListParamsReadinessChannels()->count();
for(int i = 0; i < count; i++) {
// rect = AddReadinessTestChannel(pScrollAreaTestContents, yTopChannel,// "Engine.png",
// &(*GetPMainWnd()->GetPListParamsReadinessChannels())[i]);
MReadinessTestChannel* pReadinessTestChannel = new MReadinessTestChannel(pScrollAreaTestContents, yTopChannel,// namePixmapFileChannel,
&(*GetPMainWnd()->GetPListParamsReadinessChannels())[i]);
// pReadinessTestChannel->setObjectName(QStringLiteral("MReadinessTestChannel"));
// pReadinessTestChannel->setGeometry(QRect(0,0, 1,1));
ListReadinessTestChannels << pReadinessTestChannel;
// connect(pReadinessTestChannel, SIGNAL(SignalStartTestChannel()), this, SLOT(SlotStartTestChannel()));
connect(pReadinessTestChannel, SIGNAL(SignalResultTestChannel(bool)), this, SLOT(SlotResultTestChannel(bool)));
rect = pReadinessTestChannel->GetRectChannel();
yTopChannel += rect.height() + 10;
if(i == 0) rectReadinessTest = rect;
else rectReadinessTest |= rect;
}
/*
QList<QString> listParamsNameTest;
QList<int> listParamsRangeTest;
QString sTextTest0(" State of Execution\n");
QString sTextTest;
//=1)= Right Engine:
listParamsNameTest << "Max RPM:" << "Min RPM:";
listParamsRangeTest << 400 << 600 << 8 << 12;
sTextTest = sTextTest0;
sTextTest += "Max Voltage:\t20 V\n";
sTextTest += listParamsNameTest[0]; sTextTest += "\t\n";
sTextTest += "Min Voltage:\t5 V\n";
sTextTest += listParamsNameTest[1]; sTextTest += "\t";
yBottomChannel = AddReadinessTestChannel(pScrollAreaTestContents, yBottomChannel+10, "Right Engine", "Engine.png",
&sTextTest, &listParamsNameTest, &listParamsRangeTest);
listParamsNameTest.clear(); listParamsNameTest.clear(); sTextTest.clear();
*/
//=2)= Left Engine:
/*
listParamsNameTest << "Max RPM:" << "Min RPM:";
listParamsRangeTest << 400 << 600 << 8 << 12;
sTextTest = sTextTest0;
sTextTest += "Max Voltage:\t20 V\n";
sTextTest += listParamsNameTest[0]; sTextTest += "\t\n";
sTextTest += "Min Voltage:\t5 V\n";
sTextTest += listParamsNameTest[1]; sTextTest += "\t";
yBottomChannel = AddReadinessTestChannel(pScrollAreaTestContents, yBottomChannel+10, "Left Engine", "Engine.png",
&sTextTest, &listParamsNameTest, &listParamsRangeTest);
listParamsNameTest.clear(); listParamsNameTest.clear(); sTextTest.clear();
*/
return rectReadinessTest;
}
//--------------------------------------------------------------------------------------------
/*
//int MReadiness::AddReadinessTestChannel(QWidget* pParent, const int yTopChannel, const char* nameChannel, const char* namePixmapFileChannel,
// QString* pTextTest, QList<QString>* pListParamsNameTest, QList<int>* pListParamsRangeTest)
QRect MReadiness::AddReadinessTestChannel(QWidget* pParent, const int yTopChannel, //const char* namePixmapFileChannel,
// QString* pTextTest, QList<QString>* pListParamsChannel)
QList<QString>* pListParamsChannel)
{
MReadinessTestChannel* pReadinessTestChannel = new MReadinessTestChannel(pParent, yTopChannel,// namePixmapFileChannel,
// pTextTest, pListParamsChannel);
pListParamsChannel);
pReadinessTestChannel->setObjectName(QStringLiteral("MReadinessTestChannel"));
// pReadinessTestChannel->setGeometry(QRect(0,0, 1,1));
ListReadinessTestChannels << pReadinessTestChannel;
// connect(pReadinessTestChannel, SIGNAL(SignalStartTestChannel()), this, SLOT(SlotStartTestChannel()));
connect(pReadinessTestChannel, SIGNAL(SignalResultTestChannel(bool)), this, SLOT(SlotResultTestChannel(bool)));
// ListReadinessTestChannels << new MReadinessTestChannel(pParent, yTopChannel, namePixmapFileChannel,
// pTextTest, pListParamsChannel);
// int count = ListReadinessTestChannels.count();
// PListReadinessTestChannel[count-1]->
// return 140;
return pReadinessTestChannel->GetRectChannel();
}
*/
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
QRect MReadiness::FillReadinessStart(QWidget* pScrollAreaStartContents)
{
QRect rectReadinessStart; QRect rect;
//= Button "START":
PPushButtonStart = new QPushButton(pScrollAreaStartContents);
// PPushButtonStart->setObjectName(QStringLiteral("PushButton"));
rect = QRect(20, 30, 61, 51); rectReadinessStart = rect;
PPushButtonStart->setGeometry(rect);
// PPushButtonStart->setAutoDefault(true);
// PPushButtonStart->setDefault(true);
PPushButtonStart->setText(QApplication::translate("MainWindow", "START", 0));
//PPushButtonStart->setFlat(false);
connect(PPushButtonStart, SIGNAL(clicked()), this, SLOT(SlotStart()));
/*
iListView = new QListView(this);
//Creating a standard item model
iStandardModel = new QStandardItemModel(this);
//First item
QStandardItem* item1 = new QStandardItem(QIcon("c:\\data\\Nokia- logo.bmp"),"First Item");
//Second item
QStandardItem* item2 = new QStandardItem(QIcon("c:\\data\\sample.bmp"),"Second item");
//third item without icon
QStandardItem* item3 = new QStandardItem("Without icon item");
//Appending the items into model
iStandardModel->appendRow(item1);
iStandardModel->appendRow(item2);
iStandardModel->appendRow(item3);
//Setting the icon size
iListView->setIconSize(QSize(40,30));
//Setting the model
iListView->setModel(iStandardModel);
//Setting listview geometry
iListView->setGeometry(QRect(0,0,240,320));
*/
// QListWidget* pListWidgetEngines; // = new QListWidget(pScrollAreaStartContents);
rect = QRect(100, 30, 121, 101); rectReadinessStart |= rect;
CreateListWidget("Engines", PListWidgetEngines, pScrollAreaStartContents, rect, GetPMainWnd()->GetPListNamesEngines());
rect = QRect(250, 30, 121, 101); rectReadinessStart |= rect;
CreateListWidget("Sensors", PListWidgetSensors, pScrollAreaStartContents, rect, GetPMainWnd()->GetPListNamesSensors());
rect = QRect(400, 30, 121, 101); rectReadinessStart |= rect;
CreateListWidget("ServoMotors", PListWidgetServoMotors, pScrollAreaStartContents, rect, GetPMainWnd()->GetPListNamesServoMotors());
// AddReadinessStartListItem(pListWidgetEngines, GetPMainWnd()->GetPListNamesEngine());
// AddReadinessStartListItem(pListWidgetSensors, GetPMainWindow()->GetPListNamesSensor());
// AddReadinessStartListItem(pListWidgetServoMotors, GetPMainWindow()->GetPListNamesServoMotor());
//= Button "Telemetry":
PPushButtonTelemetry = new QPushButton(pScrollAreaStartContents);
// PPushButtonTelemetry->setObjectName(QStringLiteral("PushButton"));
rect = QRect(535, 10, 60, 30); rectReadinessStart |= rect;
PPushButtonTelemetry->setGeometry(rect);
PPushButtonTelemetry->setAutoDefault(true);
// PPushButtonStart->setDefault(true);
PPushButtonTelemetry->setText(QApplication::translate("MainWindow", "Telemetry", 0));
connect(PPushButtonTelemetry, SIGNAL(clicked()), GetPMainWnd(), SLOT(SlotSwitchToTelemetry()));
return rectReadinessStart;
}
//--------------------------------------------------------------------------------------------
void MReadiness::CreateListWidget(const char* nameList, QListWidget*& pListWidget, QWidget* pParent, QRect rectList,
QList<QString>* pListNames)
{
QRect rect; rect.setRect(rectList.left()+18,rectList.top()-20, 80,16);
/*
QLineEdit* pLineEditName = new QLineEdit(pParent);
pLineEditName->setObjectName(QStringLiteral("LineEditName"));
pLineEditName->setGeometry(rect);
pLineEditName->setFrame(false);
pLineEditName->setReadOnly(true);
pLineEditName->setStyleSheet(QLatin1String("background: transparent;"));
pLineEditName->setText(nameList);
pLineEditName->setTextInteractionFlags(Qt::NoTextInteraction);
*/
QLabel* pNameList = new QLabel(pParent);
// pNameList->setObjectName(QStringLiteral("NameList"));
pNameList->setGeometry(rect);
pNameList->setText(QApplication::translate("MainWindow", nameList, 0));
pListWidget = new QListWidget(pParent);
// pListWidget->setObjectName(QStringLiteral("listWidget"));
pListWidget->setGeometry(rectList);
pListWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
pListWidget->setResizeMode(QListView::Adjust);
pListWidget->setFrameShape(QFrame::WinPanel);
pListWidget->setFrameShadow(QFrame::Sunken);
// pListWidgetEngines->setFocusPolicy(Qt::NoFocus);
// pListWidgetEngines->setSelectionRectVisible(false);
pListWidget->setSelectionMode(QAbstractItemView::NoSelection);
QListWidgetItem* pItem;
int count = pListNames->count();
for(int i = 0; i < count; i++) {
pItem = new QListWidgetItem(QIcon(QString::fromUtf8(":/StartCircleEmpty.png")), (*pListNames)[i], pListWidget);
// pListWidget->addItem(pItem);
}
}
//--------------------------------------------------------------------------------------------
/*
void MReadiness::AddReadinessStartListItem(QListWidget* pListWidget, QList<QString>* pListNamesDevice)
{
QListWidgetItem* pItem;
int count = pListNamesDevice->count();
for(int i = 0; i < count; i++) {
pItem = new QListWidgetItem(QIcon(QString::fromUtf8("StartCircleEmpty.png")), (*pListNamesDevice)[i], pListWidget);
// pListWidget->addItem(pItem);
}
}
*/
//--------------------------------------------------------------------------------------------
void MReadiness::SlotStart()
{
//QMessageBox msgBox; msgBox.setText("void MReadiness::Start()"); msgBox.exec();
PPushButtonStart->setEnabled(false);
// PPushButtonStart->setDown(true);
PPushButtonTelemetry->setEnabled(false);
// GetPMainWnd()->GetPArduinoConnector()->SetTypeModeReadiness();
emit SignalSetTypeModeReadiness();
BResultTests = true;
ITestChannel = -1;
for(int i = 0; i < ListReadinessTestChannels.count(); i++) {
ListReadinessTestChannels[i]->InitState();
GetListWidgetItem(ListReadinessTestChannels[i]->GetNameChannel())->setIcon(QIcon(QString::fromUtf8(":/StartCircleEmpty.png")));
}
StartNextTestChannel();
}
//--------------------------------------------------------------------------------------------
void MReadiness::StartNextTestChannel()
{
ITestChannel += 1;
// QListWidgetItem* pItem;
// int count = ListReadinessTestChannels.count();
if(ITestChannel < ListReadinessTestChannels.count()) {
// pItem = GetListWidgetItem(ListReadinessTestChannels[ITestChannel]->GetNameChannel());
// if(ListReadinessTestChannels[ITestChannel]->Test()) {
//QString s; s.sprintf("ITestChannel = %d\nListReadinessTestChannels.count() = %d", ITestChannel,ListReadinessTestChannels.count());
//QMessageBox msgBox; msgBox.setText(s); msgBox.exec();
ListReadinessTestChannels[ITestChannel]->Test();
/*
ListReadinessTestChannels[i]->TestPassed();
pItem->setIcon(QIcon(QString::fromUtf8("StartPassed.png")));
}
else {
ListReadinessTestChannels[i]->TestNotPassed();
pItem->setIcon(QIcon(QString::fromUtf8("StartNotPassed.png")));
QMessageBox msgBox(QMessageBox::Critical, SMessageBoxTitle, "===== TROUBLE! ====="); msgBox.exec();
break;
}
*/
}
else {
PPushButtonStart->setEnabled(true);
//PPushButtonTelemetry->setEnabled(BResultTests);
PPushButtonTelemetry->setEnabled(true);
}
}
//--------------------------------------------------------------------------------------------
void MReadiness::SlotResultTestChannel(bool bResult)
{
BResultTests &= bResult;
QListWidgetItem* pItem = GetListWidgetItem(ListReadinessTestChannels[ITestChannel]->GetNameChannel());
if(bResult) {
// ListReadinessTestChannels[i]->TestPassed();
pItem->setIcon(QIcon(QString::fromUtf8(":/StartPassed.png")));
}
else {
// ListReadinessTestChannels[i]->TestNotPassed();
pItem->setIcon(QIcon(QString::fromUtf8(":/StartNotPassed.png")));
// QMessageBox msgBox(QMessageBox::Critical, SMessageBoxTitle, "===== TROUBLE! ====="); msgBox.exec();
// break;
}
//QMessageBox msgBox(QMessageBox::Critical, SMessageBoxTitle, "===== TROUBLE! ====="); msgBox.exec();
StartNextTestChannel();
}
//--------------------------------------------------------------------------------------------
QListWidgetItem* MReadiness::GetListWidgetItem(QString nameItem)
{
QListWidgetItem* pItem;
pItem = GetListWidgetItem(PListWidgetEngines, nameItem);
if(pItem != NULL) return pItem;
pItem = GetListWidgetItem(PListWidgetSensors, nameItem);
if(pItem != NULL) return pItem;
pItem = GetListWidgetItem(PListWidgetServoMotors, nameItem);
if(pItem == NULL) {
QMessageBox msgBox(QMessageBox::Warning, SMessageBoxTitle, "GetListWidgetItem == NULL"); msgBox.exec();
}
return pItem;
}
//--------------------------------------------------------------------------------------------
QListWidgetItem* MReadiness::GetListWidgetItem(QListWidget* pListWidget, QString nameItem)
{
QListWidgetItem* pItem;
int count = pListWidget->count();
for(int i = 0; i < count; i++) {
pItem = pListWidget->item(i);
if(pItem->text() == nameItem) return pItem;
}
return NULL;
}
//--------------------------------------------------------------------------------------------