configsteamwashdlg.cpp
4.63 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
#include "configsteamwashdlg.h"
#include "ui_configsteamwashdlg.h"
#include "udphandler.h"
ConfigSteamWashDlg::ConfigSteamWashDlg(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfigSteamWashDlg)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_DeleteOnClose);
setFocus();
qApp->setActiveWindow(this);
UdpHandler *udp = UdpHandler::getInstance();
connect(udp, SIGNAL(changed()), SLOT(onChanged()));
updateView();
}
ConfigSteamWashDlg::~ConfigSteamWashDlg()
{
delete ui;
}
void ConfigSteamWashDlg::updateView()
{
switch (phase) {
case Idle:
ui->ctrLbBody->setText(tr("시작하시겠습니까?"));
ui->ctrLbBody->show();
ui->ctrGauge->hide();
ui->ctrBtnOk->setGeometry(300, 350, 150, 100);
ui->ctrBtnOk->show();
ui->ctrBtnCancel->show();
break;
case Starting:
ui->ctrLbBody->hide();
ui->ctrGauge->hide();
ui->ctrBtnOk->hide();
ui->ctrBtnCancel->hide();
break;
case Started:
{
UdpHandler *udp = UdpHandler::getInstance();
oven_control_t control;
udp->fillControl(control);
switch (control.clean_step_type)
{
case 1:
ui->ctrLbBody->setText(tr("내부 헹굼 진행 중입니다."));
break;
case 2:
ui->ctrLbBody->setText(tr("스팀 급수 진행 중입니다."));
break;
case 3:
ui->ctrLbBody->setText(tr("내부 팬 세척 진행 중입니다."));
break;
case 4:
ui->ctrLbBody->setText(tr("내부 스팀 불림 진행 중입니다."));
break;
case 5:
ui->ctrLbBody->setText(tr("내부 강 세척 진행 중입니다."));
break;
case 6:
ui->ctrLbBody->setText(tr("내부 상부 세척 진행 중입니다."));
break;
case 7:
ui->ctrLbBody->setText(tr("내부 스팀 세척 진행 중입니다."));
break;
case 8:
ui->ctrLbBody->setText(tr("세척 종료 진행 중입니다."));
break;
case 9:
ui->ctrLbBody->setText(tr("세제 세척수 만들기 진행 중입니다."));
break;
case 10:
ui->ctrLbBody->setText(tr("세제 세척수 헹굼 진행 중입니다."));
break;
case 11:
ui->ctrLbBody->setText(tr("하부 탱크 세척수 만들기 진행 중입니다."));
break;
}
ui->ctrLbBody->show();
ui->ctrGauge->setMaximum(control.clean_total);
ui->ctrGauge->setValue(control.clean_step);
ui->ctrGauge->show();
ui->ctrBtnOk->hide();
ui->ctrBtnCancel->hide();
break;
}
case Finished:
ui->ctrLbBody->setText(tr("세척이 종료되었습니다"));
ui->ctrLbBody->show();
ui->ctrGauge->setMaximum(1);
ui->ctrGauge->setValue(1);
ui->ctrGauge->show();
ui->ctrBtnOk->setGeometry(300, 350, 300, 100);
ui->ctrBtnOk->show();
ui->ctrBtnCancel->hide();
}
}
void ConfigSteamWashDlg::onChanged()
{
switch (phase) {
case Idle:
return;
case Starting:
if (isStarted())
phase = Started;
break;
case Started:
if (isFinished())
phase = Finished;
break;
case Finished:
return;
}
updateView();
}
void ConfigSteamWashDlg::start()
{
UdpHandler *udp = UdpHandler::getInstance();
udp->set(TG_OVEN_MODE, 2);
udp->set(TG_CLEAN_TYPE, 6);
udp->turnOn(TG_CLEANING);
phase = Starting;
updateView();
}
bool ConfigSteamWashDlg::isStarted()
{
UdpHandler *udp = UdpHandler::getInstance();
oven_control_t control;
oven_state_t state;
udp->fillControl(control);
udp->fillData(state);
return state.cleaning_sate != 0
&& control.clean_total != 0
&& control.clean_step != 0
&& control.clean_step_type != 0;
}
bool ConfigSteamWashDlg::isFinished()
{
UdpHandler *udp = UdpHandler::getInstance();
oven_state_t state;
udp->fillData(state);
return state.cleaning_sate == 0;
}
void ConfigSteamWashDlg::on_ctrBtnOk_clicked()
{
switch (phase) {
case Idle:
start();
break;
case Finished:
close();
break;
default:
return;
}
}
void ConfigSteamWashDlg::on_ctrBtnCancel_clicked()
{
switch (phase) {
case Idle:
close();
break;
default:
return;
}
}