Blame view

app/gui/oven_control/manualcookwindow.cpp 14 KB
8c2952457   김태훈   응용 프로그램 추가
1
2
3
4
5
6
7
8
9
10
11
12
  #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);
6f96c947a   김태훈   GUI 0.1.4
13
14
      ui->clockContainer->setParent(ui->upperStack);
      setAttribute(Qt::WA_DeleteOnClose);
8c2952457   김태훈   응용 프로그램 추가
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
      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()));
ae1095876   김태훈   중심 온도 설정 창에서 중심 온...
40
      connect(ui->innerInterTempSlider, SIGNAL(valueChanged(int)), this, SLOT(updateLabels()));
8c2952457   김태훈   응용 프로그램 추가
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
  
      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();
6f96c947a   김태훈   GUI 0.1.4
152
      ui->tempLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">℃</span>", temp));
8c2952457   김태훈   응용 프로그램 추가
153
154
155
156
157
158
  
      int time;
      if (ui->timeSlider->isSliderDown())
          time = ui->timeSlider->sliderPosition();
      else
          time = oven->time();
c598b01b2   김태훈   GUI 업데이트
159
      if (time >= 3600)
6f96c947a   김태훈   GUI 0.1.4
160
          ui->timeLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">시간</span> %02d<span style=\"font-size:11pt;\">분</span>", time / 3600, (time % 3600) / 60));
c598b01b2   김태훈   GUI 업데이트
161
      else if (time >= 60)
6f96c947a   김태훈   GUI 0.1.4
162
          ui->timeLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">분</span> %02d<span style=\"font-size:11pt;\">초</span>", time / 60, time % 60));
c598b01b2   김태훈   GUI 업데이트
163
      else
6f96c947a   김태훈   GUI 0.1.4
164
          ui->timeLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">초</span>", time));
8c2952457   김태훈   응용 프로그램 추가
165
166
167
168
169
170
171
172
  
      if (oven->interTempEnabled())
      {
          int interTemp;
          if (ui->interTempSlider->isSliderDown())
              interTemp = ui->interTempSlider->sliderPosition();
          else
              interTemp = oven->interTemp();
6f96c947a   김태훈   GUI 0.1.4
173
          ui->interTempLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">℃</span>", interTemp));
8c2952457   김태훈   응용 프로그램 추가
174
175
      }
      else
6f96c947a   김태훈   GUI 0.1.4
176
          ui->interTempLabel->setText("<span style=\"font-size:11pt;\">℃</span>");
8c2952457   김태훈   응용 프로그램 추가
177
ae1095876   김태훈   중심 온도 설정 창에서 중심 온...
178
179
180
181
182
      int innerInterTemp = ui->innerInterTempSlider->sliderPosition();
  //    if (ui->innerInterTempSlider->isSliderDown())
  //        innerInterTemp = ui->innerInterTempSlider->sliderPosition();
  //    else
  //        innerInterTemp = oven->interTemp();
8c2952457   김태훈   응용 프로그램 추가
183
6f96c947a   김태훈   GUI 0.1.4
184
      ui->innerInterTempLabel->setText(buf.sprintf("%d<span style=\"font-size:11pt;\">℃</span>", innerInterTemp));
8c2952457   김태훈   응용 프로그램 추가
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
  
      ui->curHumidityLabel->setText(buf.sprintf("%d", oven->currentHumidity()));
      ui->targetHumidityLabel->setText(buf.sprintf("%d", oven->humidity()));
      ui->curTempLabel->setText(buf.sprintf("%d", oven->currentTemp()));
      ui->curInterTempLabel->setText(buf.sprintf("%d", oven->currentInterTemp()));
  }
  
  void ManualCookWindow::onModeButtonClicked(int mode)
  {
      oven->stop();
      oven->setDefault((Oven::Mode) mode);
      ui->bodyStack->setCurrentIndex(0);
  }
  
  void ManualCookWindow::onOvenUpdated(Oven *oven)
  {
8c2952457   김태훈   응용 프로그램 추가
201
202
203
204
      switch (oven->mode())
      {
      case Oven::HeatMode:
          ui->dryheatButton->setChecked(true);
8c2952457   김태훈   응용 프로그램 추가
205
206
207
          break;
      case Oven::SteamMode:
          ui->steamButton->setChecked(true);
8c2952457   김태훈   응용 프로그램 추가
208
209
210
          break;
      case Oven::CombinationMode:
          ui->combiButton->setChecked(true);
8c2952457   김태훈   응용 프로그램 추가
211
212
213
214
215
216
217
218
          break;
      default:
          break;
      }
  
      bool old;
      old = ui->humiditySlider->blockSignals(true);
      ui->humiditySlider->setValue(oven->humidity());
99b8066f4   김태훈   V0.1.1
219
      ui->humiditySlider->setEnabled(oven->mode() == Oven::CombinationMode);
8c2952457   김태훈   응용 프로그램 추가
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
      ui->humiditySlider->blockSignals(old);
  
      old = ui->tempSlider->blockSignals(true);
      ui->tempSlider->setRange(oven->minTemp(), oven->maxTemp());
      ui->tempSlider->setValue(oven->temp());
      ui->tempSlider->blockSignals(old);
  
      if (!ui->timeSlider->isSliderDown())
      {
          old = ui->timeSlider->blockSignals(true);
          ui->timeSlider->setValue(oven->time());
          ui->timeSlider->blockSignals(old);
      }
  
  //    ui->interTempButton->setChecked(oven->interTempEnabled());
      if (oven->interTempEnabled())
          ui->interTempButton->setStyleSheet("\
6f96c947a   김태훈   GUI 0.1.4
237
  QPushButton {\
8c2952457   김태훈   응용 프로그램 추가
238
239
      border-image: url(:/images/images/manual/011_icon_04_ov_01.png);\
  }\
6f96c947a   김태훈   GUI 0.1.4
240
  QPushButton:pressed {\
8c2952457   김태훈   응용 프로그램 추가
241
242
243
244
      border-image: url(:/images/images/manual/011_icon_04_ov.png);\
  }");
      else
          ui->interTempButton->setStyleSheet("\
6f96c947a   김태훈   GUI 0.1.4
245
  QPushButton {\
8c2952457   김태훈   응용 프로그램 추가
246
247
      border-image: url(:/images/images/manual/011_icon_04.png);\
  }\
6f96c947a   김태훈   GUI 0.1.4
248
  QPushButton:pressed {\
8c2952457   김태훈   응용 프로그램 추가
249
250
251
252
253
254
255
256
257
258
259
260
261
      border-image: url(:/images/images/manual/011_icon_04_ov.png);\
  }");
  
      old = ui->interTempSlider->blockSignals(true);
      ui->interTempSlider->setEnabled(oven->interTempEnabled());
      ui->interTempSlider->setRange(oven->minInterTemp(), oven->maxInterTemp());
      ui->interTempSlider->setValue(oven->interTemp());
      ui->interTempSlider->blockSignals(old);
  
      old = ui->innerInterTempSlider->blockSignals(true);
      ui->innerInterTempSlider->setRange(oven->minInterTemp(), oven->maxInterTemp());
      ui->innerInterTempSlider->setValue(oven->interTemp());
      ui->innerInterTempSlider->blockSignals(old);
c598b01b2   김태훈   GUI 업데이트
262
263
264
265
266
267
268
269
270
      if (oven->cooking())
          ui->runStopButton->setStyleSheet(
                      "border-image: url(:/images/images/manual/012_play_btn_ov_stop.png)");
      else
          ui->runStopButton->setStyleSheet(
                      "border-image: url(:/images/images/manual/012_play_btn.png)");
  
      if (oven->preheating())
          ui->preheatButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
271
                      "background-image: url(:/images/images/manual/013_sys_icon_01_ov.png)");
c598b01b2   김태훈   GUI 업데이트
272
273
      else
          ui->preheatButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
274
                      "background-image: url(:/images/images/manual/013_sys_icon_01.png)");
c598b01b2   김태훈   GUI 업데이트
275
276
277
  
      if (oven->damper())
          ui->damperButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
278
                      "background-image: url(:/images/images/manual/013_sys_icon_02_ov.png)");
c598b01b2   김태훈   GUI 업데이트
279
280
      else
          ui->damperButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
281
                      "background-image: url(:/images/images/manual/013_sys_icon_02.png)");
c598b01b2   김태훈   GUI 업데이트
282
283
284
  
      if (oven->humidification())
          ui->humidificationButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
285
                      "background-image: url(:/images/images/manual/013_sys_icon_03_ov.png)");
c598b01b2   김태훈   GUI 업데이트
286
287
      else
          ui->humidificationButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
288
                      "background-image: url(:/images/images/manual/013_sys_icon_03.png)");
c598b01b2   김태훈   GUI 업데이트
289
290
291
  
      if (oven->cooldown())
          ui->cooldownButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
292
                      "background-image: url(:/images/images/manual/013_sys_icon_05_ov.png)");
c598b01b2   김태훈   GUI 업데이트
293
294
      else
          ui->cooldownButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
295
                      "background-image: url(:/images/images/manual/013_sys_icon_05.png)");
8c2952457   김태훈   응용 프로그램 추가
296
297
298
299
300
  
      switch (oven->fan())
      {
      case 1:
          ui->fanButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
301
                      "background-image: url(:/images/images/manual/013_sys_icon_06.png)");
8c2952457   김태훈   응용 프로그램 추가
302
303
304
          break;
      case 2:
          ui->fanButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
305
                      "background-image: url(:/images/images/manual/013_sys_icon_06_01.png)");
8c2952457   김태훈   응용 프로그램 추가
306
307
308
          break;
      case 3:
          ui->fanButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
309
                      "background-image: url(:/images/images/manual/013_sys_icon_06_02.png)");
8c2952457   김태훈   응용 프로그램 추가
310
311
312
          break;
      case 4:
          ui->fanButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
313
                      "background-image: url(:/images/images/manual/013_sys_icon_06_03.png)");
8c2952457   김태훈   응용 프로그램 추가
314
315
316
          break;
      case 5:
          ui->fanButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
317
                      "background-image: url(:/images/images/manual/013_sys_icon_06_04.png)");
8c2952457   김태훈   응용 프로그램 추가
318
319
320
          break;
      default:
          ui->fanButton->setStyleSheet(
6f96c947a   김태훈   GUI 0.1.4
321
                      "background-image: url(:/images/images/manual/013_sys_icon_06.png)");
8c2952457   김태훈   응용 프로그램 추가
322
323
324
325
326
          break;
      }
  
      updateLabels();
  }
c598b01b2   김태훈   GUI 업데이트
327
  void ManualCookWindow::on_runStopButton_clicked()
8c2952457   김태훈   응용 프로그램 추가
328
  {
c598b01b2   김태훈   GUI 업데이트
329
      if (oven->cooking())
8c2952457   김태훈   응용 프로그램 추가
330
331
332
333
      {
          oven->stopCooking();
          emit cookStopRequested();
      }
c598b01b2   김태훈   GUI 업데이트
334
335
      else
          oven->startCooking();
8c2952457   김태훈   응용 프로그램 추가
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
  }
  
  void ManualCookWindow::on_fanButton_clicked()
  {
      int fan = oven->fan() + 1;
      if (fan > oven->maxFan())
          fan = oven->minFan();
  
      oven->setFan(fan);
  }
  
  void ManualCookWindow::on_goOuterButton_clicked()
  {
      ui->bodyStack->setCurrentIndex(0);
  }
  
  void ManualCookWindow::on_applyButton_clicked()
  {
      ui->bodyStack->setCurrentIndex(0);
  
      oven->setInterTemp(ui->innerInterTempSlider->value());
8c2952457   김태훈   응용 프로그램 추가
357
      oven->setInterTempEnabled(true);
8c2952457   김태훈   응용 프로그램 추가
358
359
360
361
362
363
364
365
366
367
368
369
  }
  
  void ManualCookWindow::on_interTempButton_clicked()
  {
      if (oven->interTempEnabled())
          oven->setInterTempEnabled(false);
      else
          ui->bodyStack->setCurrentIndex(1);
  }
  
  void ManualCookWindow::on_preheatButton_clicked()
  {
c598b01b2   김태훈   GUI 업데이트
370
371
      if (oven->preheating())
          oven->stopPreheating();
8c2952457   김태훈   응용 프로그램 추가
372
      else
c598b01b2   김태훈   GUI 업데이트
373
          oven->startPreheating();
8c2952457   김태훈   응용 프로그램 추가
374
375
376
377
  }
  
  void ManualCookWindow::on_damperButton_clicked()
  {
c598b01b2   김태훈   GUI 업데이트
378
379
      if (oven->damper())
          oven->closeDamper();
8c2952457   김태훈   응용 프로그램 추가
380
      else
c598b01b2   김태훈   GUI 업데이트
381
          oven->openDamper();
8c2952457   김태훈   응용 프로그램 추가
382
383
384
385
  }
  
  void ManualCookWindow::on_humidificationButton_clicked()
  {
c598b01b2   김태훈   GUI 업데이트
386
387
      if (oven->humidification())
          oven->stopHumidification();
8c2952457   김태훈   응용 프로그램 추가
388
      else
c598b01b2   김태훈   GUI 업데이트
389
          oven->startHumidification();
8c2952457   김태훈   응용 프로그램 추가
390
391
392
393
  }
  
  void ManualCookWindow::on_repeatButton_clicked()
  {
8c2952457   김태훈   응용 프로그램 추가
394
8c2952457   김태훈   응용 프로그램 추가
395
396
397
398
  }
  
  void ManualCookWindow::on_cooldownButton_clicked()
  {
c598b01b2   김태훈   GUI 업데이트
399
400
      if (oven->cooldown())
          oven->stopCooldown();
8c2952457   김태훈   응용 프로그램 추가
401
      else
c598b01b2   김태훈   GUI 업데이트
402
          oven->startCooldown();
8c2952457   김태훈   응용 프로그램 추가
403
404
405
406
  }
  
  void ManualCookWindow::on_reserveButton_clicked()
  {
8c2952457   김태훈   응용 프로그램 추가
407
8c2952457   김태훈   응용 프로그램 추가
408
409
410
411
  }
  
  void ManualCookWindow::on_favoritesButton_clicked()
  {
8c2952457   김태훈   응용 프로그램 추가
412
8c2952457   김태훈   응용 프로그램 추가
413
  }