-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckwindow.cpp
More file actions
156 lines (125 loc) · 6.31 KB
/
checkwindow.cpp
File metadata and controls
156 lines (125 loc) · 6.31 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
#include "ui_checkwindow.h"
#include "checkwindow.h"
#include "logger.h"
#include <iostream>
#include <QString>
using std::cout;
using std::endl;
void toCheck(uint count, double passError, std::vector<double> listMeasurementState, std::vector<double> listTrueState, uint8_t id);
CheckWindow::CheckWindow(QWidget *parent) :
QDialog(parent),
uiCheck(new Ui::CheckWindow)
{
uiCheck->setupUi(this);
passError = 0.05; // Default passing error = 5%; 5% / 100% = 0.05
uiCheck->passErrorSpinBox->setValue(passError);
uiCheck->passErrorSpinBox->setSingleStep(0.01);
uiCheck->passErrorSpinBox->setRange(0.0, 1.0); // Set the minimum and maximum values
}
CheckWindow::~CheckWindow()
{
delete uiCheck;
}
void CheckWindow::on_toCheckButton_clicked()
{
cout << endl << "Checking steady state..." << endl;
passError = uiCheck->passErrorSpinBox->value();
// Get measurement values
std::vector<double> listFirstMeasurementState, listSecondMeasurementState, listThirdMeasurementState;
for(uint i = 0; i < uint(firstState->count()); ++i)
{
listFirstMeasurementState.push_back(firstState->itemText(int(i)).toDouble());
listSecondMeasurementState.push_back(secondState->itemText(int(i)).toDouble());
listThirdMeasurementState.push_back(thirdState->itemText(int(i)).toDouble());
}
// Get true values
std::vector<double> listFirstTrueState, listSecondTrueState, listThirdTrueState;
if (( LVM_BP->isChecked() ) || ( NLVM_BP->isChecked() ) || ( EVM_BP->isChecked() ))
{
listFirstTrueState = {157.000, 153.900, 150.600};
listSecondTrueState = {124.800, 129.000, 133.000};
toCheck(static_cast <uint> (firstState->count()), passError, listFirstMeasurementState, listFirstTrueState, 0);
toCheck(static_cast <uint> (secondState->count()), passError, listSecondMeasurementState, listSecondTrueState, 1);
}
if ( EFM_BP->isChecked() )
{
listFirstTrueState = {77.000, 74.000, 71.140};
listSecondTrueState = {4.497, 2.524, 0.626};
toCheck(static_cast <uint> (firstState->count()), passError, listFirstMeasurementState, listFirstTrueState, 0);
toCheck(static_cast <uint> (secondState->count()), passError, listSecondMeasurementState, listSecondTrueState, 1);
}
if ( EVM_TP->isChecked() )
{
listFirstTrueState = {122, 97.4, 69.59};
listSecondTrueState = {58.28, 86.23, 111.8};
toCheck(static_cast <uint> (firstState->count()), passError, listFirstMeasurementState, listFirstTrueState, 0);
toCheck(static_cast <uint> (secondState->count()), passError, listSecondMeasurementState, listSecondTrueState, 1);
}
if ( EFM_TP->isChecked() )
{
listFirstTrueState = {0.6646, 0.8024, 0.9853};
listSecondTrueState = {0.8271, 0.6863, 0.5696};
toCheck(static_cast <uint> (firstState->count()), passError, listFirstMeasurementState, listFirstTrueState, 0);
toCheck(static_cast <uint> (secondState->count()), passError, listSecondMeasurementState, listSecondTrueState, 1);
}
if ( EVAP->isChecked() )
{
listFirstTrueState = {160.161, 154.220, 148.736, 143.673};
listSecondTrueState = {164.482, 158.209, 152.418, 147.072};
listThirdTrueState = {283.306, 267.896, 253.671, 240.540};
toCheck(static_cast <uint> (firstState->count()), passError, listFirstMeasurementState, listFirstTrueState, 0);
toCheck(static_cast <uint> (secondState->count()), passError, listSecondMeasurementState, listSecondTrueState, 1);
toCheck(static_cast <uint> (thirdState->count()), passError, listThirdMeasurementState, listThirdTrueState, 2);
}
if ( ACU->isChecked() )
{
listFirstTrueState = {53.364, 39.552, 30.001};
listSecondTrueState = {26.846, 21.992, 18.635};
toCheck(static_cast <uint> (firstState->count()), passError, listFirstMeasurementState, listFirstTrueState, 0);
toCheck(static_cast <uint> (secondState->count()), passError, listSecondMeasurementState, listSecondTrueState, 1);
}
if ( TP_ACU->isChecked() )
{
listFirstTrueState = {122, 97, 69, 67.000, 66.000, 52, 39, 30};
listSecondTrueState = {58, 86, 112};
listThirdTrueState = {27, 23, 20};
toCheck(static_cast <uint> (firstState->count()), passError, listFirstMeasurementState, listFirstTrueState, 0);
toCheck(static_cast <uint> (secondState->count()), passError, listSecondMeasurementState, listSecondTrueState, 1);
toCheck(static_cast <uint> (thirdState->count()), passError, listThirdMeasurementState, listThirdTrueState, 2);
}
}
void CheckWindow::on_toCancelButton_clicked()
{
CheckWindow::reject(); // Return to MainWindow
}
void CheckWindow::setParentToCheck(MainWindow *parentWindow)
{
firstState = parentWindow->findChild<QComboBox *>("firstState");
secondState = parentWindow->findChild<QComboBox *>("secondState");
thirdState = parentWindow->findChild<QComboBox *>("thirdState");
LVM_BP = parentWindow->findChild<QRadioButton *>("LVM_BP");
NLVM_BP = parentWindow->findChild<QRadioButton *>("NLVM_BP");
EVM_BP = parentWindow->findChild<QRadioButton *>("EVM_BP");
EFM_BP = parentWindow->findChild<QRadioButton *>("EFM_BP");
EVM_TP = parentWindow->findChild<QRadioButton *>("EVM_TP");
EFM_TP = parentWindow->findChild<QRadioButton *>("EFM_TP");
EVAP = parentWindow->findChild<QRadioButton *>("EVAP");
ACU = parentWindow->findChild<QRadioButton *>("ACU");
TP_ACU = parentWindow->findChild<QRadioButton *>("TP_ACU");
BP_EVAP = parentWindow->findChild<QRadioButton *>("BP_EVAP");
TP_BP = parentWindow->findChild<QRadioButton *>("TP_BP");
}
void toCheck(uint count, double passError, std::vector<double> listMeasurementState, std::vector<double> listTrueState, uint8_t id)
{
std::vector<double> listErrorState;
for(uint i = 0; i < count; ++i)
{
listErrorState.push_back(listTrueState[i] * passError);
if(listErrorState.at(i) < abs(listTrueState.at(i) - listMeasurementState.at(i)))
{
QString message(QString("Attention! Error has very big value - list(%1)_[%2] = %3\n").arg(id).arg(i).arg(listErrorState.at(i)));
cout << message.toStdString() << endl;
Logger::log(message, LOG_LEVEL_INFO);
}
}
}