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