-
Notifications
You must be signed in to change notification settings - Fork 46
/
DutInfoWidget.cpp
120 lines (90 loc) · 2.77 KB
/
DutInfoWidget.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
#include "DutInfoWidget.h"
#include <QDebug>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGroupBox>
#include <QButtonGroup>
DutInfoWidget::DutInfoWidget(SessionManager *session, QWidget *parent) : QWidget(parent), _session(session)
{
QVBoxLayout* mainLayout = new QVBoxLayout;
setLayout(mainLayout);
QGroupBox* widgetBox = new QGroupBox("DUT information");
widgetBox->setMinimumWidth(300);
widgetBox->setMinimumHeight(298);
// widgetBox->setFixedSize(300, 258);
mainLayout->addWidget(widgetBox);
mainLayout->addStretch();
widgetBox->setStyleSheet("QGroupBox{color: #595959; font-size:10pt; font-weight: bold;}");
QVBoxLayout* labelsLayout = new QVBoxLayout;
widgetBox->setLayout(labelsLayout);
setStyleSheet("QLabel{color: #595959;}");
_slot = new QLabel;
_slot->setText(_slotTemplate.arg(""));
labelsLayout->addWidget(_slot);
_id = new QLabel;
_id->setText(_idTemplate.arg(""));
labelsLayout->addWidget(_id);
_status = new QLabel;
_status->setText(_statusTemplate.arg(""));
labelsLayout->addWidget(_status);
_errorDesc = new QLabel;
labelsLayout->addWidget(_errorDesc);
_checkState = new QLabel;
labelsLayout->addWidget(_checkState);
labelsLayout->addStretch();
for (int no = 1; no < 16; no++)
{
_duts.insert(no, dutTemplate);
}
}
void DutInfoWidget::showDutInfo(int no)
{
if(no < 1)
return;
auto dut = _duts[no];
_slot->setText(_slotTemplate.arg(no));
_id->setText(_idTemplate.arg(dut["id"].toString()));
QString stateDescription;
switch (dut["state"].toInt())
{
case DutState::inactive:
stateDescription = "The device is not avaliable now.";
break;
case DutState::untested:
stateDescription = "The device is not tested yet.</p>";
break;
case DutState::tested:
stateDescription = "The device has been tested successfully.";
break;
case DutState::warning:
stateDescription = "An error occures during the testing.";
break;
}
_status->setText(_statusTemplate.arg(stateDescription));
// if(!dut->getErrorList().isEmpty())
// {
// _errorDesc->setText(_errorDescTemplate.arg(dut->getErrorList().last()));
// }
// else
// {
// _errorDesc->setText("");
// }
if(dut["checked"].toBool())
{
_checkState->setText("CHECKED for a further testing.");
}
else
{
_checkState->setText("NOT CHECKED for a further testing.");
}
}
void DutInfoWidget::updateDut(Dut dut)
{
QMutexLocker locker(&_updateMutex);
_duts[dut["no"].toInt()] = dut;
showDutInfo(dut["no"].toInt());
}
void DutInfoWidget::setDutChecked(int no, bool checked)
{
_duts[no]["checked"] = checked;
}