8c2952457
김태훈
응용 프로그램 추가
|
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 "manualcookwindow.h"
#include "ui_manualcookwindow.h"
#include <QSignalMapper>
#include <QTimer>
#include <QtDebug>
ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) :
QMainWindow(parent),
ui(new Ui::ManualCookWindow), oven(oven), udp(udp)
{
ui->setupUi(this);
connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*)));
connect(ui->steamButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked()));
connect(ui->combiButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked()));
connect(ui->dryheatButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked()));
QSignalMapper *sm = new QSignalMapper(this);
sm->setMapping(ui->steamButton, (int) Oven::SteamMode);
sm->setMapping(ui->combiButton, (int) Oven::CombinationMode);
sm->setMapping(ui->dryheatButton, (int) Oven::HeatMode);
connect(ui->steamButton, SIGNAL(clicked()), sm, SLOT(map()));
connect(ui->combiButton, SIGNAL(clicked()), sm, SLOT(map()));
connect(ui->dryheatButton, SIGNAL(clicked()), sm, SLOT(map()));
connect(sm, SIGNAL(mapped(int)), this, SLOT(onModeButtonClicked(int)));
connect(ui->humiditySlider, SIGNAL(valueChanged(int)), oven, SLOT(setHumidity(int)));
connect(ui->tempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setTemp(int)));
connect(ui->timeSlider, SIGNAL(valueChanged(int)), oven, SLOT(setTime(int)));
connect(ui->interTempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setInterTemp(int)));
connect(ui->humiditySlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
connect(ui->tempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
connect(ui->timeSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
connect(ui->interTempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
connect(ui->innerInterTempSlider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabels()));
QTimer *cookingTimerCheckTimer = new QTimer(this);
cookingTimerCheckTimer->setInterval(100);
connect(cookingTimerCheckTimer, SIGNAL(timeout()), this, SLOT(checkTime()));
connect(this, SIGNAL(modeButtonClicked()), cookingTimerCheckTimer, SLOT(stop()));
QTimer *cookingStartTimer = new QTimer(this);
cookingStartTimer->setSingleShot(true);
cookingStartTimer->setInterval(3000);
connect(ui->timeSlider, SIGNAL(valueChanged(int)), cookingStartTimer, SLOT(start()));
connect(ui->timeSlider, SIGNAL(valueChanged(int)), this, SLOT(updateLabels()));
connect(this, SIGNAL(modeButtonClicked()), cookingStartTimer, SLOT(stop()));
connect(cookingStartTimer, SIGNAL(timeout()), oven, SLOT(startCooking()));
connect(cookingStartTimer, SIGNAL(timeout()), cookingTimerCheckTimer, SLOT(start()));
QTimer *showCurHumTimer = new QTimer(this);
QTimer *showCurTempTimer = new QTimer(this);
showCurHumTimer->setInterval(2000);
showCurTempTimer->setInterval(2000);
connect(ui->humidityButton, SIGNAL(pressed()), showCurHumTimer, SLOT(start()));
connect(ui->humidityButton, SIGNAL(released()), showCurHumTimer, SLOT(stop()));
connect(showCurHumTimer, SIGNAL(timeout()), this, SLOT(showCurrentHumidity()));
connect(ui->humidityButton, SIGNAL(released()), this, SLOT(hideCurrentHumidity()));
connect(ui->tempButton, SIGNAL(pressed()), showCurTempTimer, SLOT(start()));
connect(ui->tempButton, SIGNAL(released()), showCurTempTimer, SLOT(stop()));
connect(showCurTempTimer, SIGNAL(timeout()), this, SLOT(showCurrentTemp()));
connect(ui->tempButton, SIGNAL(released()), this, SLOT(hideCurrentTemp()));
QSignalMapper *smStack = new QSignalMapper(this);
smStack->setMapping(ui->goFrontStackButton, 0);
smStack->setMapping(ui->goBackStackButton, 1);
connect(ui->goFrontStackButton, SIGNAL(clicked()), smStack, SLOT(map()));
connect(ui->goBackStackButton, SIGNAL(clicked()), smStack, SLOT(map()));
connect(smStack, SIGNAL(mapped(int)), ui->buttonStack, SLOT(setCurrentIndex(int)));
connect(ui->backButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(ui->backButton, SIGNAL(clicked()), oven, SLOT(stop()));
connect(ui->backButton, SIGNAL(clicked()), cookingTimerCheckTimer, SLOT(stop()));
connect(ui->backButton, SIGNAL(clicked()), cookingStartTimer, SLOT(stop()));
connect(ui->backButton, SIGNAL(clicked()), showCurHumTimer, SLOT(stop()));
connect(ui->backButton, SIGNAL(clicked()), showCurTempTimer, SLOT(stop()));
connect(this, SIGNAL(cookStopRequested()), cookingStartTimer, SLOT(stop()));
ui->bodyStack->setCurrentIndex(0);
}
ManualCookWindow::~ManualCookWindow()
{
delete ui;
}
void ManualCookWindow::checkTime()
{
if (oven->cooking() && !ui->timeSlider->isSliderDown())
{
bool old = ui->timeSlider->blockSignals(true);
ui->timeSlider->setSliderPosition(oven->time());
ui->timeSlider->blockSignals(old);
updateLabels();
}
}
void ManualCookWindow::showCurrentHumidity()
{
showCurrentHumidity_ = true;
updateLabels();
}
void ManualCookWindow::hideCurrentHumidity()
{
showCurrentHumidity_ = false;
updateLabels();
}
void ManualCookWindow::showCurrentTemp()
{
showCurrentTemp_ = true;
updateLabels();
}
void ManualCookWindow::hideCurrentTemp()
{
showCurrentTemp_ = false;
updateLabels();
}
void ManualCookWindow::updateLabels()
{
QString buf;
int humidity;
if (showCurrentHumidity_)
humidity = oven->currentHumidity();
else if (ui->humiditySlider->isSliderDown())
humidity = ui->humiditySlider->sliderPosition();
else
humidity = oven->humidity();
ui->humidityLabel->setText(buf.sprintf("%d%%", humidity));
int temp;
if (showCurrentTemp_)
temp = oven->currentTemp();
else if (ui->tempSlider->isSliderDown())
temp = ui->tempSlider->sliderPosition();
else
temp = oven->temp();
ui->tempLabel->setText(buf.sprintf("%d℃", temp));
int time;
if (ui->timeSlider->isSliderDown())
time = ui->timeSlider->sliderPosition();
else
time = oven->time();
|