Commit 6eb13ba2e37b439fc99e3d8b5e28b40c181bbb56

Authored by 김태훈
1 parent 50e20e69fd
Exists in master and in 2 other branches fhd, fhd-demo

예열 팝업 동작 보완 및 동작 정의 변경

- 현재 온도에 따라 예열 게이지 상태 변환
 - 현재 온도가 목표 예열 온도에 도달하면 예열 중단 후 복귀
app/gui/oven_control/mainwindow.cpp
@@ -20,7 +20,7 @@ MainWindow::MainWindow(QWidget *parent) : @@ -20,7 +20,7 @@ MainWindow::MainWindow(QWidget *parent) :
20 20
21 oven = new Oven(this); 21 oven = new Oven(this);
22 22
23 - OvenController *interface = new OvenController; 23 + OvenController *interface = new OvenController(this, oven);
24 oven->setInterface(interface); 24 oven->setInterface(interface);
25 25
26 udp = new UdpHandler(this); 26 udp = new UdpHandler(this);
app/gui/oven_control/oven.cpp
@@ -7,6 +7,10 @@ Oven::Oven(QObject *parent) : QObject(parent) @@ -7,6 +7,10 @@ Oven::Oven(QObject *parent) : QObject(parent)
7 { 7 {
8 interface = NULL; 8 interface = NULL;
9 9
  10 + currentHumidity_ = 0;
  11 + currentTemp_ = 0;
  12 + currentInterTemp_ = 0;
  13 +
10 cookingTimer.setSingleShot(true); 14 cookingTimer.setSingleShot(true);
11 connect(&cookingTimer, SIGNAL(timeout()), this, SLOT(stopCooking())); 15 connect(&cookingTimer, SIGNAL(timeout()), this, SLOT(stopCooking()));
12 16
@@ -83,7 +87,6 @@ void Oven::setDefault(Mode mode) @@ -83,7 +87,6 @@ void Oven::setDefault(Mode mode)
83 cooldown_ = false; 87 cooldown_ = false;
84 damper_ = false; 88 damper_ = false;
85 humidification_ = false; 89 humidification_ = false;
86 - washing_ = false;  
87 door_ = interface->door(); 90 door_ = interface->door();
88 paused_ = false; 91 paused_ = false;
89 92
@@ -285,26 +288,30 @@ void Oven::stop() @@ -285,26 +288,30 @@ void Oven::stop()
285 288
286 if (humidification()) 289 if (humidification())
287 stopHumidification(); 290 stopHumidification();
288 -  
289 - if (washing())  
290 - stopWashing();  
291 } 291 }
292 292
293 void Oven::startCooking() 293 void Oven::startCooking()
294 { 294 {
295 - paused_ = false;  
296 -  
297 if (!cooking()) 295 if (!cooking())
298 { 296 {
299 - if (preheating())  
300 - stopPreheating(); 297 + if (door())
  298 + {
  299 + paused_ = true;
  300 + }
  301 + else
  302 + {
  303 + paused_ = false;
  304 +
  305 + if (preheating())
  306 + stopPreheating();
301 307
302 - if (cooldown())  
303 - stopCooldown(); 308 + if (cooldown())
  309 + stopCooldown();
304 310
305 - cooking_ = true;  
306 - cookingTimer.start();  
307 - interface->startCooking(); 311 + cooking_ = true;
  312 + cookingTimer.start();
  313 + interface->startCooking();
  314 + }
308 315
309 emit changed(this); 316 emit changed(this);
310 } 317 }
@@ -334,6 +341,9 @@ void Oven::startPreheating() @@ -334,6 +341,9 @@ void Oven::startPreheating()
334 { 341 {
335 if (preheatingStartable()) 342 if (preheatingStartable())
336 { 343 {
  344 + if (cooking())
  345 + stopCooking();
  346 +
337 preheating_ = true; 347 preheating_ = true;
338 interface->startPreheating(); 348 interface->startPreheating();
339 349
@@ -349,6 +359,9 @@ void Oven::stopPreheating() @@ -349,6 +359,9 @@ void Oven::stopPreheating()
349 interface->stopPreheating(); 359 interface->stopPreheating();
350 360
351 emit changed(this); 361 emit changed(this);
  362 +
  363 + if (paused())
  364 + startCooking();
352 } 365 }
353 } 366 }
354 367
@@ -406,26 +419,17 @@ void Oven::stopHumidification() @@ -406,26 +419,17 @@ void Oven::stopHumidification()
406 } 419 }
407 } 420 }
408 421
409 -void Oven::startWashing()  
410 -{  
411 -  
412 -}  
413 -  
414 -void Oven::stopWashing()  
415 -{  
416 -  
417 -}  
418 -  
419 -void Oven::openDamper() 422 +void Oven::openDamper(int secs)
420 { 423 {
421 if (!damper()) 424 if (!damper())
422 { 425 {
423 damper_ = true; 426 damper_ = true;
424 - damperTimer.start(5 * 60 * 1000);  
425 interface->openDamper(); 427 interface->openDamper();
426 428
427 emit changed(this); 429 emit changed(this);
428 } 430 }
  431 +
  432 + damperTimer.start(secs * 1000);
429 } 433 }
430 434
431 void Oven::closeDamper() 435 void Oven::closeDamper()
@@ -442,6 +446,33 @@ void Oven::closeDamper() @@ -442,6 +446,33 @@ void Oven::closeDamper()
442 } 446 }
443 } 447 }
444 448
  449 +void Oven::setCurrentHumidity(int percentage)
  450 +{
  451 + if (currentHumidity() != percentage)
  452 + {
  453 + currentHumidity_ = percentage;
  454 + emit changed(this);
  455 + }
  456 +}
  457 +
  458 +void Oven::setCurrentTemp(int celsius)
  459 +{
  460 + if (currentTemp() != celsius)
  461 + {
  462 + currentTemp_ = celsius;
  463 + emit changed(this);
  464 + }
  465 +}
  466 +
  467 +void Oven::setCurrentInterTemp(int celsius)
  468 +{
  469 + if (currentInterTemp() != celsius)
  470 + {
  471 + currentInterTemp_ = celsius;
  472 + emit changed(this);
  473 + }
  474 +}
  475 +
445 476
446 477
447 478
@@ -523,7 +554,10 @@ void Oven::onDoorOpened() @@ -523,7 +554,10 @@ void Oven::onDoorOpened()
523 emit changed(this); 554 emit changed(this);
524 555
525 if (cooking()) 556 if (cooking())
  557 + {
526 stopCooking(); 558 stopCooking();
  559 + openDamper(7);
  560 + }
527 } 561 }
528 562
529 void Oven::onDoorClosed() 563 void Oven::onDoorClosed()
@@ -532,6 +566,9 @@ void Oven::onDoorClosed() @@ -532,6 +566,9 @@ void Oven::onDoorClosed()
532 566
533 emit changed(this); 567 emit changed(this);
534 568
535 - if (paused()) 569 + if (!cooldown() && paused())
536 startCooking(); 570 startCooking();
  571 +
  572 + if (damper())
  573 + closeDamper();
537 } 574 }
app/gui/oven_control/oven.h
@@ -66,7 +66,10 @@ private: @@ -66,7 +66,10 @@ private:
66 bool damper_ = false; // true: open, false: close 66 bool damper_ = false; // true: open, false: close
67 bool humidification_ = false; 67 bool humidification_ = false;
68 bool door_ = false; // true: open, false: close 68 bool door_ = false; // true: open, false: close
69 - bool washing_ = false; 69 +
  70 + int currentHumidity_;
  71 + int currentTemp_;
  72 + int currentInterTemp_;
70 73
71 74
72 bool paused_; 75 bool paused_;
@@ -95,12 +98,11 @@ public: @@ -95,12 +98,11 @@ public:
95 bool damper() { return damper_; } 98 bool damper() { return damper_; }
96 bool humidification() { return humidification_; } 99 bool humidification() { return humidification_; }
97 bool door() { return door_; } 100 bool door() { return door_; }
98 - bool washing() { return washing_; }  
99 bool paused() { return paused_; } 101 bool paused() { return paused_; }
100 102
101 - int currentTemp() { return interface->currentTemp(); }  
102 - int currentHumidity() { return interface->currentHumidity(); }  
103 - int currentInterTemp() { return interface->currentInterTemp(); } 103 + int currentTemp() { return currentTemp_; }
  104 + int currentHumidity() { return currentHumidity_; }
  105 + int currentInterTemp() { return currentInterTemp_; }
104 106
105 bool cookingStartable(); 107 bool cookingStartable();
106 bool preheatingStartable(); 108 bool preheatingStartable();
@@ -139,12 +141,13 @@ public slots: @@ -139,12 +141,13 @@ public slots:
139 void stopCooldown(); 141 void stopCooldown();
140 void startHumidification(); 142 void startHumidification();
141 void stopHumidification(); 143 void stopHumidification();
142 - void startWashing();  
143 - void stopWashing();  
144 144
145 - void openDamper(); 145 + void openDamper(int secs = 300);
146 void closeDamper(); 146 void closeDamper();
147 147
  148 + void setCurrentHumidity(int percentage);
  149 + void setCurrentTemp(int celsius);
  150 + void setCurrentInterTemp(int celsius);
148 151
149 void setInterface(OvenInterface *interface); 152 void setInterface(OvenInterface *interface);
150 153
app/gui/oven_control/ovencontroller.cpp
1 #include "ovencontroller.h" 1 #include "ovencontroller.h"
2 2
3 -OvenController::OvenController(QObject *parent) : OvenInterface(parent) 3 +OvenController::OvenController(QObject *parent, Oven *oven) : OvenInterface(parent),
  4 + oven(oven)
4 { 5 {
5 bzero(&control, sizeof(control)); 6 bzero(&control, sizeof(control));
6 bzero(&state, sizeof(state)); 7 bzero(&state, sizeof(state));
@@ -29,6 +30,10 @@ void OvenController::onDataChanged() @@ -29,6 +30,10 @@ void OvenController::onDataChanged()
29 if (state.door_state != 0) 30 if (state.door_state != 0)
30 emit doorOpened(); 31 emit doorOpened();
31 } 32 }
  33 +
  34 + oven->setCurrentHumidity(currentHumidity());
  35 + oven->setCurrentTemp(currentTemp());
  36 + oven->setCurrentInterTemp(currentInterTemp());
32 } 37 }
33 38
34 int OvenController::currentTemp() 39 int OvenController::currentTemp()
@@ -92,7 +97,7 @@ void OvenController::stopCooking() @@ -92,7 +97,7 @@ void OvenController::stopCooking()
92 97
93 void OvenController::startPreheating() 98 void OvenController::startPreheating()
94 { 99 {
95 - udp->set(TG_OVEN_MODE, 0); 100 + udp->set(TG_OVEN_MODE, 1);
96 udp->set(TG_TIME, 1440); 101 udp->set(TG_TIME, 1440);
97 udp->turnOn(TG_SYSTEM); 102 udp->turnOn(TG_SYSTEM);
98 udp->turnOn(TG_PREHEAT); 103 udp->turnOn(TG_PREHEAT);
@@ -135,10 +140,10 @@ void OvenController::stopWashing() @@ -135,10 +140,10 @@ void OvenController::stopWashing()
135 140
136 void OvenController::openDamper() 141 void OvenController::openDamper()
137 { 142 {
138 - 143 + udp->turnOn(TG_OUTHUMIDITY);
139 } 144 }
140 145
141 void OvenController::closeDamper() 146 void OvenController::closeDamper()
142 { 147 {
143 - 148 + udp->turnOff(TG_OUTHUMIDITY);
144 } 149 }
app/gui/oven_control/ovencontroller.h
@@ -9,12 +9,13 @@ class OvenController : public OvenInterface @@ -9,12 +9,13 @@ class OvenController : public OvenInterface
9 { 9 {
10 Q_OBJECT 10 Q_OBJECT
11 11
  12 + Oven *oven;
12 UdpHandler *udp; 13 UdpHandler *udp;
13 oven_control_t control; 14 oven_control_t control;
14 oven_state_t state; 15 oven_state_t state;
15 16
16 public: 17 public:
17 - OvenController(QObject *parent = 0); 18 + OvenController(QObject *parent = 0, Oven *oven = 0);
18 19
19 void setUdpHandler(UdpHandler *udp); 20 void setUdpHandler(UdpHandler *udp);
20 int currentTemp(); 21 int currentTemp();
app/gui/oven_control/preheatpopup.cpp
@@ -12,7 +12,7 @@ PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) : @@ -12,7 +12,7 @@ PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) :
12 12
13 setAttribute(Qt::WA_DeleteOnClose); 13 setAttribute(Qt::WA_DeleteOnClose);
14 14
15 - connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView())); 15 + connect(oven, SIGNAL(changed(Oven*)), SLOT(onOvenChanged()));
16 16
17 showCurrentHumidityTimer.setSingleShot(true); 17 showCurrentHumidityTimer.setSingleShot(true);
18 showCurrentHumidityTimer.setInterval(3000); 18 showCurrentHumidityTimer.setInterval(3000);
@@ -22,6 +22,10 @@ PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) : @@ -22,6 +22,10 @@ PreheatPopup::PreheatPopup(QWidget *parent, Oven *oven) :
22 showCurrentTempTimer.setInterval(3000); 22 showCurrentTempTimer.setInterval(3000);
23 connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp())); 23 connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp()));
24 24
  25 + ui->preheatGauge->setMaximum(oven->temp());
  26 + ui->preheatGauge->setMinimum(oven->currentTemp());
  27 + ui->preheatGauge->setValue(oven->currentTemp());
  28 +
25 start(); 29 start();
26 } 30 }
27 31
@@ -63,6 +67,8 @@ void PreheatPopup::updateView() @@ -63,6 +67,8 @@ void PreheatPopup::updateView()
63 67
64 ui->humidityLabel->setText(QString().sprintf("%d%%", humidity)); 68 ui->humidityLabel->setText(QString().sprintf("%d%%", humidity));
65 ui->heatLabel->setText(QString().sprintf("%d℃", temp)); 69 ui->heatLabel->setText(QString().sprintf("%d℃", temp));
  70 +
  71 + ui->preheatGauge->setValue(oven->currentTemp());
66 } 72 }
67 73
68 void PreheatPopup::start() 74 void PreheatPopup::start()
@@ -89,6 +95,17 @@ void PreheatPopup::showCurrentTemp() @@ -89,6 +95,17 @@ void PreheatPopup::showCurrentTemp()
89 updateView(); 95 updateView();
90 } 96 }
91 97
  98 +void PreheatPopup::onOvenChanged()
  99 +{
  100 + if (oven->currentHumidity() >= oven->humidity() && oven->currentTemp() >= oven->temp())
  101 + {
  102 + stop();
  103 + close();
  104 + }
  105 + else
  106 + updateView();
  107 +}
  108 +
92 void PreheatPopup::on_closeButton_clicked() 109 void PreheatPopup::on_closeButton_clicked()
93 { 110 {
94 stop(); 111 stop();
app/gui/oven_control/preheatpopup.h
@@ -26,15 +26,14 @@ private slots: @@ -26,15 +26,14 @@ private slots:
26 void showCurrentHumidity(); 26 void showCurrentHumidity();
27 void showCurrentTemp(); 27 void showCurrentTemp();
28 28
  29 + void onOvenChanged();
  30 +
29 void on_closeButton_clicked(); 31 void on_closeButton_clicked();
30 void on_closeButton_2_clicked(); 32 void on_closeButton_2_clicked();
31 33
32 void on_humidityGaugeButton_pressed(); 34 void on_humidityGaugeButton_pressed();
33 -  
34 void on_humidityGaugeButton_released(); 35 void on_humidityGaugeButton_released();
35 -  
36 void on_heatGaugeButton_pressed(); 36 void on_heatGaugeButton_pressed();
37 -  
38 void on_heatGaugeButton_released(); 37 void on_heatGaugeButton_released();
39 38
40 private: 39 private: