Commit d66d7f5b443cd02409863597861746bad5822987

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

GUI 버전 0.1.2

app/gui/oven_control/autocookselectionwindow.cpp
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Cook::CookType type) : 8 AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Cook::CookType type) :
9 QMainWindow(parent), 9 QMainWindow(parent),
10 ui(new Ui::AutoCookSelectionWindow), 10 ui(new Ui::AutoCookSelectionWindow),
11 - oven(oven), type(type) 11 + oven(oven), type(type), autoCookWindowOpened(false)
12 { 12 {
13 ui->setupUi(this); 13 ui->setupUi(this);
14 14
@@ -47,7 +47,6 @@ AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Co @@ -47,7 +47,6 @@ AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Co
47 47
48 for (int idx = 0; idx < cookList.size(); idx++) 48 for (int idx = 0; idx < cookList.size(); idx++)
49 { 49 {
50 - // TODO: make pushbuttons, map buttons to index,  
51 int x = 12 + (idx % 3) * 294; 50 int x = 12 + (idx % 3) * 294;
52 int y = 615 + (idx / 3) * 80; 51 int y = 615 + (idx / 3) * 80;
53 52
@@ -72,8 +71,19 @@ AutoCookSelectionWindow::~AutoCookSelectionWindow() @@ -72,8 +71,19 @@ AutoCookSelectionWindow::~AutoCookSelectionWindow()
72 71
73 void AutoCookSelectionWindow::onCookSelected(int idx) 72 void AutoCookSelectionWindow::onCookSelected(int idx)
74 { 73 {
  74 + if (autoCookWindowOpened)
  75 + return;
  76 +
  77 + autoCookWindowOpened = true;
  78 +
75 AutoCookWindow *w = new AutoCookWindow(this, oven, cookList.at(idx)); 79 AutoCookWindow *w = new AutoCookWindow(this, oven, cookList.at(idx));
76 w->showFullScreen(); 80 w->showFullScreen();
  81 + connect(w, SIGNAL(destroyed(QObject*)), SLOT(onAutoCookWindowDestroyed()));
  82 +}
  83 +
  84 +void AutoCookSelectionWindow::onAutoCookWindowDestroyed()
  85 +{
  86 + autoCookWindowOpened = false;
77 } 87 }
78 88
79 void AutoCookSelectionWindow::on_backButton_clicked() 89 void AutoCookSelectionWindow::on_backButton_clicked()
app/gui/oven_control/autocookselectionwindow.h
@@ -20,6 +20,7 @@ public: @@ -20,6 +20,7 @@ public:
20 20
21 private slots: 21 private slots:
22 void onCookSelected(int idx); 22 void onCookSelected(int idx);
  23 + void onAutoCookWindowDestroyed();
23 24
24 void on_backButton_clicked(); 25 void on_backButton_clicked();
25 26
@@ -28,6 +29,7 @@ private: @@ -28,6 +29,7 @@ private:
28 Oven *oven; 29 Oven *oven;
29 Cook::CookType type; 30 Cook::CookType type;
30 QList<AbstractCook *> cookList; 31 QList<AbstractCook *> cookList;
  32 + bool autoCookWindowOpened;
31 }; 33 };
32 34
33 #endif // AUTOCOOKSELECTIONWINDOW_H 35 #endif // AUTOCOOKSELECTIONWINDOW_H
app/gui/oven_control/autocookwindow.cpp
@@ -32,8 +32,6 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Oven *oven, AbstractCook *cook) @@ -32,8 +32,6 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Oven *oven, AbstractCook *cook)
32 cookStartTimer->setInterval(3000); 32 cookStartTimer->setInterval(3000);
33 connect(cookStartTimer, SIGNAL(timeout()), SLOT(start())); 33 connect(cookStartTimer, SIGNAL(timeout()), SLOT(start()));
34 34
35 - cookStartTimer->start();  
36 -  
37 connect(ui->configButton_1, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); 35 connect(ui->configButton_1, SIGNAL(pressed()), SIGNAL(stopCookStartTimer()));
38 connect(ui->configButton_2, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); 36 connect(ui->configButton_2, SIGNAL(pressed()), SIGNAL(stopCookStartTimer()));
39 connect(ui->configButton_3, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); 37 connect(ui->configButton_3, SIGNAL(pressed()), SIGNAL(stopCookStartTimer()));
@@ -97,6 +95,8 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Oven *oven, AbstractCook *cook) @@ -97,6 +95,8 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Oven *oven, AbstractCook *cook)
97 connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp())); 95 connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp()));
98 96
99 setupUi(); 97 setupUi();
  98 +
  99 + cookStartTimer->start();
100 } 100 }
101 101
102 AutoCookWindow::~AutoCookWindow() 102 AutoCookWindow::~AutoCookWindow()
@@ -248,6 +248,7 @@ void AutoCookWindow::setupUi() @@ -248,6 +248,7 @@ void AutoCookWindow::setupUi()
248 248
249 void AutoCookWindow::updateView() 249 void AutoCookWindow::updateView()
250 { 250 {
  251 + qDebug() << "updateView";
251 if (started) 252 if (started)
252 { 253 {
253 ui->stackedWidget->setCurrentIndex(1); 254 ui->stackedWidget->setCurrentIndex(1);
@@ -345,6 +346,7 @@ void AutoCookWindow::updateView() @@ -345,6 +346,7 @@ void AutoCookWindow::updateView()
345 346
346 void AutoCookWindow::viewStep(Cook::Step step) 347 void AutoCookWindow::viewStep(Cook::Step step)
347 { 348 {
  349 + qDebug() << "viewStep" << step.type;
348 switch (Cook::classify(step.type)) 350 switch (Cook::classify(step.type))
349 { 351 {
350 case Cook::PreheatClass: 352 case Cook::PreheatClass:
@@ -403,6 +405,7 @@ void AutoCookWindow::viewPreheatStep(Cook::Step step) @@ -403,6 +405,7 @@ void AutoCookWindow::viewPreheatStep(Cook::Step step)
403 405
404 void AutoCookWindow::viewDoorStep(Cook::Step step) 406 void AutoCookWindow::viewDoorStep(Cook::Step step)
405 { 407 {
  408 + qDebug() << "viewDoorStep";
406 ui->cookStepLabel->hide(); 409 ui->cookStepLabel->hide();
407 ui->cookStepIcon->hide(); 410 ui->cookStepIcon->hide();
408 ui->doorStepLabel->show(); 411 ui->doorStepLabel->show();
@@ -521,11 +524,9 @@ void AutoCookWindow::doCookStep(Cook::Step step) @@ -521,11 +524,9 @@ void AutoCookWindow::doCookStep(Cook::Step step)
521 524
522 static bool checkReached(int target, int last, int current) 525 static bool checkReached(int target, int last, int current)
523 { 526 {
524 - if (target == current)  
525 - return true;  
526 -  
527 - return ((target > last) && (target <= current))  
528 - || ((target < last) && (target >= current)); 527 + qDebug() << "checkReached" << target << last << current;
  528 + return ((target >= last) && (target <= current))
  529 + || ((target <= last) && (target >= current));
529 } 530 }
530 531
531 void AutoCookWindow::checkPreheatStep(Cook::Step step) 532 void AutoCookWindow::checkPreheatStep(Cook::Step step)
@@ -533,6 +534,9 @@ void AutoCookWindow::checkPreheatStep(Cook::Step step) @@ -533,6 +534,9 @@ void AutoCookWindow::checkPreheatStep(Cook::Step step)
533 if (/*checkReached(step.humidity, lastHumidity, oven->currentHumidity()) 534 if (/*checkReached(step.humidity, lastHumidity, oven->currentHumidity())
534 && */checkReached(step.temp, lastTemp, oven->currentTemp())) 535 && */checkReached(step.temp, lastTemp, oven->currentTemp()))
535 { 536 {
  537 + if (selectedStepIndex == cook->currentStepIndex())
  538 + selectedStepIndex = cook->currentStepIndex() + 1;
  539 +
536 cook->setCurrentStepIndex(cook->currentStepIndex() + 1); 540 cook->setCurrentStepIndex(cook->currentStepIndex() + 1);
537 doStep(); 541 doStep();
538 } 542 }
@@ -540,13 +544,23 @@ void AutoCookWindow::checkPreheatStep(Cook::Step step) @@ -540,13 +544,23 @@ void AutoCookWindow::checkPreheatStep(Cook::Step step)
540 544
541 void AutoCookWindow::checkDoorStep(Cook::Step /*step*/) 545 void AutoCookWindow::checkDoorStep(Cook::Step /*step*/)
542 { 546 {
543 - if (opened && !oven->door()) 547 + qDebug() << "checkDoorStep" << opened << oven->door();
  548 + if (opened)
544 { 549 {
545 - cook->setCurrentStepIndex(cook->currentStepIndex() + 1);  
546 - doStep(); 550 + if (!oven->door())
  551 + {
  552 + if (selectedStepIndex == cook->currentStepIndex())
  553 + selectedStepIndex = cook->currentStepIndex() + 1;
  554 +
  555 + cook->setCurrentStepIndex(cook->currentStepIndex() + 1);
  556 + doStep();
  557 + }
  558 + }
  559 + else
  560 + {
  561 + if (oven->door())
  562 + opened = true;
547 } 563 }
548 - else if (!opened && oven->door())  
549 - opened = true;  
550 } 564 }
551 565
552 void AutoCookWindow::checkCookStep(Cook::Step step) 566 void AutoCookWindow::checkCookStep(Cook::Step step)
@@ -556,6 +570,9 @@ void AutoCookWindow::checkCookStep(Cook::Step step) @@ -556,6 +570,9 @@ void AutoCookWindow::checkCookStep(Cook::Step step)
556 if (/*checkReached(step.humidity, lastHumidity, oven->currentHumidity()) 570 if (/*checkReached(step.humidity, lastHumidity, oven->currentHumidity())
557 && */checkReached(step.temp, lastTemp, oven->currentTemp())) 571 && */checkReached(step.temp, lastTemp, oven->currentTemp()))
558 { 572 {
  573 + if (selectedStepIndex == cook->currentStepIndex())
  574 + selectedStepIndex = cook->currentStepIndex() + 1;
  575 +
559 cook->setCurrentStepIndex(cook->currentStepIndex() + 1); 576 cook->setCurrentStepIndex(cook->currentStepIndex() + 1);
560 doStep(); 577 doStep();
561 } 578 }
@@ -563,6 +580,9 @@ void AutoCookWindow::checkCookStep(Cook::Step step) @@ -563,6 +580,9 @@ void AutoCookWindow::checkCookStep(Cook::Step step)
563 { 580 {
564 if (cook->interTemp() == oven->currentInterTemp()) 581 if (cook->interTemp() == oven->currentInterTemp())
565 { 582 {
  583 + if (selectedStepIndex == cook->currentStepIndex())
  584 + selectedStepIndex = cook->stepCount() - 1;
  585 +
566 cook->setCurrentStepIndex(cook->stepCount() - 1); 586 cook->setCurrentStepIndex(cook->stepCount() - 1);
567 doStep(); 587 doStep();
568 } 588 }
@@ -572,6 +592,8 @@ void AutoCookWindow::checkCookStep(Cook::Step step) @@ -572,6 +592,8 @@ void AutoCookWindow::checkCookStep(Cook::Step step)
572 592
573 void AutoCookWindow::start() 593 void AutoCookWindow::start()
574 { 594 {
  595 + qDebug() << "start";
  596 +
575 started = true; 597 started = true;
576 oven->setTime(cook->time()); 598 oven->setTime(cook->time());
577 oven->setInterTempEnabled(interTempEnabled); 599 oven->setInterTempEnabled(interTempEnabled);
@@ -585,6 +607,7 @@ void AutoCookWindow::start() @@ -585,6 +607,7 @@ void AutoCookWindow::start()
585 607
586 void AutoCookWindow::stop() 608 void AutoCookWindow::stop()
587 { 609 {
  610 + qDebug() << "stop";
588 oven->stop(); 611 oven->stop();
589 checkCookTimer.stop(); 612 checkCookTimer.stop();
590 613
@@ -593,6 +616,7 @@ void AutoCookWindow::stop() @@ -593,6 +616,7 @@ void AutoCookWindow::stop()
593 616
594 void AutoCookWindow::doStep() 617 void AutoCookWindow::doStep()
595 { 618 {
  619 + qDebug() << "doStep";
596 Cook::Step step = cook->currentStep(); 620 Cook::Step step = cook->currentStep();
597 switch (Cook::classify(step.type)) 621 switch (Cook::classify(step.type))
598 { 622 {
@@ -612,6 +636,7 @@ void AutoCookWindow::doStep() @@ -612,6 +636,7 @@ void AutoCookWindow::doStep()
612 636
613 void AutoCookWindow::checkCook() 637 void AutoCookWindow::checkCook()
614 { 638 {
  639 + qDebug() << "checkCook";
615 Cook::Step step = cook->currentStep(); 640 Cook::Step step = cook->currentStep();
616 switch (Cook::classify(step.type)) 641 switch (Cook::classify(step.type))
617 { 642 {
app/gui/oven_control/cook.cpp
@@ -62,7 +62,7 @@ int AbstractCook::currentStepIndex() @@ -62,7 +62,7 @@ int AbstractCook::currentStepIndex()
62 62
63 void AbstractCook::setCurrentStepIndex(int index) 63 void AbstractCook::setCurrentStepIndex(int index)
64 { 64 {
65 - if (index < stepCount_) 65 + if (index < stepCount_ && index >= 0)
66 currentStep_ = index; 66 currentStep_ = index;
67 } 67 }
68 68
app/gui/oven_control/mainwindow.ui
@@ -1647,7 +1647,7 @@ QPushButton#primeButton:pressed { @@ -1647,7 +1647,7 @@ QPushButton#primeButton:pressed {
1647 </font> 1647 </font>
1648 </property> 1648 </property>
1649 <property name="text"> 1649 <property name="text">
1650 - <string>V0.1.1</string> 1650 + <string>V0.1.2</string>
1651 </property> 1651 </property>
1652 <property name="alignment"> 1652 <property name="alignment">
1653 <set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set> 1653 <set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
app/gui/oven_control/ovencontroller.cpp
@@ -12,8 +12,21 @@ void OvenController::setUdpHandler(UdpHandler *udp) @@ -12,8 +12,21 @@ void OvenController::setUdpHandler(UdpHandler *udp)
12 12
13 void OvenController::onDataChanged() 13 void OvenController::onDataChanged()
14 { 14 {
  15 + bool opened = state.door_state != 0;
  16 +
15 udp->fillControl(control); 17 udp->fillControl(control);
16 udp->fillData(state); 18 udp->fillData(state);
  19 +
  20 + if (opened)
  21 + {
  22 + if (state.door_state == 0)
  23 + emit doorClosed();
  24 + }
  25 + else
  26 + {
  27 + if (state.door_state != 0)
  28 + emit doorOpened();
  29 + }
17 } 30 }
18 31
19 int OvenController::currentTemp() 32 int OvenController::currentTemp()
@@ -34,7 +47,7 @@ int OvenController::currentInterTemp() @@ -34,7 +47,7 @@ int OvenController::currentInterTemp()
34 47
35 bool OvenController::door() 48 bool OvenController::door()
36 { 49 {
37 - return state.door_state; 50 + return state.door_state != 0;
38 } 51 }
39 52
40 void OvenController::setHumidity(int percentage) 53 void OvenController::setHumidity(int percentage)
app/gui/oven_control/udphandler.cpp
@@ -43,18 +43,20 @@ void UdpHandler::readPendingDatagrams() @@ -43,18 +43,20 @@ void UdpHandler::readPendingDatagrams()
43 43
44 void UdpHandler::processDatagram(QByteArray &datagram) 44 void UdpHandler::processDatagram(QByteArray &datagram)
45 { 45 {
46 - qDebug() << "Received";  
47 sock->writeDatagram(datagram, QHostAddress("192.168.4.191"), 4000); 46 sock->writeDatagram(datagram, QHostAddress("192.168.4.191"), 4000);
48 packet_t *packet = (packet_t *) datagram.data(); 47 packet_t *packet = (packet_t *) datagram.data();
49 switch (packet->header) 48 switch (packet->header)
50 { 49 {
51 case HDR_OVEN_CONTROL: 50 case HDR_OVEN_CONTROL:
  51 + qDebug() << "Received Control";
52 processControl((oven_control_t *) packet->body); 52 processControl((oven_control_t *) packet->body);
53 break; 53 break;
54 case HDR_OVEN_STATE: 54 case HDR_OVEN_STATE:
  55 + qDebug() << "Received State";
55 processState((oven_state_t *) packet->body); 56 processState((oven_state_t *) packet->body);
56 break; 57 break;
57 case HDR_ERROR_CODE: 58 case HDR_ERROR_CODE:
  59 + qDebug() << "Received Error";
58 break; 60 break;
59 } 61 }
60 } 62 }