washwindow.cpp
2.28 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
#include "washwindow.h"
#include "ui_washwindow.h"
#include <QSignalMapper>
WashWindow::WashWindow(QWidget *parent, UdpHandler *udp) :
QMainWindow(parent),
ui(new Ui::WashWindow),
udp(udp),
started(false)
{
ui->setupUi(this);
ui->clockContainer->setParent(ui->upperStack);
ui->progressContainer->setParent(ui->upperStack);
setAttribute(Qt::WA_DeleteOnClose);
udp->turnOff(TG_SYSTEM);
connect(udp, SIGNAL(changed()), SLOT(onChanged()));
ui->animation->load(":/images/animation/wash_01.png");
ui->animation->load(":/images/animation/wash_02.png");
ui->animation->load(":/images/animation/wash_03.png");
ui->animation->load(":/images/animation/wash_04.png");
QSignalMapper *sm = new QSignalMapper(this);
connect(sm, SIGNAL(mapped(int)), SLOT(start(int)));
sm->setMapping(ui->washButton_1, 1);
sm->setMapping(ui->washButton_2, 2);
sm->setMapping(ui->washButton_3, 3);
sm->setMapping(ui->washButton_4, 4);
sm->setMapping(ui->washButton_5, 5);
connect(ui->washButton_1, SIGNAL(clicked()), sm, SLOT(map()));
connect(ui->washButton_2, SIGNAL(clicked()), sm, SLOT(map()));
connect(ui->washButton_3, SIGNAL(clicked()), sm, SLOT(map()));
connect(ui->washButton_4, SIGNAL(clicked()), sm, SLOT(map()));
connect(ui->washButton_5, SIGNAL(clicked()), sm, SLOT(map()));
}
WashWindow::~WashWindow()
{
delete ui;
}
void WashWindow::start(int type)
{
if (started)
return;
if (type < 1 || type > 5)
return;
started = true;
udp->set(TG_OVEN_MODE, 2);
udp->set(TG_CLEAN_TYPE, type);
udp->turnOn(TG_SYSTEM);
udp->turnOn(TG_CLEANING);
ui->upperStack->setCurrentIndex(1);
ui->animation->start(300);
}
void WashWindow::stop()
{
udp->turnOff(TG_CLEANING);
}
void WashWindow::onChanged()
{
if (!started)
return;
oven_control_t control;
// oven_state_t state;
udp->fillControl(control);
// udp->fillData(state);
ui->washStepGauge->setMaximum(control.clean_total);
ui->washStepGauge->setValue(control.clean_step);
ui->washStepCountLabel->setText(QString().sprintf("%d/%d", control.clean_step, control.clean_total));
ui->washStepTypeLabel->setText("세척 공정 진행");
}
void WashWindow::on_backButton_clicked()
{
stop();
close();
}