functiontestwindow.cpp
6.12 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
#include "functiontestwindow.h"
#include "ui_functiontestwindow.h"
#include <QKeyEvent>
#include "burnertestwindow.h"
#include "componenttestwindow.h"
#include "valvetestwindow.h"
#include "washtestwindow.h"
#include "fantestwindow.h"
#include "gastestwindow.h"
#include "soundplayer.h"
#include "config.h"
#include "yesnopopupdlg.h"
#include "notipopupdlg.h"
#include "usbcheckpopupdlg.h"
#include "fileprocessor.h"
FunctionTestWindow::FunctionTestWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::FunctionTestWindow)
{
ui->setupUi(this);
ui->clockContainer->setParent(ui->upperStack);
setAttribute(Qt::WA_DeleteOnClose);
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
connect(ui->backButton, SIGNAL(clicked(bool)), SLOT(close()));
}
FunctionTestWindow::~FunctionTestWindow()
{
delete ui;
}
void FunctionTestWindow::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000032: // Turn left
onEncoderLeft();
break;
case 0x01000031: // Push
pushed = focusWidget();
break;
case 0x01000030: // Turn right
onEncoderRight();
break;
}
}
void FunctionTestWindow::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000032: // Turn left
onEncoderLeft();
break;
case 0x01000031: // Push
if (focusWidget() == pushed)
onEncoderClicked(pushed);
pushed = NULL;
break;
case 0x01000030: // Turn right
onEncoderRight();
break;
}
}
void FunctionTestWindow::on_burnerTestButton_clicked()
{
BurnerTestWindow *w = new BurnerTestWindow(this);
w->showFullScreen();
}
void FunctionTestWindow::on_componentTestButton_clicked()
{
ComponentTestWindow *w = new ComponentTestWindow(this);
w->showFullScreen();
}
void FunctionTestWindow::on_valveTestButton_clicked()
{
ValveTestWindow *w = new ValveTestWindow(this);
w->showFullScreen();
}
void FunctionTestWindow::on_washTestButton_clicked()
{
WashTestWindow *w = new WashTestWindow(this);
w->showFullScreen();
}
void FunctionTestWindow::on_fanTestButton_clicked()
{
FanTestWindow *w = new FanTestWindow(this);
w->showFullScreen();
}
void FunctionTestWindow::on_gasTestButton_clicked()
{
// GasTestWindow *w = new GasTestWindow(this, udp);
// w->showFullScreen();
}
void FunctionTestWindow::onEncoderLeft()
{
focusPreviousChild();
}
void FunctionTestWindow::onEncoderRight()
{
focusNextChild();
}
void FunctionTestWindow::onEncoderClicked(QWidget *clicked)
{
QPushButton *b = qobject_cast<QPushButton *>(clicked);
if (b)
b->click();
}
bool FunctionTestWindow::readFromRpmFile(QMap<QString, uint32_t> &rpm_map, const QString &filename){
QFile file(filename);
if(file.open(QIODevice::ReadOnly | QIODevice::Text)){
while(!file.atEnd()){
QString line = QString::fromUtf8(file.readLine());
rpm_map[line.section(',',0,0)] = line.section(',',1,1).toUInt();
}
qDebug() << file.fileName() << "read OK!";
qDebug() << "final size " << rpm_map.size();
return true;
}
else {
qDebug() << file.fileName() + " file not found";
}
return false;
}
void FunctionTestWindow::on_adjustBlowerFan_clicked()
{
QString strUsbPath;
Config* cfg = Config::getInstance();
Define::config_item item;
YesNoPopupDlg* yesDlg = new YesNoPopupDlg(this,tr("RPM 설정을 바꾸시겠습니까?"));
yesDlg->exec();
if(yesDlg->result()!=QDialog::Accepted){
return;
}
QMap<QString, uint32_t> rpm_infos;
rpm_infos["config_burner1_pwr1_normal_rpm"] = 4000;
rpm_infos["config_burner1_pwr2_normal_rpm"] = 6000;
rpm_infos["config_burner23_pwr1_normal_rpm"] = 2300;
rpm_infos["config_burner23_pwr2_normal_rpm"] = 6500;
rpm_infos["config_burner1_pwr1_half_rpm"] = 4000;
rpm_infos["config_burner1_pwr2_half_rpm"] = 4500;
rpm_infos["config_burner23_pwr1_half_rpm"] = 2300;
rpm_infos["config_burner23_pwr2_half_rpm"] = 4500;
if(!FileProcessor::detectUSB(strUsbPath)){
UsbCheckPopupDlg* usbDlg = new UsbCheckPopupDlg(this);
usbDlg->exec();
if(usbDlg->result() != QDialog::Accepted){
NotiPopupDlg* notidlg= new NotiPopupDlg(this,tr("USB 메모리가 인식되지 않았습니다."));
notidlg->exec();
return;
}
}
FileProcessor::detectUSB(strUsbPath);
strUsbPath = QString("%1%2").arg(strUsbPath).arg(QString(RPM_INFO_FILE_NAME));
if(readFromRpmFile(rpm_infos,strUsbPath)){
item.d32 = rpm_infos["config_burner1_pwr1_normal_rpm"];
cfg->setConfigValue(Define::config_burner1_pwr1_normal_rpm, item);
item.d32 = rpm_infos["config_burner1_pwr2_normal_rpm"];
cfg->setConfigValue(Define::config_burner1_pwr2_normal_rpm, item);
item.d32 = rpm_infos["config_burner23_pwr1_normal_rpm"];
cfg->setConfigValue(Define::config_burner23_pwr1_normal_rpm,item);
item.d32 = rpm_infos["config_burner23_pwr2_normal_rpm"];
cfg->setConfigValue(Define::config_burner23_pwr2_normal_rpm, item);
item.d32 = rpm_infos["config_burner1_pwr1_half_rpm"];
cfg->setConfigValue(Define::config_burner1_pwr1_half_rpm,item);
item.d32 = rpm_infos["config_burner1_pwr2_half_rpm"];
cfg->setConfigValue(Define::config_burner1_pwr2_half_rpm, item);
item.d32 = rpm_infos["config_burner23_pwr1_half_rpm"];
cfg->setConfigValue(Define::config_burner23_pwr1_half_rpm,item);
item.d32 = rpm_infos["config_burner23_pwr2_half_rpm"];
cfg->setConfigValue(Define::config_burner23_pwr2_half_rpm,item);
cfg->saveConfig();
cfg->applyConfig();
item = cfg->getConfigValue(Define::config_burner23_pwr2_half_rpm);
qDebug() << item.d32;
NotiPopupDlg* notidlg = new NotiPopupDlg(this,tr("적용 되었습니다."));
notidlg->exec();
}
else{
NotiPopupDlg* notidlg = new NotiPopupDlg(this,tr("설정 파일이 없습니다."));
notidlg->exec();
}
}