adjustmentwindow.cpp
4.42 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
#include <qdebug.h>
#include "adjustmentwindow.h"
#include "ui_adjustmentwindow.h"
#include "yesnopopupdlg.h"
#include "soundplayer.h"
#include "notipopupdlg.h"
#include "touchtestwindow.h"
#include "dirtylevel.h"
#include "ovenstatics.h"
AdjustmentWindow::AdjustmentWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AdjustmentWindow)
{
ui->setupUi(this);
ui->clockContainer->setParent(ui->upperStack);
setAttribute(Qt::WA_DeleteOnClose);
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
m_nCurStep = 0;
m_bAdjustStarted = false;
m_tmrOneSec = new QTimer(this);
connect(m_tmrOneSec, SIGNAL(timeout()), this, SLOT(testTimerFired()));
}
AdjustmentWindow::~AdjustmentWindow()
{
delete ui;
}
void AdjustmentWindow::on_btnAdjust_clicked()
{
YesNoPopupDlg* w = new YesNoPopupDlg(this,tr("모든 설정 값을 공장(출고)초기화\n값으로 변경 하시겠습니까?"));
//w->raise();
if(m_bAdjustStarted == false){
UdpHandler* udp = UdpHandler::getInstance();
int dlgrst = w->exec();
dlgrst = w->result();
if(dlgrst == QDialog::Accepted) {
//Process Init Value;
qDebug() << "Accepted";
m_nCurStep = 0;
m_bAdjustStarted = true;
m_nSecCnt = 0;
udp->turnOn(TG_MANUAL_BURNER1);
udp->turnOn(TG_MANUAL_BURNER2);
udp->turnOn(TG_MANUAL_BURNER3);
udp->turnOn(TG_MANUAL_FAN1);
udp->turnOn(TG_MANUAL_FAN2);
udp->turnOn(TG_MANUAL_RELAY);
udp->turnOn(m_arrTestItems[m_nCurStep]);
m_tmrOneSec->start(1000);
}
else qDebug() <<"Rejected";
}
else{
}
}
void AdjustmentWindow::on_backButton_clicked()
{
UdpHandler* udp = UdpHandler::getInstance();
if(m_bAdjustStarted){
m_tmrOneSec->stop();
udp->turnOff(TG_MANUAL_BURNER1);
udp->turnOff(TG_MANUAL_BURNER2);
udp->turnOff(TG_MANUAL_BURNER3);
udp->turnOff(TG_MANUAL_FAN1);
udp->turnOff(TG_MANUAL_FAN2);
udp->turnOff(TG_MANUAL_RELAY);
m_bAdjustStarted = false;
}
close();
}
void AdjustmentWindow::testTimerFired()
{
int nRestTime = ADJUST_TIME_SEC * MAX_ADJUST_TEST_CNT;
QString strTemp;
m_nSecCnt++;
if((m_nSecCnt%ADJUST_TIME_SEC)==0){
UdpHandler* udp = UdpHandler::getInstance();
udp->turnOff(m_arrTestItems[m_nCurStep]);
m_nCurStep++;
if(m_nCurStep < MAX_ADJUST_TEST_CNT){
udp->turnOn(m_nCurStep);
}
else{
//Test Finished
m_tmrOneSec->stop();
udp->turnOff(TG_MANUAL_BURNER1);
udp->turnOff(TG_MANUAL_BURNER2);
udp->turnOff(TG_MANUAL_BURNER3);
udp->turnOff(TG_MANUAL_FAN1);
udp->turnOff(TG_MANUAL_FAN2);
udp->turnOff(TG_MANUAL_RELAY);
m_bAdjustStarted = false;
QDialog* dlg = new NotiPopupDlg(this,tr("테스트를 완료하였습니다."));
dlg->exec();
}
}
nRestTime = nRestTime - m_nSecCnt;
strTemp = QString("%1/ %2:%3").arg(m_nCurStep).arg((nRestTime/60),2,10,QLatin1Char('0')).arg((nRestTime%60),2,10,QLatin1Char('0'));
ui->btnAdjust->setText(strTemp);
}
void AdjustmentWindow::keyPressEvent(QKeyEvent *event){
switch (event->key())
{
case 0x01000032: // Turn left
focusPreviousChild();
break;
case 0x01000030: // Turn right
focusNextChild();
break;
}
}
void AdjustmentWindow::keyReleaseEvent(QKeyEvent *event){
switch (event->key())
{
case 0x01000032: // Turn left
focusPreviousChild();
break;
case 0x01000031: // Push
{
QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
if(btn != NULL){
btn->click();
}
break;
}
case 0x01000030: // Turn right
focusNextChild();
break;
}
}
void AdjustmentWindow::on_btnAdjust_LCD_clicked()
{
TouchTestWindow* wnd = new TouchTestWindow(this);
wnd->setWindowModality(Qt::WindowModal);
wnd->show();
wnd->raise();
}
void AdjustmentWindow::on_btnClearWashData_clicked()
{
// DirtyLevel::setCookingTime(0);
// DirtyLevel::setCookingCount(0);
OvenStatistics::getInstance()->setTotalCookingCount(0,false);
OvenStatistics::getInstance()->setTotalCookingTime(0, true);
}