From 6a81d38e4cef99a38cc392c4483816492e917114 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 18 Apr 2017 17:08:06 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EC=9A=94=EB=A6=AC=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EB=A1=9C=EC=A7=81=20=EC=A0=84=EB=A9=B4=20?= =?UTF-8?q?=EC=9E=AC=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui/oven_control/autocook.cpp | 522 ++++ app/gui/oven_control/autocook.h | 42 + app/gui/oven_control/autocookconfigwindow.cpp | 178 +- app/gui/oven_control/autocookconfigwindow.h | 17 +- app/gui/oven_control/autocookconfigwindow.ui | 257 +- app/gui/oven_control/autocookselectionwindow.cpp | 34 +- app/gui/oven_control/autocookselectionwindow.h | 9 +- app/gui/oven_control/autocookwindow.cpp | 1129 +++---- app/gui/oven_control/autocookwindow.h | 73 +- app/gui/oven_control/autocookwindow.ui | 3516 ++++++++-------------- app/gui/oven_control/cook.cpp | 754 ++--- app/gui/oven_control/cook.h | 227 +- app/gui/oven_control/cookbook.cpp | 102 + app/gui/oven_control/cookbook.h | 29 + app/gui/oven_control/define.cpp | 495 +++ app/gui/oven_control/define.h | 118 + app/gui/oven_control/keepwarmpopup.cpp | 34 + app/gui/oven_control/keepwarmpopup.h | 32 + app/gui/oven_control/keepwarmpopup.ui | 362 +++ app/gui/oven_control/oven_control.pro | 17 +- app/gui/oven_control/preheattempgauge.cpp | 19 +- app/gui/oven_control/preheattempgauge.h | 4 +- 22 files changed, 4016 insertions(+), 3954 deletions(-) create mode 100644 app/gui/oven_control/autocook.cpp create mode 100644 app/gui/oven_control/autocook.h create mode 100644 app/gui/oven_control/cookbook.cpp create mode 100644 app/gui/oven_control/cookbook.h create mode 100644 app/gui/oven_control/define.cpp create mode 100644 app/gui/oven_control/define.h create mode 100644 app/gui/oven_control/keepwarmpopup.cpp create mode 100644 app/gui/oven_control/keepwarmpopup.h create mode 100644 app/gui/oven_control/keepwarmpopup.ui diff --git a/app/gui/oven_control/autocook.cpp b/app/gui/oven_control/autocook.cpp new file mode 100644 index 0000000..a2d93cb --- /dev/null +++ b/app/gui/oven_control/autocook.cpp @@ -0,0 +1,522 @@ +#include "autocook.h" + +AutoCook::AutoCook() : currentStepIndex(0), done_(false), doorOpened(false), checkingCoreTemp(false) +{ + +} + +AutoCook::AutoCook(Cook cook) : AutoCook() +{ + this->cook = cook; + for (int idx = 0; idx < this->cook.steps.size(); idx++) + this->cook.steps[idx].time *= 1000; + + + startStep(); +} + +void AutoCook::startStep() +{ + Oven *oven = Oven::getInstance(); + + CookStep ¤tStep = cook.steps[currentStepIndex]; + switch (Define::classify(currentStep.type)) + { + case Define::PreheatClass: + startHumidity = oven->currentHumidity(); + startTemp = oven->currentTemp(); + isWaitingDoorOpened_ = false; + oven->setMode(Oven::CombinationMode); + oven->setHumidity(currentStep.humidity); + oven->setTemp(currentStep.temp); + oven->setFan(currentStep.fan); + oven->startPreheating(); + break; + case Define::DoorClass: + isWaitingDoorOpened_ = true; + break; + case Define::CookClass: + startHumidity = oven->currentHumidity(); + startTemp = oven->currentTemp(); + isWaitingDoorOpened_ = false; + oven->setMode(Oven::CombinationMode); + oven->setHumidity(currentStep.humidity); + oven->setTemp(currentStep.temp); + oven->setFan(currentStep.fan); + oven->setTime(remainingTime() + 300); + + if (cook.isCoreTempValid()) + { + oven->setInterTemp(cook.coreTemp()); + oven->setInterTempEnabled(true); + } + else + oven->setInterTempEnabled(false); + + if (currentStep.dehumidification) + { + if (currentStep.dehumidificationRepeatDelay) + oven->repeatDamper(currentStep.dehumidification, currentStep.dehumidificationRepeatDelay, currentStep.dehumidificationRepeatCount); + else + oven->openDamper(currentStep.dehumidification); + } + + if (currentStep.humidification) + { + if (currentStep.humidificationRepeatDelay) + oven->repeatHumidification(currentStep.humidification, currentStep.humidificationRepeatDelay, currentStep.humidificationRepeatCount); + else + oven->startHumidification(currentStep.humidification); + } + + stepStartTime.start(); + oven->startCooking(); + case Define::InvalidClass: + break; + } + + advance(); +} + +void AutoCook::nextStep() +{ + qDebug() << "Next Step Before" << remainingTime(); + + Oven *oven = Oven::getInstance(); + + CookStep ¤tStep = cook.steps[currentStepIndex]; + CookStep &nextStep = cook.steps[currentStepIndex + 1]; + + Define::StepClass currentClass = Define::classify(currentStep.type); + Define::StepClass nextClass = Define::classify(nextStep.type); + + if (currentClass == Define::PreheatClass && nextClass == Define::DoorClass) + { + oven->stopPreheating(); + isWaitingDoorOpened_ = true; + } + else if (currentClass == Define::DoorClass && nextClass == Define::CookClass) + { + startHumidity = oven->currentHumidity(); + startTemp = oven->currentTemp(); + oven->setHumidity(nextStep.humidity); + oven->setTemp(nextStep.temp); + oven->setFan(nextStep.fan); + oven->setTime(remainingTime() + 300); + + if (cook.isCoreTempValid()) + { + oven->setInterTemp(cook.coreTemp()); + oven->setInterTempEnabled(true); + } + else + oven->setInterTempEnabled(false); + + stepStartTime.start(); + oven->startCooking(); + + if (nextStep.dehumidification) + { + if (nextStep.dehumidificationRepeatDelay) + oven->repeatDamper(nextStep.dehumidification, nextStep.dehumidificationRepeatDelay, nextStep.dehumidificationRepeatCount); + else + oven->openDamper(nextStep.dehumidification); + } + + if (nextStep.humidification) + { + if (nextStep.humidificationRepeatDelay) + oven->repeatHumidification(nextStep.humidification, nextStep.humidificationRepeatDelay, nextStep.humidificationRepeatCount); + else + oven->startHumidification(nextStep.humidification); + } + + if (checkingCoreTemp && currentStepIndex + 2 >= cook.steps.size()) + { + lastCoreTempIncreasedTime.start(); + } + } + else if (currentClass == Define::CookClass && nextClass == Define::CookClass) + { + startHumidity = oven->currentHumidity(); + startTemp = oven->currentTemp(); + oven->setHumidity(nextStep.humidity); + oven->setTemp(nextStep.temp); + oven->setFan(nextStep.fan); + stepStartTime.start(); + + if (currentStep.dehumidification) + { + if (nextStep.dehumidification) + { + if (currentStep.dehumidificationRepeatDelay) + { + if (nextStep.dehumidificationRepeatDelay) + oven->repeatDamper(nextStep.dehumidification, nextStep.dehumidificationRepeatDelay, nextStep.dehumidificationRepeatCount); + else + { + oven->stopRepeatDamper(); + oven->openDamper(nextStep.dehumidification); + } + } + else + { + if (nextStep.dehumidificationRepeatDelay) + oven->repeatDamper(nextStep.dehumidification, nextStep.dehumidificationRepeatDelay, nextStep.dehumidificationRepeatCount); + else + oven->openDamper(nextStep.dehumidification); + } + } + else + { + if (currentStep.dehumidificationRepeatDelay) + oven->stopRepeatDamper(); + } + } + else + { + if (nextStep.dehumidification) + { + if (nextStep.dehumidificationRepeatDelay) + oven->repeatDamper(nextStep.dehumidification, nextStep.dehumidificationRepeatDelay, nextStep.dehumidificationRepeatCount); + else + oven->openDamper(nextStep.dehumidification); + } + } + + if (nextStep.humidification != currentStep.humidification + || nextStep.humidificationRepeatDelay != currentStep.humidificationRepeatDelay + || nextStep.humidificationRepeatCount != currentStep.humidificationRepeatCount) + { + if (nextStep.humidificationRepeatDelay) + { + if (currentStep.humidificationRepeatDelay) + oven->repeatHumidification(nextStep.humidification, nextStep.humidificationRepeatDelay, nextStep.humidificationRepeatCount); + else + { + oven->stopHumidification(); + oven->repeatHumidification(nextStep.humidification, nextStep.humidificationRepeatDelay, nextStep.humidificationRepeatCount); + } + } + else + { + if (currentStep.humidificationRepeatDelay) + { + oven->stopRepeatHumidification(); + oven->startHumidification(nextStep.humidification); + } + else + oven->startHumidification(nextStep.humidification); + } + } + + if (checkingCoreTemp && currentStepIndex + 2 >= cook.steps.size()) + { + lastCoreTempIncreasedTime.start(); + } + } + else if (currentClass == Define::CookClass && nextClass == Define::DoorClass) + { + if (currentStep.dehumidification) + { + if (currentStep.dehumidificationRepeatDelay) + oven->stopRepeatDamper(); + else + oven->closeDamper(); + } + + if (currentStep.humidification) + { + if (currentStep.humidificationRepeatDelay) + oven->stopRepeatHumidification(); + else + oven->stopHumidification(); + } + + oven->stopCooking(); + isWaitingDoorOpened_ = true; + } + + currentStepIndex++; + + advance(); + + qDebug() << "Next Step After" << remainingTime(); +} + +bool AutoCook::advance() +{ + Oven *oven = Oven::getInstance(); + + CookStep ¤tStep = cook.steps[currentStepIndex]; + switch (Define::classify(currentStep.type)) + { + case Define::PreheatClass: + if (oven->currentHumidity() >= currentStep.humidity + && oven->currentTemp() >= currentStep.temp) + { + nextStep(); + + return true; + } + break; + case Define::DoorClass: + if (isWaitingDoorOpened_) + { + if (oven->door()) + { + isWaitingDoorOpened_ = false; + + return true; + } + } + else + { + if (!oven->door()) + { + nextStep(); + + return true; + } + } + break; + case Define::CookClass: + { + if (oven->door()) + { + if (!doorOpened) + { + doorOpened = true; + + if (checkingCoreTemp && currentStepIndex + 1 >= cook.steps.size()) + { + currentStep.time -= lastCoreTempIncreasedTime.elapsed(); + } + else + { + currentStep.time -= stepStartTime.elapsed(); + } + } + + return false; + } + else if (doorOpened) + { + doorOpened = false; + stepStartTime.start(); + lastCoreTempIncreasedTime.start(); + lastCoreTempChangedTime.start(); + } + + int remainingCurrentStepTime = currentStep.time; + if (checkingCoreTemp && currentStepIndex + 1 >= cook.steps.size()) + remainingCurrentStepTime -= lastCoreTempIncreasedTime.elapsed(); + else + remainingCurrentStepTime -= stepStartTime.elapsed(); + + if (remainingCurrentStepTime <= 0) + { + if (currentStepIndex + 1 < cook.steps.size()) + { + nextStep(); + + return true; + } + else + { + done_ = true; + + if (currentStep.dehumidification) + { + if (currentStep.dehumidificationRepeatDelay) + oven->stopRepeatDamper(); + else + oven->closeDamper(); + } + + if (currentStep.humidification) + { + if (currentStep.humidificationRepeatDelay) + oven->stopRepeatHumidification(); + else + oven->stopHumidification(); + } + + oven->stopCooking(); + + return true; + } + } + else if (cook.isCoreTempValid() && oven->isInterTempValid()) + { + if (!checkingCoreTemp) + { + checkingCoreTemp = true; + lastCoreTemp = oven->currentInterTemp(); + lastIncreasedCoreTemp = lastCoreTemp; + lastCoreTempChangedTime.start(); + lastCoreTempIncreasedTime.start(); + } + + + int currentCoreTemp = oven->currentInterTemp(); + if (currentCoreTemp >= cook.coreTemp()) + { + done_ = true; + + if (currentStep.dehumidification) + { + if (currentStep.dehumidificationRepeatDelay) + oven->stopRepeatDamper(); + else + oven->closeDamper(); + } + + if (currentStep.humidification) + { + if (currentStep.humidificationRepeatDelay) + oven->stopRepeatHumidification(); + else + oven->stopHumidification(); + } + + oven->stopCooking(); + + currentStepIndex = cook.steps.size() - 1; + + return true; + } + else if (currentCoreTemp != lastCoreTemp) + { + if (currentCoreTemp > lastIncreasedCoreTemp) + { + if (currentStepIndex + 1 < cook.steps.size()) + { + int otherStepsTime = 0; + for (int idx = currentStepIndex; idx + 1 < cook.steps.size(); idx++) + otherStepsTime += cook.steps[idx].time; + + otherStepsTime -= stepStartTime.elapsed(); + + int expectedRemainingTime = (cook.coreTemp() - currentCoreTemp) * lastCoreTempChangedTime.elapsed() / (currentCoreTemp - lastCoreTemp); + int expectedLastStepRemainingTime = expectedRemainingTime - otherStepsTime; + + CookStep &lastStep = cook.steps[cook.steps.size() - 1]; + lastStep.time = qMax(expectedLastStepRemainingTime, 30000); + + lastIncreasedCoreTemp = currentCoreTemp; + lastCoreTempIncreasedTime.start(); + } + else + { + CookStep &lastStep = cook.steps[cook.steps.size() - 1]; + + int expectedRemainingTime = (cook.coreTemp() - currentCoreTemp) * lastCoreTempChangedTime.elapsed() / (currentCoreTemp - lastCoreTemp); + + qDebug() << "cook.coreTemp()" << cook.coreTemp(); + qDebug() << "currentCoreTemp" << currentCoreTemp; + qDebug() << "lastCoreTemp" << lastCoreTemp; + qDebug() << "lastCoreTempChangedTime.elapsed()" << lastCoreTempChangedTime.elapsed(); + qDebug() << "expectedRemainingTime" << expectedRemainingTime; + + if (expectedRemainingTime > 30000) + { + lastStep.time = expectedRemainingTime; + lastCoreTempIncreasedTime.start(); + } + else + { + int currentRemainingTime = lastStep.time - lastCoreTempIncreasedTime.elapsed(); + + qDebug() << "lastCoreTempIncreasedTime" << lastCoreTempIncreasedTime; + qDebug() << "currentRemainingTime" << currentRemainingTime; + + if (currentRemainingTime > 30000) + { + lastStep.time = 30000; + lastCoreTempIncreasedTime.start(); + } + else if (expectedRemainingTime > currentRemainingTime) + { + lastStep.time = expectedRemainingTime; + lastCoreTempIncreasedTime.start(); + } + } + } + } + + lastCoreTemp = currentCoreTemp; + lastCoreTempChangedTime.start(); + } + + +// int currentCoreTemp = oven->currentInterTemp(); +// if (currentCoreTemp != lastCoreTemp) +// { +// int remainingStepsTime = 0; +// for (int idx = currentStepIndex + 1; idx < cook.steps.size(); idx++) +// remainingStepsTime += cook.steps[idx].time; + +// int currentRemainingTime = currentStep.time - lastCoreTempTime.elapsed() + remainingStepsTime; +// int expectedTime = (cook.coreTemp() - currentCoreTemp) * qAbs(lastCoreTempTime.elapsed() / (currentCoreTemp - lastCoreTemp)); +// int expectedCurrentStepTime = expectedTime - remainingStepsTime; + +// for (int idx = currentStepIndex; idx < cook.steps.size(); idx++) +// { +// CookStep &step = cook.steps[idx]; +// if (expectedCurrentStepTime > 0) +// { +// step.time = expectedCurrentStepTime; +// break; +// } +// else +// { +// expectedCurrentStepTime += step.time; +// step.time = 0; +// } +// } + +// lastCoreTemp = oven->currentInterTemp(); +// lastCoreTempTime.start(); +// stepStartTime.start(); + +// advance(); + +// return true; +// } + } + } + case Define::InvalidClass: + break; + } + + return false; +} + +int AutoCook::remainingTime() +{ + if (done_) + { + return 0; + } + else if (checkingCoreTemp && currentStepIndex + 1 >= cook.steps.size()) + { + CookStep &step = cook.steps[cook.steps.size() - 1]; + int t = step.time; + if (!doorOpened) + t -= lastCoreTempIncreasedTime.elapsed(); + + return t / 1000; + } + else + { + int t = 0; + for (int i = currentStepIndex; i < cook.steps.size(); i++) + t += cook.steps[i].time; + + if (!doorOpened && Define::classify(cook.steps[currentStepIndex].type) == Define::CookClass) + t -= stepStartTime.elapsed(); + + return t / 1000; + } +} diff --git a/app/gui/oven_control/autocook.h b/app/gui/oven_control/autocook.h new file mode 100644 index 0000000..3788089 --- /dev/null +++ b/app/gui/oven_control/autocook.h @@ -0,0 +1,42 @@ +#ifndef AUTOCOOK_H +#define AUTOCOOK_H + +#include "oven.h" +#include "cook.h" + +class AutoCook +{ +public: + AutoCook(); + AutoCook(Cook cook); + + void startStep(); + void nextStep(); + + bool advance(); + + int remainingTime(); + bool isWaitingDoorOpened() { return isWaitingDoorOpened_; } + bool done() { return done_; } + + Cook cook; + int currentStepIndex; + + int startHumidity; + int startTemp; + +private: + bool done_; + bool isWaitingDoorOpened_; + + bool doorOpened; + + QTime stepStartTime; + bool checkingCoreTemp; + int lastCoreTemp; + int lastIncreasedCoreTemp; + QTime lastCoreTempChangedTime; + QTime lastCoreTempIncreasedTime; +}; + +#endif // AUTOCOOK_H diff --git a/app/gui/oven_control/autocookconfigwindow.cpp b/app/gui/oven_control/autocookconfigwindow.cpp index d30f026..6f6e66f 100644 --- a/app/gui/oven_control/autocookconfigwindow.cpp +++ b/app/gui/oven_control/autocookconfigwindow.cpp @@ -1,7 +1,9 @@ #include "autocookconfigwindow.h" #include "ui_autocookconfigwindow.h" -AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, AbstractCook *cook) : +#include "autocookwindow.h" + +AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Cook cook) : QMainWindow(parent), ui(new Ui::AutoCookConfigWindow), oven(oven), @@ -12,13 +14,9 @@ AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Abstract ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); - ui->cookTypeIcon->setPixmap(Cook::icon(cook->type())); - ui->selectCookButton->setText(cook->name()); - configWidgets.append( ConfigWidget { ui->configButton_1, - ui->configBlock_1, ui->configMinLabel_1, ui->configMaxLabel_1, ui->configCurrentLabel_1, @@ -27,7 +25,6 @@ AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Abstract configWidgets.append( ConfigWidget { ui->configButton_2, - ui->configBlock_2, ui->configMinLabel_2, ui->configMaxLabel_2, ui->configCurrentLabel_2, @@ -36,7 +33,6 @@ AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Abstract configWidgets.append( ConfigWidget { ui->configButton_3, - ui->configBlock_3, ui->configMinLabel_3, ui->configMaxLabel_3, ui->configCurrentLabel_3, @@ -45,7 +41,6 @@ AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Abstract configWidgets.append( ConfigWidget { ui->configButton_4, - ui->configBlock_4, ui->configMinLabel_4, ui->configMaxLabel_4, ui->configCurrentLabel_4, @@ -54,21 +49,46 @@ AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Abstract configWidgets.append( ConfigWidget { ui->configButton_5, - ui->configBlock_5, ui->configMinLabel_5, ui->configMaxLabel_5, ui->configCurrentLabel_5, ui->configSlider_5 }); + cookStartTimer.setSingleShot(true); + cookStartTimer.setInterval(3000); + connect(&cookStartTimer, SIGNAL(timeout()), SLOT(start())); + + foreach (ConfigWidget w, configWidgets) + { + connect(w.button, SIGNAL(pressed()), SLOT(stopTimer())); + connect(w.button, SIGNAL(released()), SLOT(startTimer())); + connect(w.slider, SIGNAL(sliderPressed()), SLOT(stopTimer())); + connect(w.slider, SIGNAL(sliderReleased()), SLOT(startTimer())); + } + + setupUi(); + + startTimer(); +} + +AutoCookConfigWindow::~AutoCookConfigWindow() +{ + delete ui; +} + +void AutoCookConfigWindow::setupUi() +{ + ui->cookTypeIcon->setPixmap(Define::icon(cook.type)); + ui->selectCookButton->setText(cook.name); + for (int idx = 0; idx < 5; idx++) { - AbstractCookConfig *config = cook->configurations[idx]; - if (config == NULL) + CookConfig config = cook.configs[idx]; + if (config.type == Define::ConfigNotUsed) { ConfigWidget cw = configWidgets.at(idx); cw.button->hide(); - cw.block->hide(); cw.minimum->hide(); cw.maximum->hide(); cw.current->hide(); @@ -78,29 +98,29 @@ AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Abstract { ConfigWidget cw = configWidgets.at(idx); cw.button->setStyleSheet( - "QPushButton { border-image: url(" - + config->icon() - + ") } QPushButton::pressed { border-image: url(" - + config->overlayIcon() + "QPushButton { image: url(" + + Define::icon(config.type) + + ") } QPushButton::pressed { image: url(" + + Define::iconOverlay(config.type) + ") }"); - cw.minimum->setText(config->minLabel()); - cw.maximum->setText(config->maxLabel()); + cw.minimum->setText(Define::minimum(config.type)); + cw.maximum->setText(Define::maximum(config.type)); cw.slider->blockSignals(true); cw.slider->setMinimum(1); - cw.slider->setMaximum(config->count()); - cw.slider->setValue(config->current()); + cw.slider->setMaximum(config.maximum); + cw.slider->setValue(config.current); cw.slider->blockSignals(false); - switch (config->type()) + switch (config.type) { - case Cook::Time: + case Define::Time: cw.slider->setProperty("sliderColor", "white"); break; - case Cook::BurnDegree: + case Define::BurnDegree: cw.slider->setProperty("sliderColor", "yellow"); break; - case Cook::Brightness: + case Define::Brightness: cw.slider->setProperty("sliderColor", "red"); break; default: @@ -108,61 +128,32 @@ AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Abstract break; } - cw.slider->style()->unpolish(cw.slider); - cw.slider->style()->polish(cw.slider); - cw.slider->update(); +// cw.slider->style()->unpolish(cw.slider); +// cw.slider->style()->polish(cw.slider); +// cw.slider->update(); connect(cw.slider, SIGNAL(valueChanged(int)), SLOT(updateConfig())); } } - if (cook->interTempEnabled()) - { - interTempEnabled = true; - - ConfigWidget cw = configWidgets.at(3); - cw.button->show(); - cw.button->setStyleSheet( - "QPushButton {" - " border-image: url(:/images/images/auto/011_icon_04_ov_01.png)" - "} QPushButton::pressed {" - " border-image: url(:/images/images/auto/011_icon_04_ov.png)" - "}"); - - cw.block->show(); - cw.minimum->hide(); - cw.maximum->hide(); - cw.current->hide(); - cw.slider->hide(); - - connect(cw.button, SIGNAL(clicked()), SLOT(changeInterTemp())); - } - -} - -AutoCookConfigWindow::~AutoCookConfigWindow() -{ - delete ui; + updateView(); } void AutoCookConfigWindow::updateView() { for (int idx = 0; idx < 5; idx++) { - if (interTempEnabled && idx == 3) - continue; - - AbstractCookConfig *config = cook->configurations[idx]; - if (config == NULL) + CookConfig config = cook.configs[idx]; + if (config.type == Define::ConfigNotUsed) continue; ConfigWidget cw = configWidgets.at(idx); - switch (config->type()) + switch (config.type) { - case Cook::Time: + case Define::Time: { - int time = cook->time(); + int time = cook.time(); if (time >= 3600) cw.current->setText(QString().sprintf( "%d" @@ -186,43 +177,54 @@ void AutoCookConfigWindow::updateView() time)); break; } - case Cook::BurnDegree: - cw.slider->setProperty("sliderColor", "yellow"); - break; - case Cook::Brightness: - cw.slider->setProperty("sliderColor", "red"); + case Define::BurnDegree: + cw.current->setText(QString().sprintf( + "%d" + "", + cook.coreTemp())); break; default: - cw.slider->setProperty("sliderColor", "blue"); + cw.current->setText(QString().sprintf( + "%d" + "/%d", + config.current, config.maximum)); break; } } - - if (cook->interTempEnabled()) - { - ConfigWidget cw = configWidgets.at(3); - cw.button->show(); - cw.button->setStyleSheet( - "QPushButton {" - " border-image: url(:/images/images/auto/011_icon_04_ov_01.png)" - "} QPushButton::pressed {" - " border-image: url(:/images/images/auto/011_icon_04_ov.png)" - "}"); - - cw.block->show(); - cw.minimum->hide(); - cw.maximum->hide(); - cw.current->hide(); - cw.slider->hide(); - } } void AutoCookConfigWindow::updateConfig() { + cook.setConfig(ui->configSlider_1->value(), + ui->configSlider_2->value(), + ui->configSlider_3->value(), + ui->configSlider_4->value(), + ui->configSlider_5->value()); + + updateView(); +} + +void AutoCookConfigWindow::startTimer() +{ + cookStartTimer.start(); +} + +void AutoCookConfigWindow::stopTimer() +{ + cookStartTimer.stop(); +} + +void AutoCookConfigWindow::start() +{ + close(); + AutoCookWindow *w = new AutoCookWindow(parentWidget(), cook); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); } -void AutoCookConfigWindow::changeInterTemp() +void AutoCookConfigWindow::on_backButton_clicked() { - cook->setInterTempEnabled(!cook->interTempEnabled()); + close(); } diff --git a/app/gui/oven_control/autocookconfigwindow.h b/app/gui/oven_control/autocookconfigwindow.h index 5f594b3..b7eba44 100644 --- a/app/gui/oven_control/autocookconfigwindow.h +++ b/app/gui/oven_control/autocookconfigwindow.h @@ -8,7 +8,8 @@ #include #include "oven.h" -#include "cook.h" +//#include "cook.h" +#include "cookbook.h" namespace Ui { class AutoCookConfigWindow; @@ -19,20 +20,19 @@ class AutoCookConfigWindow : public QMainWindow Q_OBJECT public: - explicit AutoCookConfigWindow(QWidget *parent = 0, Oven *oven = 0, AbstractCook *cook = 0); + explicit AutoCookConfigWindow(QWidget *parent = 0, Oven *oven = 0, + Cook cook = Cook(Define::Poultry, "/prime/cookbook/poultry/chicken", "Chicken")); ~AutoCookConfigWindow(); private: Ui::AutoCookConfigWindow *ui; Oven *oven; - AbstractCook *cook; + Cook cook; QTimer cookStartTimer; - bool interTempEnabled; struct ConfigWidget { QPushButton *button; - QWidget *block; QLabel *minimum; QLabel *maximum; QLabel *current; @@ -42,9 +42,14 @@ private: QList configWidgets; private slots: + void setupUi(); void updateView(); void updateConfig(); - void changeInterTemp(); + void startTimer(); + void stopTimer(); + void start(); + + void on_backButton_clicked(); }; #endif // AUTOCOOKCONFIGWINDOW_H diff --git a/app/gui/oven_control/autocookconfigwindow.ui b/app/gui/oven_control/autocookconfigwindow.ui index 89046ea..ca5e35b 100644 --- a/app/gui/oven_control/autocookconfigwindow.ui +++ b/app/gui/oven_control/autocookconfigwindow.ui @@ -14,11 +14,11 @@ MainWindow - #centralwidget { background-image: url(:/images/background/auto_config.png); } + #centralwidget { background-image: url(:/images/background/auto.png); } #bottomBar { background-image: url(:/images/bottom_bar/background.png); } QSlider::groove { -background-image: url(:/images/images/auto/gau_04.png); +background-image: url(:/images/slider/groove.png); background-repeat: no-repeat; background-position: center; } @@ -30,31 +30,38 @@ margin: 0px 5px; } QSlider[sliderColor="red"]::sub-page { -background-image: url(:/images/images/auto/gau_05.png); +background-image: url(:/images/slider/sub_red.png); } QSlider[sliderColor="yellow"]::sub-page { -background-image: url(:/images/images/auto/gau_06.png); +background-image: url(:/images/slider/sub_yellow.png); } QSlider[sliderColor="white"]::sub-page { -background-image: url(:/images/images/auto/gau_07.png); +background-image: url(:/images/slider/sub_white.png); } QSlider[sliderColor="blue"]::sub-page { -background-image: url(:/images/images/auto/gau_09.png); +background-image: url(:/images/slider/sub_blue.png); } QSlider[sliderColor="green"]::sub-page { -background-image: url(:/images/images/auto/sys_icon_01_gau.png); +background-image: url(:/images/slider/sub_green.png); } QSlider::handle { -background-image: url(:/images/images/manual/graphe_BTN_Bigsize.png); +background-image: url(:/images/slider/handle_big.png); background-repeat: no-repeat; background-position: center; width: 23px; height: 33px; +} + +QPushButton[style="icon"] { +background-image: url(:/images/slider_icon/background.png); +background-repeat: no-repeat; +background-position: center; +border: none; } @@ -109,14 +116,14 @@ height: 33px; - QPushButton { border-image: url(:/images/images/auto/006_sys_icon_03.png); } -QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_03_ov.png); } + QPushButton { border-image: url(:/images/bottom_bar/back.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } - + 514 @@ -132,14 +139,14 @@ QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_03_ov. - QPushButton { border-image: url(:/images/images/auto/006_sys_icon_05.png); } -QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_05_ov.png); } + QPushButton { border-image: url(:/images/bottom_bar/wash.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/wash_ov.png); } - + 288 @@ -155,14 +162,14 @@ QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_05_ov. - QPushButton { border-image: url(:/images/images/auto/006_sys_icon_01.png); } -QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_01_ov.png); } + QPushButton { border-image: url(:/images/bottom_bar/config.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } - + 627 @@ -178,14 +185,14 @@ QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_01_ov. - QPushButton { border-image: url(:/images/images/auto/006_sys_icon_02.png); } -QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_02_ov.png); } + QPushButton { border-image: url(:/images/bottom_bar/help.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); } - + 401 @@ -201,7 +208,8 @@ QPushButton:pressed { border-image: url(:/images/images/auto/006_sys_icon_02_ov. - + QPushButton { border-image: url(:/images/bottom_bar/favorites.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/favorites_ov.png); } @@ -632,8 +640,8 @@ border-image: url(:/images/button/152_ov.png); - - :/images/images/auto/btn_icon_01.png:/images/images/auto/btn_icon_01.png + + :/images/auto_button/btn_icon_01.png:/images/auto_button/btn_icon_01.png @@ -645,25 +653,18 @@ border-image: url(:/images/button/152_ov.png); - 49 - 627 - 96 - 96 + 27 + 605 + 140 + 140 - - QPushButton { - border-image: url(:/images/images/manual/011_icon_01.png); -} - -QPushButton:pressed { - border-image: url(:/images/images/manual/011_icon_01_ov.png); -} - - + + icon + @@ -693,25 +694,18 @@ QPushButton:pressed { - 49 - 1137 - 96 - 96 + 27 + 1115 + 140 + 140 - - QPushButton { - border-image: url(:/images/images/manual/011_icon_01.png); -} - -QPushButton:pressed { - border-image: url(:/images/images/manual/011_icon_01_ov.png); -} - - + + icon + @@ -775,32 +769,6 @@ QPushButton:pressed { Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - 27 - 935 - 140 - 140 - - - - background-image: url(:/images/images/manual/010_icon_block.png); - - - - - - 27 - 1115 - 140 - 140 - - - - background-image: url(:/images/images/manual/010_icon_block.png); - - @@ -1042,25 +1010,18 @@ QPushButton:pressed { - 49 - 787 - 96 - 96 + 27 + 765 + 140 + 140 - - QPushButton { - border-image: url(:/images/images/manual/011_icon_01.png); -} - -QPushButton:pressed { - border-image: url(:/images/images/manual/011_icon_01_ov.png); -} - - + + icon + @@ -1124,19 +1085,6 @@ QPushButton:pressed { Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - 27 - 765 - 140 - 140 - - - - background-image: url(:/images/images/manual/010_icon_block.png); - - true @@ -1346,20 +1294,7 @@ QPushButton:pressed { Qt::AlignCenter - - - - 27 - 605 - 140 - 140 - - - - background-image: url(:/images/images/manual/010_icon_block.png); - - - + 27 @@ -1368,32 +1303,12 @@ QPushButton:pressed { 140 - - background-image: url(:/images/images/manual/010_icon_block.png); - - - - - - 49 - 1307 - 96 - 96 - - - - QPushButton { - border-image: url(:/images/images/manual/011_icon_01.png); -} - -QPushButton:pressed { - border-image: url(:/images/images/manual/011_icon_01_ov.png); -} - - + + icon + @@ -1487,25 +1402,18 @@ QPushButton:pressed { - 49 - 957 - 96 - 96 + 27 + 935 + 140 + 140 - - QPushButton { - border-image: url(:/images/images/manual/011_icon_01.png); -} - -QPushButton:pressed { - border-image: url(:/images/images/manual/011_icon_01_ov.png); -} - - + + icon + @@ -1538,41 +1446,6 @@ QPushButton:pressed { 1 - configBlock_4 - configBlock_2 - configBlock_1 - upperStack - bottomBar - configMaxLabel_5 - configMinLabel_5 - selectCookButton - configCurrentLabel_2 - configMaxLabel_3 - configMinLabel_3 - configMinLabel_4 - pushButton_4 - configButton_1 - configSlider_4 - configButton_4 - configMaxLabel_2 - configBlock_3 - configSlider_2 - configCurrentLabel_5 - configMinLabel_2 - configSlider_3 - configMaxLabel_4 - configButton_2 - configMinLabel_1 - configMaxLabel_1 - configCurrentLabel_3 - configCurrentLabel_1 - cookTypeIcon - configBlock_5 - configButton_5 - configSlider_5 - configCurrentLabel_4 - configButton_3 - configSlider_1 @@ -1583,6 +1456,8 @@ QPushButton:pressed { 1 - + + + diff --git a/app/gui/oven_control/autocookselectionwindow.cpp b/app/gui/oven_control/autocookselectionwindow.cpp index 38e2348..89e0dd0 100644 --- a/app/gui/oven_control/autocookselectionwindow.cpp +++ b/app/gui/oven_control/autocookselectionwindow.cpp @@ -4,9 +4,10 @@ #include #include -#include "autocookwindow.h" +#include "autocookconfigwindow.h" +//#include "autocookwindow.h" -AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Cook::CookType type) : +AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Define::CookType type) : QMainWindow(parent), ui(new Ui::AutoCookSelectionWindow), oven(oven), type(type), autoCookWindowOpened(false) @@ -16,20 +17,9 @@ AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Co ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); - ui->cookTypeIcon->setPixmap(Cook::icon(type)); + ui->cookTypeIcon->setPixmap(Define::icon(type)); - switch (type) - { - case Cook::Poultry: - cookList.append(new ChickenCook); - break; - case Cook::Meat: - cookList.append(new MeatPie); - break; - case Cook::Bread: - cookList.append(new Croissant); - break; - } + book = CookBook(type); QSignalMapper *sm = new QSignalMapper(this); connect(sm, SIGNAL(mapped(int)), SLOT(onCookSelected(int))); @@ -47,7 +37,7 @@ AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Co "border-image: url(:/images/button/288_ov.png);\n" "}"); - for (int idx = 0; idx < cookList.size(); idx++) + for (int idx = 0; idx < book.list.size(); idx++) { int x = 12 + (idx % 3) * 294; int y = 615 + (idx / 3) * 80; @@ -56,7 +46,7 @@ AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Co pb->setGeometry(QRect(x, y, 288, 70)); pb->setFont(font); pb->setStyleSheet(stylesheet); - pb->setText(cookList.at(idx)->name()); + pb->setText(book.list.at(idx)); sm->setMapping(pb, idx); connect(pb, SIGNAL(clicked()), sm, SLOT(map())); @@ -66,9 +56,6 @@ AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Co AutoCookSelectionWindow::~AutoCookSelectionWindow() { delete ui; - - foreach (AbstractCook *cook, cookList) - delete cook; } void AutoCookSelectionWindow::onCookSelected(int idx) @@ -78,11 +65,12 @@ void AutoCookSelectionWindow::onCookSelected(int idx) autoCookWindowOpened = true; - AutoCookWindow *w = new AutoCookWindow(parentWidget(), oven, cookList.takeAt(idx)); + close(); + + AutoCookConfigWindow *w = new AutoCookConfigWindow(parentWidget(), oven, book.get(idx)); w->setWindowModality(Qt::WindowModal); w->showFullScreen(); - - close(); + w->raise(); } void AutoCookSelectionWindow::on_backButton_clicked() diff --git a/app/gui/oven_control/autocookselectionwindow.h b/app/gui/oven_control/autocookselectionwindow.h index e116740..3addaac 100644 --- a/app/gui/oven_control/autocookselectionwindow.h +++ b/app/gui/oven_control/autocookselectionwindow.h @@ -4,7 +4,7 @@ #include #include "oven.h" -#include "cook.h" +#include "cookbook.h" namespace Ui { class AutoCookSelectionWindow; @@ -15,7 +15,7 @@ class AutoCookSelectionWindow : public QMainWindow Q_OBJECT public: - explicit AutoCookSelectionWindow(QWidget *parent = 0, Oven *oven = 0, Cook::CookType type = Cook::Poultry); + explicit AutoCookSelectionWindow(QWidget *parent = 0, Oven *oven = 0, Define::CookType type = Define::Poultry); ~AutoCookSelectionWindow(); private slots: @@ -26,8 +26,9 @@ private slots: private: Ui::AutoCookSelectionWindow *ui; Oven *oven; - Cook::CookType type; - QList cookList; + Define::CookType type; + CookBook book; + bool autoCookWindowOpened; }; diff --git a/app/gui/oven_control/autocookwindow.cpp b/app/gui/oven_control/autocookwindow.cpp index 31027ea..cb2c026 100644 --- a/app/gui/oven_control/autocookwindow.cpp +++ b/app/gui/oven_control/autocookwindow.cpp @@ -1,104 +1,47 @@ #include "autocookwindow.h" #include "ui_autocookwindow.h" -AutoCookWindow::AutoCookWindow(QWidget *parent, Oven *oven, AbstractCook *cook) : +#include "keepwarmpopup.h" + +AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) : QMainWindow(parent), ui(new Ui::AutoCookWindow), - oven(oven), - cook(cook), - started(false), - done(false), - selectedStepIndex(0) + cook(cook) { ui->setupUi(this); ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); - connect(oven, SIGNAL(changed(Oven*)), SLOT(onOvenUpdated())); - oven->setDefault(Oven::CombinationMode); - - lastHumidity = oven->currentHumidity(); - lastTemp = oven->currentTemp(); - lastDoorView = Cook::Invalid; - - QTimer *cookStartTimer = new QTimer(this); - cookStartTimer->setSingleShot(true); - cookStartTimer->setInterval(3000); - connect(cookStartTimer, SIGNAL(timeout()), SLOT(start())); - - connect(ui->configButton_1, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configButton_2, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configButton_3, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configButton_4, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configButton_5, SIGNAL(pressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configButton_1, SIGNAL(released()), SIGNAL(startCookStartTimer())); - connect(ui->configButton_2, SIGNAL(released()), SIGNAL(startCookStartTimer())); - connect(ui->configButton_3, SIGNAL(released()), SIGNAL(startCookStartTimer())); - connect(ui->configButton_4, SIGNAL(released()), SIGNAL(startCookStartTimer())); - connect(ui->configButton_5, SIGNAL(released()), SIGNAL(startCookStartTimer())); - - connect(ui->configSlider_1, SIGNAL(sliderPressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configSlider_2, SIGNAL(sliderPressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configSlider_3, SIGNAL(sliderPressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configSlider_4, SIGNAL(sliderPressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configSlider_5, SIGNAL(sliderPressed()), SIGNAL(stopCookStartTimer())); - connect(ui->configSlider_1, SIGNAL(actionTriggered(int)), SIGNAL(startCookStartTimer())); - connect(ui->configSlider_2, SIGNAL(actionTriggered(int)), SIGNAL(startCookStartTimer())); - connect(ui->configSlider_3, SIGNAL(actionTriggered(int)), SIGNAL(startCookStartTimer())); - connect(ui->configSlider_4, SIGNAL(actionTriggered(int)), SIGNAL(startCookStartTimer())); - connect(ui->configSlider_5, SIGNAL(actionTriggered(int)), SIGNAL(startCookStartTimer())); - - connect(this, SIGNAL(stopCookStartTimer()), cookStartTimer, SLOT(stop())); - connect(this, SIGNAL(startCookStartTimer()), cookStartTimer, SLOT(start())); - - connect(ui->configSlider_1, SIGNAL(valueChanged(int)), SLOT(onConfigChanged())); - connect(ui->configSlider_2, SIGNAL(valueChanged(int)), SLOT(onConfigChanged())); - connect(ui->configSlider_3, SIGNAL(valueChanged(int)), SLOT(onConfigChanged())); - connect(ui->configSlider_4, SIGNAL(valueChanged(int)), SLOT(onConfigChanged())); - connect(ui->configSlider_5, SIGNAL(valueChanged(int)), SLOT(onConfigChanged())); - - connect(ui->configSlider_1, SIGNAL(sliderMoved(int)), SLOT(updateView())); - connect(ui->configSlider_2, SIGNAL(sliderMoved(int)), SLOT(updateView())); - connect(ui->configSlider_3, SIGNAL(sliderMoved(int)), SLOT(updateView())); - connect(ui->configSlider_4, SIGNAL(sliderMoved(int)), SLOT(updateView())); - connect(ui->configSlider_5, SIGNAL(sliderMoved(int)), SLOT(updateView())); - connect(ui->configSlider_1, SIGNAL(valueChanged(int)), SLOT(updateView())); - connect(ui->configSlider_2, SIGNAL(valueChanged(int)), SLOT(updateView())); - connect(ui->configSlider_3, SIGNAL(valueChanged(int)), SLOT(updateView())); - connect(ui->configSlider_4, SIGNAL(valueChanged(int)), SLOT(updateView())); - connect(ui->configSlider_5, SIGNAL(valueChanged(int)), SLOT(updateView())); - - - checkCookTimer.setInterval(1000); - connect(&checkCookTimer, SIGNAL(timeout()), SLOT(checkCook())); + autocook = AutoCook(cook); + processSelected = false; + + setupUi(); + Oven *oven = Oven::getInstance(); + connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView())); returnToCurrentStepTimer.setSingleShot(true); returnToCurrentStepTimer.setInterval(3000); connect(&returnToCurrentStepTimer, SIGNAL(timeout()), SLOT(returnToCurrentStep())); - - showingCurrentHumidity = false; showCurrentHumidityTimer.setSingleShot(true); showCurrentHumidityTimer.setInterval(3000); connect(&showCurrentHumidityTimer, SIGNAL(timeout()), SLOT(showCurrentHumidity())); - showingCurrentTemp = false; showCurrentTempTimer.setSingleShot(true); showCurrentTempTimer.setInterval(3000); connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp())); - setupUi(); + connect(&checkCookTimer, SIGNAL(timeout()), SLOT(checkCook())); + checkCookTimer.start(100); - cookStartTimer->start(); + connect(&checkProcessTimer, SIGNAL(timeout()), SLOT(checkProcess())); } AutoCookWindow::~AutoCookWindow() { delete ui; - - delete cook; } void AutoCookWindow::setupUi() @@ -109,137 +52,14 @@ void AutoCookWindow::setupUi() dryModeIcon.load(":/images/cook_mode/small_dryheat.png"); combiModeIcon.load(":/images/cook_mode/small_combi.png"); - QString cookTypeIcon = Cook::icon(cook->type()); - ui->cookTypeIcon_1->setPixmap(cookTypeIcon); - ui->cookTypeIcon_2->setPixmap(cookTypeIcon); - - QString name = cook->name(); - ui->selectCookButton_1->setText(name); - ui->selectCookButton_2->setText(name); + ui->cookTypeIcon->setPixmap(Define::icon(cook.type)); + ui->selectCookButton->setText(cook.name); - for (int idx = 0; idx < 5; idx++) - { - QPushButton *icon; - QLabel *minLabel; - QLabel *maxLabel; - QLabel *currentLabel; - QSlider *slider; - - switch (idx) - { - case 0: - icon = ui->configButton_1; - minLabel = ui->configMinLabel_1; - maxLabel = ui->configMaxLabel_1; - currentLabel = ui->configCurrentLabel_1; - slider = ui->configSlider_1; - break; - case 1: - icon = ui->configButton_2; - minLabel = ui->configMinLabel_2; - maxLabel = ui->configMaxLabel_2; - currentLabel = ui->configCurrentLabel_2; - slider = ui->configSlider_2; - break; - case 2: - icon = ui->configButton_3; - minLabel = ui->configMinLabel_3; - maxLabel = ui->configMaxLabel_3; - currentLabel = ui->configCurrentLabel_3; - slider = ui->configSlider_3; - break; - case 3: - icon = ui->configButton_4; - minLabel = ui->configMinLabel_4; - maxLabel = ui->configMaxLabel_4; - currentLabel = ui->configCurrentLabel_4; - slider = ui->configSlider_4; - break; - case 4: - icon = ui->configButton_5; - minLabel = ui->configMinLabel_5; - maxLabel = ui->configMaxLabel_5; - currentLabel = ui->configCurrentLabel_5; - slider = ui->configSlider_5; - break; - } - - AbstractCookConfig *config = cook->configurations[idx]; - if (config != NULL) - { - icon->show(); - icon->setStyleSheet("QPushButton { image: url(" - + config->icon() - + ") } QPushButton::pressed { image: url(" - + config->overlayIcon() - + ") }"); - minLabel->show(); - minLabel->setText(config->minLabel()); - maxLabel->show(); - maxLabel->setText(config->maxLabel()); - - currentLabel->show(); - - slider->show(); - slider->blockSignals(true); - slider->setMinimum(1); - slider->setMaximum(config->count()); - slider->setValue(config->current()); - slider->blockSignals(false); - - switch (config->type()) - { - case Cook::Time: - slider->setProperty("sliderColor", QString("white")); - break; - case Cook::BurnDegree: - slider->setProperty("sliderColor", QString("yellow")); - break; - case Cook::Brightness: - slider->setProperty("sliderColor", QString("red")); - break; - default: - slider->setProperty("sliderColor", QString("blue")); - break; - } - - slider->style()->unpolish(slider); - slider->style()->polish(slider); - slider->update(); - } - else - { - icon->hide(); - minLabel->hide(); - maxLabel->hide(); - currentLabel->hide(); - slider->hide(); - } - } - - if (cook->interTempEnabled()) - { - ui->configButton_4->show(); - ui->configButton_4->setStyleSheet( - QString("QPushButton { image: url(") - + ":/images/slider_icon/core_temp_enabled.png" - + ") } QPushButton::pressed { image: url(" - + ":/images/slider_icon/core_temp_ov.png" - + ") }" - ); - ui->configMinLabel_4->hide(); - ui->configMaxLabel_4->hide(); - ui->configCurrentLabel_4->hide(); - ui->configSlider_4->hide(); - - interTempEnabled = true; - } - - int offsetX = (900 - (cook->stepCount() * 19 * 2 - 19)) / 2; + int offsetX = (900 - (cook.steps.size() * 19 * 2 - 19)) / 2; int offsetY = 1150; - for (int idx = 0; idx < cook->stepCount(); idx++) + for (int idx = 0; idx < cook.steps.size(); idx++) { - QLabel *bullet = new QLabel(ui->cookPage); + QLabel *bullet = new QLabel(this); bullet->setPixmap(bulletPixmap); bullet->setGeometry(offsetX + 19 * 2 * idx, offsetY, 19, 19); bullets.append(bullet); @@ -281,588 +101,533 @@ void AutoCookWindow::setupUi() ui->closeDoorAnimation->hide(); ui->closeDoorArrow->hide(); - updateView(); -} + lastViewCookMode = Define::InvalidMode; + lastViewCookType = Define::Invalid; + lastViewCoreTemp = 999; + lastViewDoorType = Define::Invalid; + lastViewTime = 0; + lastViewStepIndex = -1; + selectedStepIndex = 0; + showingCurrentHumidity = false; + showingCurrentTemp = false; -void AutoCookWindow::updateView() -{ -// qDebug() << "updateView"; - if (started) + if (autocook.cook.processes.isEmpty()) { - ui->stackedWidget->setCurrentIndex(1); - - for (int idx = 0; idx < bullets.length(); idx++) - { - QLabel *bullet = bullets.at(idx); - if (idx == selectedStepIndex) - bullet->setPixmap(selectedBulletPixmap); - else - bullet->setPixmap(bulletPixmap); - } - - viewStep(cook->step(selectedStepIndex)); - - int time = oven->time(); - if (time >= 3600) - ui->timeLabel->setText(QString().sprintf("%d시간 %02d", time / 3600, (time % 3600) / 60)); - else if (time >= 60) - ui->timeLabel->setText(QString().sprintf("%d %02d", time / 60, time % 60)); - else - ui->timeLabel->setText(QString().sprintf("%d", time)); - - int curInterTemp = oven->currentInterTemp(); - if (interTempEnabled) - { - int interTemp = oven->interTemp(); - ui->interTempLabel->setText(QString().sprintf("%d℃ / %d", curInterTemp, interTemp)); - } - else - ui->interTempLabel->setText(QString().sprintf("%d", curInterTemp)); - - if (!done) - { - if (oven->door()) - { - ui->closeDoorAnimation->show(); - ui->closeDoorArrow->show(); - ui->openDoorAnimation->hide(); - ui->openDoorArrow->hide(); - } - else - { - ui->closeDoorAnimation->hide(); - ui->closeDoorArrow->hide(); - - Cook::Step step = cook->currentStep(); - if (Cook::classify(step.type) == Cook::DoorClass) - { - ui->openDoorAnimation->show(); - ui->openDoorArrow->show(); - } - else - { - ui->openDoorAnimation->hide(); - ui->openDoorArrow->hide(); - } - } - } + ui->processTitleLabel->hide(); + ui->processTypeLabel->hide(); + ui->processButton_1->hide(); + ui->processButton_2->hide(); + ui->processButton_3->hide(); } else { - ui->stackedWidget->setCurrentIndex(0); - - for (int idx = 0; idx < 5; idx++) + QString typeText; + QSignalMapper *sm = NULL; + for (int i = 0; i < 3; i++) { - AbstractCookConfig *config = cook->configurations[idx]; - if (config == NULL) - continue; - - QLabel *l; - QSlider *s; - switch (idx) + QPushButton *pb; + switch (i) { case 0: - l = ui->configCurrentLabel_1; - s = ui->configSlider_1; + pb = ui->processButton_1; break; case 1: - l = ui->configCurrentLabel_2; - s = ui->configSlider_2; + pb = ui->processButton_2; break; case 2: - l = ui->configCurrentLabel_3; - s = ui->configSlider_3; - break; - case 3: - l = ui->configCurrentLabel_4; - s = ui->configSlider_4; - break; - case 4: - l = ui->configCurrentLabel_5; - s = ui->configSlider_5; + pb = ui->processButton_3; break; } - int time = cook->time(); - int interTemp = cook->interTemp(); - - switch (config->type()) + if (i < autocook.cook.processes.size()) { - case Cook::Time: - if (time >= 3600) - l->setText(QString().sprintf("%d시간 %02d", time / 3600, (time % 3600) / 60)); - else if (time >= 60) - l->setText(QString().sprintf("%d %02d", time / 60, time % 60)); + if (sm == NULL) + { + sm = new QSignalMapper(this); + connect(sm, SIGNAL(mapped(int)), SLOT(startProcess(int))); + } + + Define::Process process = autocook.cook.processes[i]; + + QString text = Define::name(process); + if (typeText.isEmpty()) + typeText = text; else - l->setText(QString().sprintf("%d", time)); - break; - case Cook::BurnDegree: - l->setText(QString().sprintf("%d", interTemp)); - break; - default: - l->setText(QString().sprintf("%d/%d", config->current(), config->count())); - break; + typeText += ", " + text; + + QString styleSheet = QString("QPushButton { border-image: url(%1) } QPushButton:pressed { border-image: url(%2) }") + .arg(Define::icon(process)) + .arg(Define::iconOverlay(process)); + + pb->setStyleSheet(styleSheet); + + sm->setMapping(pb, (int) process); + connect(pb, SIGNAL(clicked()), sm, SLOT(map())); + } + else + { + pb->hide(); } } - if (interTempEnabled) - { - ui->configButton_4->setStyleSheet( - QString("QPushButton { image: url(") - + ":/images/slider_icon/core_temp_enabled.png" - + ") } QPushButton::pressed { image: url(" - + ":/images/slider_icon/core_temp_ov.png" - + ") }"); - } - else - { - ui->configButton_4->setStyleSheet( - QString("QPushButton { image: url(") - + ":/images/slider_icon/core_temp.png" - + ") } QPushButton::pressed { image: url(" - + ":/images/slider_icon/core_temp_ov.png" - + ") }"); - } + ui->processTypeLabel->setText(typeText); } + + ui->processContainer->hide(); + + updateView(); } -void AutoCookWindow::viewStep(Cook::Step step) +void AutoCookWindow::updateView() { -// qDebug() << "viewStep" << step.type; - switch (Cook::classify(step.type)) + Oven *oven = Oven::getInstance(); + + QString spanFontSize11("%1"); + QString spanFontSize9("%1"); + + int remainingTime = qMax(0, autocook.remainingTime()); + if (remainingTime != lastViewTime) { - case Cook::PreheatClass: - viewPreheatStep(step); - break; - case Cook::DoorClass: - viewDoorStep(step); - break; - case Cook::CookClass: - viewCookStep(step); - break; - default: - break; + lastViewTime = remainingTime; + + QString hour = spanFontSize11.arg("시간"); + QString min = spanFontSize11.arg("분"); + QString sec = spanFontSize11.arg("초"); + + if (remainingTime >= 3600) + ui->timeLabel->setText(QString("%1%2 %3%4") + .arg(remainingTime / 3600) + .arg(hour) + .arg((remainingTime % 3600) / 60, 2, 10, QLatin1Char('0')) + .arg(min)); + else if (remainingTime >= 60) + ui->timeLabel->setText(QString("%1%2 %3%4") + .arg(remainingTime / 60) + .arg(min) + .arg(remainingTime % 60, 2, 10, QLatin1Char('0')) + .arg(sec)); + else + ui->timeLabel->setText(QString("%1%2") + .arg(remainingTime) + .arg(sec)); } -} -void AutoCookWindow::viewPreheatStep(Cook::Step step) -{ - ui->cookStepIcon->show(); - ui->cookStepIcon->setPixmap(QPixmap(":/images/cook_step_type/sys_icon_05.png")); - ui->cookStepLabel->show(); - ui->cookStepLabel->setText("예열"); - ui->doorStepLabel->hide(); - ui->cookStepAnimation->hide(); - - ui->humidityGauge->show(); - ui->humidityGauge->setValue(step.humidity); - ui->humidityLabel->show(); - if (showingCurrentHumidity) - ui->humidityLabel->setText(QString().sprintf("%d%%", oven->currentHumidity())); - else - ui->humidityLabel->setText(QString().sprintf("%d%%", step.humidity)); + int coreTemp = oven->currentInterTemp(); + if (coreTemp != lastViewCoreTemp) + { + lastViewCoreTemp = coreTemp; - ui->heatGauge->show(); - ui->heatGauge->setValue(step.temp); - ui->heatLabel->show(); - if (showingCurrentTemp) - ui->heatLabel->setText(QString().sprintf("%d℃", oven->currentTemp())); - else - ui->heatLabel->setText(QString().sprintf("%d℃", step.temp)); + QString coreTempLabel = QString::number(coreTemp); + if (cook.isCoreTempValid()) + coreTempLabel += spanFontSize11.arg("℃ / " + QString::number(cook.coreTemp())) + spanFontSize9.arg("℃"); + else + coreTempLabel += spanFontSize11.arg("℃"); - ui->cookModeIcon->show(); - switch (step.mode) - { - case Cook::SteamMode: - ui->cookModeIcon->setPixmap(steamModeIcon); - break; - case Cook::DryMode: - ui->cookModeIcon->setPixmap(dryModeIcon); - break; - case Cook::CombiMode: - ui->cookModeIcon->setPixmap(combiModeIcon); - break; + ui->interTempLabel->setText(coreTempLabel); } -} -void AutoCookWindow::viewDoorStep(Cook::Step step) -{ -// qDebug() << "viewDoorStep"; - ui->cookStepLabel->hide(); - ui->cookStepIcon->hide(); - ui->doorStepLabel->show(); - ui->cookStepAnimation->show(); - - ui->humidityGauge->hide(); - ui->humidityLabel->hide(); - ui->heatGauge->hide(); - ui->heatLabel->hide(); - ui->cookModeIcon->hide(); - - if (lastDoorView != step.type) + if (autocook.done()) { - lastDoorView = step.type; - qDebug() << "clearStepAnimation"; + if (!oven->door()) + { + if (ui->openDoorAnimation->isHidden()) + ui->openDoorAnimation->show(); - ui->cookStepAnimation->clear(); - switch (step.type) + if (ui->openDoorArrow->isHidden()) + ui->openDoorArrow->show(); + + if (ui->closeDoorAnimation->isVisible()) + ui->closeDoorAnimation->hide(); + + if (ui->closeDoorArrow->isVisible()) + ui->closeDoorArrow->hide(); + } + else { - case Cook::PutThermometer: - ui->doorStepLabel->setText("중심 온도계 삽입"); - ui->cookStepAnimation->load(":/images/animation/thermometer_01.png"); - ui->cookStepAnimation->load(":/images/animation/thermometer_02.png"); - ui->cookStepAnimation->setGeometry((900-210)/2, 800, 210, 307); - break; - case Cook::Load: - ui->doorStepLabel->setText("식재료 적재"); - ui->cookStepAnimation->load(":/images/animation/load_01.png"); - ui->cookStepAnimation->load(":/images/animation/load_02.png"); - ui->cookStepAnimation->load(":/images/animation/load_03.png"); - ui->cookStepAnimation->load(":/images/animation/load_04.png"); - ui->cookStepAnimation->load(":/images/animation/load_03.png"); - ui->cookStepAnimation->load(":/images/animation/load_02.png"); - ui->cookStepAnimation->load(":/images/animation/load_01.png"); - ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307); - break; - case Cook::Cut: - ui->doorStepLabel->setText("자르기"); - ui->cookStepAnimation->load(":/images/animation/cut_01.png"); - ui->cookStepAnimation->load(":/images/animation/cut_02.png"); - ui->cookStepAnimation->load(":/images/animation/cut_03.png"); - ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307); - break; - case Cook::Pour: - ui->doorStepLabel->setText("물 붓기"); - ui->cookStepAnimation->load(":/images/animation/pour_01.png"); - ui->cookStepAnimation->load(":/images/animation/pour_02.png"); - ui->cookStepAnimation->load(":/images/animation/pour_03.png"); - ui->cookStepAnimation->load(":/images/animation/pour_04.png"); - ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307); - break; - default: - ui->doorStepLabel->hide(); + if (ui->openDoorAnimation->isVisible()) + ui->openDoorAnimation->hide(); + + if (ui->openDoorArrow->isVisible()) + ui->openDoorArrow->hide(); + + if (ui->closeDoorAnimation->isVisible()) + ui->closeDoorAnimation->hide(); + + if (ui->closeDoorArrow->isVisible()) + ui->closeDoorArrow->hide(); } + + if (ui->processContainer->isHidden()) + ui->processContainer->show(); } -} + else if (autocook.isWaitingDoorOpened() && !oven->door()) + { + if (ui->openDoorAnimation->isHidden()) + ui->openDoorAnimation->show(); -void AutoCookWindow::viewCookStep(Cook::Step step) -{ - ui->cookStepLabel->show(); - ui->cookStepIcon->show(); - ui->doorStepLabel->hide(); - ui->cookStepAnimation->hide(); - - ui->humidityGauge->show(); - ui->humidityGauge->setValue(step.humidity); - ui->humidityLabel->show(); - if (showingCurrentHumidity) - ui->humidityLabel->setText(QString().sprintf("%d%%", oven->currentHumidity())); - else - ui->humidityLabel->setText(QString().sprintf("%d%%", step.humidity)); + if (ui->openDoorArrow->isHidden()) + ui->openDoorArrow->show(); - ui->heatGauge->show(); - ui->heatGauge->setValue(step.temp); - ui->heatLabel->show(); - if (showingCurrentTemp) - ui->heatLabel->setText(QString().sprintf("%d℃", oven->currentTemp())); - else - ui->heatLabel->setText(QString().sprintf("%d℃", step.temp)); + if (ui->closeDoorAnimation->isVisible()) + ui->closeDoorAnimation->hide(); - ui->cookModeIcon->show(); - switch (step.mode) - { - case Cook::SteamMode: - ui->cookModeIcon->setPixmap(steamModeIcon); - break; - case Cook::DryMode: - ui->cookModeIcon->setPixmap(dryModeIcon); - break; - case Cook::CombiMode: - ui->cookModeIcon->setPixmap(combiModeIcon); - break; + if (ui->closeDoorArrow->isVisible()) + ui->closeDoorArrow->hide(); } + else if (!autocook.isWaitingDoorOpened() && oven->door()) + { + if (ui->openDoorAnimation->isVisible()) + ui->openDoorAnimation->hide(); - ui->cookStepLabel->setText(Cook::name(step.type)); - ui->cookStepIcon->setPixmap(QPixmap(Cook::icon(step.type))); -} + if (ui->openDoorArrow->isVisible()) + ui->openDoorArrow->hide(); -void AutoCookWindow::doPreheatStep(Cook::Step step) -{ -// oven->setHumidity(step.humidity); - oven->setHumidity(0); - oven->setTemp(step.temp); - oven->startPreheating(); - - lastHumidity = oven->currentHumidity(); - lastTemp = oven->currentTemp(); - - ui->preheatIcon->show(); - ui->preheatLabel->show(); - ui->preheatGauge->show(); - ui->preheatGauge->setMaximum(step.temp); - ui->preheatGauge->setMinimum(lastTemp); - ui->preheatGauge->setValue(lastTemp); -} + if (ui->closeDoorAnimation->isHidden()) + ui->closeDoorAnimation->show(); -void AutoCookWindow::doDoorStep(Cook::Step /*step*/) -{ - opened = false; -} + if (ui->closeDoorArrow->isHidden()) + ui->closeDoorArrow->show(); + } + else + { + if (ui->openDoorAnimation->isVisible()) + ui->openDoorAnimation->hide(); -void AutoCookWindow::doCookStep(Cook::Step step) -{ -// oven->setHumidity(step.humidity); - oven->setHumidity(0); - oven->setTemp(step.temp); - oven->startCooking(); + if (ui->openDoorArrow->isVisible()) + ui->openDoorArrow->hide(); - lastHumidity = oven->currentHumidity(); - lastTemp = oven->currentTemp(); -} + if (ui->closeDoorAnimation->isVisible()) + ui->closeDoorAnimation->hide(); -static bool checkReached(int target, int last, int current) -{ - qDebug() << "checkReached" << target << last << current; - return ((target >= last) && (target <= current)) - || ((target <= last) && (target >= current)); -} + if (ui->closeDoorArrow->isVisible()) + ui->closeDoorArrow->hide(); + } -void AutoCookWindow::checkPreheatStep(Cook::Step step) -{ - int curTemp = oven->currentTemp(); + if (autocook.cook.steps[autocook.currentStepIndex].type == Define::Preheat) + { + if (ui->preheatIcon->isHidden()) + ui->preheatIcon->show(); - ui->preheatGauge->setValue(curTemp); + if (ui->preheatLabel->isHidden()) + ui->preheatLabel->show(); - if (checkReached(step.humidity, lastHumidity, oven->currentHumidity()) - && checkReached(step.temp, lastTemp, curTemp)) + if (ui->preheatGauge->isHidden()) + ui->preheatGauge->show(); + + ui->preheatGauge->setMaximum(autocook.cook.steps[autocook.currentStepIndex].temp); + ui->preheatGauge->setMinimum(autocook.startTemp); + ui->preheatGauge->setValue(oven->currentTemp()); + } + else { - if (selectedStepIndex == cook->currentStepIndex()) - selectedStepIndex = cook->currentStepIndex() + 1; + if (ui->preheatIcon->isVisible()) + ui->preheatIcon->hide(); - ui->preheatIcon->hide(); - ui->preheatLabel->hide(); - ui->preheatGauge->hide(); + if (ui->preheatLabel->isVisible()) + ui->preheatLabel->hide(); - cook->setCurrentStepIndex(cook->currentStepIndex() + 1); - doStep(); + if (ui->preheatGauge->isVisible()) + ui->preheatGauge->hide(); } -} -void AutoCookWindow::checkDoorStep(Cook::Step /*step*/) -{ -// qDebug() << "checkDoorStep" << opened << oven->door(); - if (opened) + if (selectedStepIndex != lastViewStepIndex) { - if (!oven->door()) - { - if (selectedStepIndex == cook->currentStepIndex()) - selectedStepIndex = cook->currentStepIndex() + 1; + lastViewStepIndex = selectedStepIndex; - cook->setCurrentStepIndex(cook->currentStepIndex() + 1); - doStep(); + for (int idx = 0; idx < bullets.length(); idx++) + { + QLabel *bullet = bullets.at(idx); + if (idx == selectedStepIndex) + bullet->setPixmap(selectedBulletPixmap); + else + bullet->setPixmap(bulletPixmap); } } - else - { - if (oven->door()) - opened = true; - } -} -void AutoCookWindow::checkCookStep(Cook::Step step) -{ - if (cook->currentStepIndex() + 1 < cook->stepCount()) + CookStep showingStep = autocook.cook.steps[selectedStepIndex]; + if (Define::classify(showingStep.type) == Define::DoorClass) { - if (checkReached(step.humidity, lastHumidity, oven->currentHumidity()) - && checkReached(step.temp, lastTemp, oven->currentTemp())) - { - if (selectedStepIndex == cook->currentStepIndex()) - selectedStepIndex = cook->currentStepIndex() + 1; + if (ui->cookStepIcon->isVisible()) + ui->cookStepIcon->hide(); - cook->setCurrentStepIndex(cook->currentStepIndex() + 1); - doStep(); - } - else if (interTempEnabled) + if (ui->cookStepLabel->isVisible()) + ui->cookStepLabel->hide(); + + if (ui->cookModeIcon->isVisible()) + ui->cookModeIcon->hide(); + + if (ui->humidityGauge->isVisible()) + ui->humidityGauge->hide(); + + if (ui->humidityGaugeButton->isVisible()) + ui->humidityGaugeButton->hide(); + + if (ui->humidityLabel->isVisible()) + ui->humidityLabel->hide(); + + if (ui->heatGauge->isVisible()) + ui->heatGauge->hide(); + + if (ui->heatGaugeButton->isVisible()) + ui->heatGaugeButton->hide(); + + if (ui->heatLabel->isVisible()) + ui->heatLabel->hide(); + + if (ui->doorStepLabel->isHidden()) + ui->doorStepLabel->show(); + + if (ui->cookStepAnimation->isHidden()) + ui->cookStepAnimation->show(); + + if (showingStep.type != lastViewDoorType) { - if (cook->interTemp() <= oven->currentInterTemp()) - { - if (selectedStepIndex == cook->currentStepIndex()) - selectedStepIndex = cook->stepCount() - 1; + lastViewDoorType = showingStep.type; - cook->setCurrentStepIndex(cook->stepCount() - 1); - doStep(); + ui->doorStepLabel->setText(Define::name(showingStep.type)); + ui->cookStepAnimation->clear(); + switch (showingStep.type) + { + case Define::PutThermometer: + ui->doorStepLabel->setText("중심 온도계 삽입"); + ui->cookStepAnimation->load(":/images/animation/thermometer_01.png"); + ui->cookStepAnimation->load(":/images/animation/thermometer_02.png"); + ui->cookStepAnimation->setGeometry((900-210)/2, 800, 210, 307); + ui->cookStepAnimation->start(300); + break; + case Define::Load: + ui->doorStepLabel->setText("식재료 적재"); + ui->cookStepAnimation->load(":/images/animation/load_01.png"); + ui->cookStepAnimation->load(":/images/animation/load_02.png"); + ui->cookStepAnimation->load(":/images/animation/load_03.png"); + ui->cookStepAnimation->load(":/images/animation/load_04.png"); + ui->cookStepAnimation->load(":/images/animation/load_03.png"); + ui->cookStepAnimation->load(":/images/animation/load_02.png"); + ui->cookStepAnimation->load(":/images/animation/load_01.png"); + ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307); + ui->cookStepAnimation->start(300); + break; + case Define::Cut: + ui->doorStepLabel->setText("자르기"); + ui->cookStepAnimation->load(":/images/animation/cut_01.png"); + ui->cookStepAnimation->load(":/images/animation/cut_02.png"); + ui->cookStepAnimation->load(":/images/animation/cut_03.png"); + ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307); + ui->cookStepAnimation->start(300); + break; + case Define::Pour: + ui->doorStepLabel->setText("물 붓기"); + ui->cookStepAnimation->load(":/images/animation/pour_01.png"); + ui->cookStepAnimation->load(":/images/animation/pour_02.png"); + ui->cookStepAnimation->load(":/images/animation/pour_03.png"); + ui->cookStepAnimation->load(":/images/animation/pour_04.png"); + ui->cookStepAnimation->setGeometry((900-264)/2, 800, 264, 307); + ui->cookStepAnimation->start(300); + break; + default: + ui->doorStepLabel->hide(); + ui->cookStepAnimation->hide(); } } } - else /*if current step == last step*/ + else { - if (done) + if (ui->doorStepLabel->isVisible()) + ui->doorStepLabel->hide(); + + if (ui->cookStepAnimation->isVisible()) + ui->cookStepAnimation->hide(); + + if (ui->cookStepIcon->isHidden()) + ui->cookStepIcon->show(); + + if (ui->cookStepLabel->isHidden()) + ui->cookStepLabel->show(); + + if (ui->cookModeIcon->isHidden()) + ui->cookModeIcon->show(); + + if (ui->humidityGauge->isHidden()) + ui->humidityGauge->show(); + + if (ui->humidityGaugeButton->isHidden()) + ui->humidityGaugeButton->show(); + + if (ui->humidityLabel->isHidden()) + ui->humidityLabel->show(); + + if (ui->heatGauge->isHidden()) + ui->heatGauge->show(); + + if (ui->heatGaugeButton->isHidden()) + ui->heatGaugeButton->show(); + + if (ui->heatLabel->isHidden()) + ui->heatLabel->show(); + + if (showingStep.type != lastViewCookType) { + lastViewCookType = showingStep.type; + ui->cookStepIcon->setPixmap(Define::icon(showingStep.type)); + ui->cookStepLabel->setText(Define::name(showingStep.type)); } - else + + if (showingStep.mode != lastViewCookMode) { - if ((interTempEnabled && cook->interTemp() <= oven->currentInterTemp()) - || oven->time() == 0) - { - done = true; - ui->openDoorAnimation->show(); - ui->openDoorArrow->show(); - ui->closeDoorAnimation->hide(); - ui->closeDoorArrow->hide(); + lastViewCookMode = showingStep.mode; - oven->setTime(0); + switch (showingStep.mode) + { + case Define::SteamMode: + ui->cookModeIcon->setPixmap(steamModeIcon); + break; + case Define::CombiMode: + ui->cookModeIcon->setPixmap(combiModeIcon); + break; + case Define::DryMode: + ui->cookModeIcon->setPixmap(dryModeIcon); + break; + case Define::InvalidClass: + ui->cookModeIcon->hide(); + break; } } - } -} - -void AutoCookWindow::start() -{ - qDebug() << "start"; - started = true; - oven->setTime(cook->time()); - oven->setInterTemp(cook->interTemp()); - oven->setInterTempEnabled(interTempEnabled); + ui->humidityGauge->setValue(showingStep.humidity); - doStep(); - checkCookTimer.start(); + int humidity; + if (showingCurrentHumidity) + humidity = oven->currentHumidity(); + else + humidity = showingStep.humidity; - updateView(); -} + if (humidity != lastViewHumidity) + { + lastViewHumidity = humidity; + ui->humidityLabel->setText(QString("%1%").arg(humidity)); + } -void AutoCookWindow::stop() -{ - qDebug() << "stop"; - oven->stop(); - checkCookTimer.stop(); + ui->heatGauge->setValue(showingStep.temp); - updateView(); -} + int temp; + if (showingCurrentTemp) + temp = oven->currentTemp(); + else + temp = showingStep.temp; -void AutoCookWindow::doStep() -{ - qDebug() << "doStep"; - Cook::Step step = cook->currentStep(); - switch (Cook::classify(step.type)) - { - case Cook::PreheatClass: - doPreheatStep(step); - break; - case Cook::DoorClass: - doDoorStep(step); - break; - case Cook::CookClass: - doCookStep(step); - break; - default: - break; + if (temp != lastViewTemp) + { + lastViewTemp = temp; + ui->heatLabel->setText(QString("%1℃").arg(temp)); + } } } void AutoCookWindow::checkCook() { -// qDebug() << "checkCook"; - Cook::Step step = cook->currentStep(); - switch (Cook::classify(step.type)) + int lastStepIndex = autocook.currentStepIndex; + if (autocook.advance()) { - case Cook::PreheatClass: - checkPreheatStep(step); - break; - case Cook::DoorClass: - checkDoorStep(step); - break; - case Cook::CookClass: - checkCookStep(step); - break; - default: - qDebug() << "Checking Invalid Cook"; + if (lastStepIndex != autocook.currentStepIndex) + selectedStepIndex = autocook.currentStepIndex; + + if (autocook.done()) + checkCookTimer.stop(); } updateView(); } -void AutoCookWindow::onOvenUpdated() +void AutoCookWindow::startProcess(int process) { - updateView(); + if (processSelected) + return; - qDebug() << "onOvenUpdated()"; -} + processSelected = true; -void AutoCookWindow::on_showPrevStepButton_clicked() -{ - if (selectedStepIndex > 0) - selectedStepIndex--; - - updateView(); + Define::Process p = (Define::Process) process; + switch (p) + { + case Define::CookAgain: + { + close(); - returnToCurrentStepTimer.start(); -} + AutoCookWindow *w = new AutoCookWindow(parentWidget(), cook); + w->setWindowModality(Qt::WindowModal); + w->showFullScreen(); + w->raise(); -void AutoCookWindow::on_showNextStepButton_clicked() -{ - if (selectedStepIndex + 1 < cook->stepCount()) - selectedStepIndex++; + break; + } + case Define::MakeCrisper: + { + selectedProcess = (Define::Process) process; - updateView(); + CookStep &step = autocook.cook.steps[autocook.cook.steps.size() - 1]; - returnToCurrentStepTimer.start(); -} + Oven *oven = Oven::getInstance(); + oven->setHumidity(step.humidity); + oven->setTemp(step.temp + 10); + oven->startCooking(); -void AutoCookWindow::returnToCurrentStep() -{ - selectedStepIndex = cook->currentStepIndex(); + checkProcessTimer.start(100); + break; + } + case Define::KeepWarm: + { + processSelected = false; + selectedProcess = (Define::Process) process; - updateView(); + KeepWarmPopup *p = new KeepWarmPopup(this); + p->showFullScreen(); + p->raise(); + break; + } + } } -void AutoCookWindow::onConfigChanged() +void AutoCookWindow::checkProcess() { - for (int idx = 0; idx < 5; idx++) - { - AbstractCookConfig *config = cook->configurations[idx]; - if (config == NULL) - continue; + if (!processSelected) + return; - QSlider *slider; - switch (idx) + switch (selectedProcess) + { + case Define::MakeCrisper: + { + Oven *oven = Oven::getInstance(); + if (oven->currentTemp() >= oven->temp()) { - case 0: - slider = ui->configSlider_1; - break; - case 1: - slider = ui->configSlider_2; - break; - case 2: - slider = ui->configSlider_3; - break; - case 3: - slider = ui->configSlider_4; - break; - case 4: - slider = ui->configSlider_5; - break; + oven->stopCooking(); + checkProcessTimer.stop(); } - - config->setCurrent(slider->value()); + break; + } + default: + break; } + + updateView(); } -void AutoCookWindow::on_backButton_clicked() +void AutoCookWindow::returnToCurrentStep() { - stop(); - close(); + selectedStepIndex = autocook.currentStepIndex; + showingDifferentStep = false; + updateView(); } -void AutoCookWindow::on_configButton_4_clicked() +void AutoCookWindow::showCurrentHumidity() { - if (cook->interTempEnabled()) - { - interTempEnabled = !interTempEnabled; + showingCurrentHumidity = true; + updateView(); +} - updateView(); - } +void AutoCookWindow::showCurrentTemp() +{ + showingCurrentTemp = true; + updateView(); } void AutoCookWindow::on_humidityGaugeButton_pressed() @@ -872,7 +637,8 @@ void AutoCookWindow::on_humidityGaugeButton_pressed() void AutoCookWindow::on_humidityGaugeButton_released() { - showCurrentHumidityTimer.stop(); + if (showCurrentHumidityTimer.isActive()) + showCurrentHumidityTimer.stop(); if (showingCurrentHumidity) { @@ -888,7 +654,8 @@ void AutoCookWindow::on_heatGaugeButton_pressed() void AutoCookWindow::on_heatGaugeButton_released() { - showCurrentTempTimer.stop(); + if (showCurrentTempTimer.isActive()) + showCurrentTempTimer.stop(); if (showingCurrentTemp) { @@ -897,16 +664,30 @@ void AutoCookWindow::on_heatGaugeButton_released() } } -void AutoCookWindow::showCurrentHumidity() +void AutoCookWindow::on_backButton_clicked() { - showingCurrentHumidity = true; + Oven::getInstance()->stop(); + close(); +} - updateView(); +void AutoCookWindow::on_showPrevStepButton_clicked() +{ + if (selectedStepIndex > 0) + { + selectedStepIndex--; + updateView(); + } + + returnToCurrentStepTimer.start(); } -void AutoCookWindow::showCurrentTemp() +void AutoCookWindow::on_showNextStepButton_clicked() { - showingCurrentTemp = true; + if (selectedStepIndex + 1 < cook.steps.size()) + { + selectedStepIndex++; + updateView(); + } - updateView(); + returnToCurrentStepTimer.start(); } diff --git a/app/gui/oven_control/autocookwindow.h b/app/gui/oven_control/autocookwindow.h index de1b134..a7d0f28 100644 --- a/app/gui/oven_control/autocookwindow.h +++ b/app/gui/oven_control/autocookwindow.h @@ -2,12 +2,10 @@ #define AUTOCOOKWINDOW_H #include -#include -#include #include +#include -#include "oven.h" -#include "cook.h" +#include "autocook.h" namespace Ui { class AutoCookWindow; @@ -17,76 +15,67 @@ class AutoCookWindow : public QMainWindow { Q_OBJECT -signals: - void startCookStartTimer(); - void stopCookStartTimer(); - public: - explicit AutoCookWindow(QWidget *parent = 0, Oven *oven = 0, AbstractCook *cook = 0); + explicit AutoCookWindow(QWidget *parent, Cook cook); ~AutoCookWindow(); private: Ui::AutoCookWindow *ui; + + Cook cook; + AutoCook autocook; + QTimer checkCookTimer; - Oven *oven; - AbstractCook *cook; - bool started; - bool done; - bool opened; - bool interTempEnabled; QPixmap bulletPixmap; QPixmap selectedBulletPixmap; QList bullets; - int selectedStepIndex; - QTimer returnToCurrentStepTimer; QPixmap steamModeIcon; QPixmap dryModeIcon; QPixmap combiModeIcon; + int selectedStepIndex; + int lastViewStepIndex; + bool showingDifferentStep; + QTimer returnToCurrentStepTimer; + bool showingCurrentHumidity; bool showingCurrentTemp; QTimer showCurrentHumidityTimer; QTimer showCurrentTempTimer; - int lastHumidity; - int lastTemp; + int lastViewTime; + int lastViewCoreTemp; + int lastViewHumidity; + int lastViewTemp; + Define::StepType lastViewDoorType; + Define::StepType lastViewCookType; + Define::Mode lastViewCookMode; + + bool processSelected; + Define::Process selectedProcess; + QTimer checkProcessTimer; - Cook::StepType lastDoorView; void setupUi(); - void viewStep(Cook::Step step); - void viewPreheatStep(Cook::Step step); - void viewDoorStep(Cook::Step step); - void viewCookStep(Cook::Step step); - void doPreheatStep(Cook::Step step); - void doDoorStep(Cook::Step step); - void doCookStep(Cook::Step step); - void checkPreheatStep(Cook::Step step); - void checkDoorStep(Cook::Step step); - void checkCookStep(Cook::Step step); private slots: void updateView(); - void start(); - void stop(); - void doStep(); void checkCook(); - void onOvenUpdated(); - void on_showPrevStepButton_clicked(); - void on_showNextStepButton_clicked(); - void returnToCurrentStep(); + void startProcess(int process); + void checkProcess(); - void onConfigChanged(); - void on_backButton_clicked(); - void on_configButton_4_clicked(); + void returnToCurrentStep(); + void showCurrentHumidity(); + void showCurrentTemp(); void on_humidityGaugeButton_pressed(); void on_humidityGaugeButton_released(); void on_heatGaugeButton_pressed(); void on_heatGaugeButton_released(); - void showCurrentHumidity(); - void showCurrentTemp(); + void on_backButton_clicked(); + void on_showPrevStepButton_clicked(); + void on_showNextStepButton_clicked(); }; #endif // AUTOCOOKWINDOW_H diff --git a/app/gui/oven_control/autocookwindow.ui b/app/gui/oven_control/autocookwindow.ui index ee6140f..6eaab6d 100644 --- a/app/gui/oven_control/autocookwindow.ui +++ b/app/gui/oven_control/autocookwindow.ui @@ -16,57 +16,11 @@ #centralwidget { background-image: url(:/images/background/auto_steps.png); } #bottomBar { background-image: url(:/images/bottom_bar/background.png); } -#configPage { background-image: url(:/images/background/auto.png); } -#cookPage { background-image: url(:/images/background/auto_steps.png); } - -QSlider::groove { -background-image: url(:/images/slider/groove.png); -background-repeat: no-repeat; -background-position: center; -} - -QSlider::sub-page { -background-repeat: no-repeat; -background-position: left center; -margin: 0px 5px; -} - -QSlider[sliderColor="red"]::sub-page { -background-image: url(:/images/slider/sub_red.png); -} - -QSlider[sliderColor="yellow"]::sub-page { -background-image: url(:/images/slider/sub_yellow.png); -} - -QSlider[sliderColor="white"]::sub-page { -background-image: url(:/images/slider/sub_white.png); -} - -QSlider[sliderColor="blue"]::sub-page { -background-image: url(:/images/slider/sub_blue.png); -} - -QSlider[sliderColor="green"]::sub-page { -background-image: url(:/images/slider/sub_green.png); -} - -QSlider::handle { -background-image: url(:/images/slider/handle_big.png); -background-repeat: no-repeat; -background-position: center; -width: 23px; -height: 33px; -} QPushButton { background-repeat: no-repeat; background-position: center; border: none; -} - -QPushButton[style="icon"] { -background-image: url(:/images/slider_icon/background.png); } @@ -96,2318 +50,1292 @@ background-image: url(:/images/slider_icon/background.png); - + 0 - 0 + 1450 900 - 1450 + 150 - - - - - 0 - 430 - 250 - 150 - - - - - - - :/images/images/auto/005_auto_icon_01_ov.png - - - Qt::AlignCenter - - - - - - 420 - 480 - 288 - 70 - - - - - Roboto - 10 - 75 - true - - - - QPushButton { -border-image: url(:/images/button/288.png); -} -QPushButton::pressed { -border-image: url(:/images/button/288_ov.png); -} - - - - - - - - - 720 - 480 - 152 - 70 - - - - QPushButton { -border-image: url(:/images/button/152.png); -} -QPushButton::pressed { -border-image: url(:/images/button/152_ov.png); -} - - - - - - - :/images/auto_button/btn_icon_01.png:/images/auto_button/btn_icon_01.png - - - - 40 - 51 - - - - - - - 185 - 663 - 666 - 33 - - - - 1 - - - true - - - Qt::Horizontal - - - - - true - - - - 199 - 690 - 641 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 스팀 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - true - - - - 185 - 620 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 감소 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 27 - 605 - 140 - 140 - - - - QPushButton { image: url(:/images/slider_icon/gau_icon_01.png); } -QPushButton:pressed { image: url(:/images/slider_icon/gau_icon_01_ov.png); } - - - - - - icon - - - - - true - - - - 700 - 620 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 증가 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - true - - - - 700 - 780 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 증가 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - true - - - - 185 - 780 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 감소 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 27 - 765 - 140 - 140 - - - - QPushButton { image: url(:/images/slider_icon/gau_icon_01.png); } -QPushButton:pressed { image: url(:/images/slider_icon/gau_icon_01_ov.png); } - - - - - - icon - - - - - true - - - - 199 - 850 - 641 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 스팀 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 185 - 823 - 666 - 33 - - - - 1 - - - true - - - Qt::Horizontal - - - - - true - - - - 700 - 950 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 증가 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - true - - - - 185 - 950 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 감소 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 27 - 935 - 140 - 140 - - - - QPushButton { image: url(:/images/slider_icon/gau_icon_01.png); } -QPushButton:pressed { image: url(:/images/slider_icon/gau_icon_01_ov.png); } - - - - - - icon - - - - - true - - - - 199 - 1020 - 641 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 스팀 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 185 - 993 - 666 - 33 - - - - 1 - - - true - - - Qt::Horizontal - - - - - true - - - - 700 - 1130 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 증가 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - true - - - - 185 - 1130 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 감소 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 27 - 1115 - 140 - 140 - - - - QPushButton { image: url(:/images/slider_icon/gau_icon_01.png); } -QPushButton:pressed { image: url(:/images/slider_icon/gau_icon_01_ov.png); } - - - - - - icon - - - - - true - - - - 199 - 1200 - 641 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 스팀 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 185 - 1173 - 666 - 33 - - - - 1 - - - true - - - Qt::Horizontal - - - - - true - - - - 700 - 1300 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 증가 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - true - - - - 185 - 1300 - 151 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 9 - - - - 감소 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 27 - 1285 - 140 - 140 - - - - QPushButton { image: url(:/images/slider_icon/gau_icon_01.png); } -QPushButton:pressed { image: url(:/images/slider_icon/gau_icon_01_ov.png); } - - - - - - icon - - - - - true - - - - 189 - 1370 - 651 - 51 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 스팀 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 185 - 1343 - 666 - 33 - - - - 1 - - - true - - - Qt::Horizontal - - + + + + 175 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/back.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } + + + + - - - - - 720 - 480 - 152 - 70 - - - - QPushButton { border-image: url(:/images/button/152.png); } -QPushButton::pressed { border-image: url(:/images/button/152_ov.png); } - - - - - - - :/images/auto_button/btn_icon_03.png:/images/auto_button/btn_icon_03.png - - - - 38 - 37 - - - - - - - 559 - 480 - 152 - 70 - - - - QPushButton { border-image: url(:/images/button/152.png); } -QPushButton::pressed { border-image: url(:/images/button/152_ov.png); } - - - - - - - :/images/auto_button/btn_icon_02.png:/images/auto_button/btn_icon_02.png - - - - 40 - 51 - - - - - - - 259 - 480 - 288 - 70 - - - - - Roboto - 10 - 75 - true - - - - QPushButton { border-image: url(:/images/button/288.png); } -QPushButton::pressed { border-image: url(:/images/button/288_ov.png); } - - - - - - - - - 0 - 430 - 250 - 150 - - - - - - - :/images/images/auto/005_auto_icon_01_ov.png - - - Qt::AlignCenter - - - - - - 10 - 715 - 60 - 400 - - - - QPushButton { background-image: url(:/images/auto_button/prev_step.png); } -QPushButton::pressed { background-image: url(:/images/auto_button/prev_step_ov.png); } - - - - - - - - - 830 - 715 - 60 - 400 - - - - QPushButton { background-image: url(:/images/auto_button/next_step.png); } -QPushButton::pressed { background-image: url(:/images/auto_button/next_step_ov.png); } - - - - - - - - - 130 - 600 - 100 - 100 - - - - - - - :/images/symbol/time.png - - - Qt::AlignCenter - - - - - - 460 - 600 - 100 - 100 - - - - - - - :/images/symbol/core_temp.png - - - Qt::AlignCenter - - - - - - 730 - 730 - 63 - 63 - - - - QPushButton { border-image: url(:/images/symbol/info.png); } -QPushButton::pressed { border-image: url(:/images/symbol/info_ov.png); } - - - - - - - - - 80 - 710 - 100 - 100 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 14 - - - - - - - :/images/cook_step_type/sys_icon_05.png - - - Qt::AlignCenter - - - - - - 180 - 710 - 541 - 100 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 14 - - - - Preheat - - - - - - 80 - 1020 - 741 - 81 - - - - - - - :/images/images/auto/window_icon_06.png - - - Qt::AlignCenter - - - - - - 40 - 1220 - 251 - 201 - - - - TextLabel - - - - - - 100 - 810 - 291 - 290 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - - - 510 - 810 - 291 - 290 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - - - 340 - 800 - 231 - 281 - - - - - - - - - - 90 - 960 - 321 - 100 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 10 - - - Qt::AlignCenter - - - - - - 490 - 960 - 321 - 100 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 10 - - - Qt::AlignCenter - - - - - - 230 - 600 - 231 - 100 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 00:00 - - - - - - 560 - 600 - 231 - 100 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Roboto - 16 - 75 - true - - - - 000/000 - - - - - - 110 - 710 - 541 - 100 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 14 - - - - Preheat - - - - - - 100 - 810 - 291 - 290 - - - - border: #000000 - - - - - - - - - 510 - 810 - 291 - 290 - - - - border: #000000 - - - - - - - - - 460 - 1360 - 415 - 58 - - - - - - - 260 - 1370 - 100 - 48 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 14 - - - - - - - :/images/cook_step_type/sys_icon_05.png - - - Qt::AlignCenter - - - - - - 330 - 1370 - 131 - 48 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 123 - 123 - 123 - - - - - - - - - Malgun Gothic - 14 - - - - 예열 중 - - - Qt::AlignCenter - - - - - - 40 - 1220 - 251 - 201 - - - - - - - :/images/images/auto/ani_04.png - - - - - - 80 - 1320 - 85 - 24 - - - - - - - :/images/animation/close_door_arrow.png - - - - - - 80 - 1320 - 85 - 24 - - - - - - - :/images/animation/open_door_arrow.png - - + + + + 514 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/wash.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/wash_ov.png); } + + + + - + + + + 288 + 26 + 97 + 97 + + + + + 0 + 0 + + - QWidget#selectionPage { -background-image: url(:/images/images/auto/ba_ground_set); -} + QPushButton { border-image: url(:/images/bottom_bar/config.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } + + + + + + + + + 627 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/help.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); } + + + + + + + 401 + 26 + 97 + 97 + + + + + 0 + 0 + + + + QPushButton { border-image: url(:/images/bottom_bar/favorites.png); } +QPushButton:pressed { border-image: url(:/images/bottom_bar/favorites_ov.png); } + + + + + + + + + + 720 + 480 + 152 + 70 + + + + QPushButton { border-image: url(:/images/button/152.png); } +QPushButton::pressed { border-image: url(:/images/button/152_ov.png); } + + + + + + + :/images/auto_button/btn_icon_03.png:/images/auto_button/btn_icon_03.png + + + + 38 + 37 + + + + + + + 110 + 710 + 541 + 100 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 14 + + + + Preheat + + + + + + 559 + 480 + 152 + 70 + + + + QPushButton { border-image: url(:/images/button/152.png); } +QPushButton::pressed { border-image: url(:/images/button/152_ov.png); } + + + + + + + :/images/auto_button/btn_icon_02.png:/images/auto_button/btn_icon_02.png + + + + 40 + 51 + + + + + + + 80 + 1020 + 741 + 81 + + + + + + + :/images/images/auto/window_icon_06.png + + + Qt::AlignCenter + + + + + + 100 + 810 + 291 + 290 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + + + 90 + 960 + 321 + 100 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 10 + + + Qt::AlignCenter + + + + + + 180 + 710 + 541 + 100 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 14 + + + + Preheat + - + + + + 490 + 960 + 321 + 100 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 10 + + + Qt::AlignCenter + + + + + + 510 + 810 + 291 + 290 + + + + border: #000000 + + + + + + 0 - 1450 - 900 + 430 + 250 150 - + + + + + :/images/images/auto/005_auto_icon_01_ov.png + + + Qt::AlignCenter + + + + + + 560 + 600 + 231 + 100 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 000/000 + + + + + + 80 + 1320 + 85 + 24 + + + + + + + :/images/animation/close_door_arrow.png + + + + + + 230 + 600 + 231 + 100 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Roboto + 16 + 75 + true + + + + 00:00 + + + + + + 260 + 1370 + 100 + 48 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 14 + + + + + + + :/images/cook_step_type/sys_icon_05.png + + + Qt::AlignCenter + + + + + + 730 + 730 + 63 + 63 + + + + QPushButton { border-image: url(:/images/symbol/info.png); } +QPushButton::pressed { border-image: url(:/images/symbol/info_ov.png); } + + + + + + + + + 100 + 810 + 291 + 290 + + + + border: #000000 + + + + + + + + + 830 + 715 + 60 + 400 + + + + QPushButton { background-image: url(:/images/auto_button/next_step.png); } +QPushButton::pressed { background-image: url(:/images/auto_button/next_step_ov.png); } + + + + + + + + + 460 + 600 + 100 + 100 + + + + + + + :/images/symbol/core_temp.png + + + Qt::AlignCenter + + + + + + 80 + 710 + 100 + 100 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 14 + + + + + + + :/images/cook_step_type/sys_icon_05.png + + + Qt::AlignCenter + + + + + + 330 + 1370 + 131 + 48 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + Malgun Gothic + 14 + + + + 예열 중 + + + Qt::AlignCenter + + + + + + 10 + 715 + 60 + 400 + + + + QPushButton { background-image: url(:/images/auto_button/prev_step.png); } +QPushButton::pressed { background-image: url(:/images/auto_button/prev_step_ov.png); } + + + + + + + + + 40 + 1220 + 251 + 201 + + + + + + + :/images/animation/door_09.png + + + + + + 340 + 800 + 231 + 281 + + + + + + + + + + 259 + 480 + 288 + 70 + + + + + Roboto + 10 + 75 + true + + + + QPushButton { border-image: url(:/images/button/288.png); } +QPushButton::pressed { border-image: url(:/images/button/288_ov.png); } + + + + + + + + + 130 + 600 + 100 + 100 + + + + + + + :/images/symbol/time.png + + + Qt::AlignCenter + + + + + + 510 + 810 + 291 + 290 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + + + 460 + 1360 + 415 + 58 + + + + + + + 80 + 1320 + 85 + 24 + + + + + + + :/images/animation/open_door_arrow.png + + + + + + 40 + 1220 + 251 + 201 + + + + + + + :/images/animation/door_09.png + + + + + + 260 + 1200 + 640 + 250 + + + - 175 - 26 - 97 - 97 + 0 + 0 + 640 + 50 - - - 0 - 0 - + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + - - QPushButton { border-image: url(:/images/bottom_bar/back.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/back_ov.png); } + + + Malgun Gothic + 14 + 75 + true + - + 후속 과정 옵션 - + - 514 - 26 - 97 - 97 + 0 + 50 + 640 + 50 - - - 0 - 0 - + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + - - QPushButton { border-image: url(:/images/bottom_bar/wash.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/wash_ov.png); } + + + Malgun Gothic + 12 + 50 + false + - + 새로운 재료 넣기 - + - 288 - 26 - 97 - 97 + 0 + 130 + 152 + 70 - - - 0 - 0 - - - QPushButton { border-image: url(:/images/bottom_bar/config.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/config_ov.png); } + QPushButton { border-image: url(:/images/button/152.png); } +QPushButton:pressed { border-image: url(:/images/button/152_ov.png); } - + - 627 - 26 - 97 - 97 + 150 + 130 + 152 + 70 - - - 0 - 0 - - - QPushButton { border-image: url(:/images/bottom_bar/help.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); } + QPushButton { border-image: url(:/images/button/152.png); } +QPushButton:pressed { border-image: url(:/images/button/152_ov.png); } - + - 401 - 26 - 97 - 97 + 300 + 130 + 152 + 70 - - - 0 - 0 - - - QPushButton { border-image: url(:/images/bottom_bar/favorites.png); } -QPushButton:pressed { border-image: url(:/images/bottom_bar/favorites_ov.png); } + QPushButton { border-image: url(:/images/button/152.png); } +QPushButton:pressed { border-image: url(:/images/button/152_ov.png); } - stackedWidget + openDoorAnimation + closeDoorAnimation upperStack bottomBar + configCookButton + doorStepLabel + autoCookButton + cookModeIcon + humidityGauge + humidityLabel + cookStepLabel + heatLabel + cookTypeIcon + interTempLabel + closeDoorArrow + timeLabel + preheatIcon + infoButton + humidityGaugeButton + showNextStepButton + label_4 + cookStepIcon + preheatLabel + showPrevStepButton + cookStepAnimation + selectCookButton + label_3 + heatGauge + preheatGauge + openDoorArrow + heatGaugeButton + processContainer @@ -2418,6 +1346,11 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/favorites_ov.png); } 1 + AnimatedImageBox + QLabel +
animatedimagebox.h
+
+ HumidityCircularGauge QWidget
humiditycirculargauge.h
@@ -2430,11 +1363,6 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/favorites_ov.png); } 1
- AnimatedImageBox - QLabel -
animatedimagebox.h
-
- PreheatTempGauge QWidget
preheattempgauge.h
diff --git a/app/gui/oven_control/cook.cpp b/app/gui/oven_control/cook.cpp index 92f7421..21e75ee 100644 --- a/app/gui/oven_control/cook.cpp +++ b/app/gui/oven_control/cook.cpp @@ -1,516 +1,396 @@ #include "cook.h" -#include -#include +#include -#include - -AbstractCook::~AbstractCook() +static QErrorMessage *errorDialog = NULL; +static void showError(QString errorMessage) { - for (int idx = 0; idx < 5; idx++) - if (configurations[idx] != NULL) - { - delete configurations[idx]; - configurations[idx] = NULL; - } -} + if (errorDialog == NULL) + { + errorDialog = new QErrorMessage; + errorDialog->setWindowModality(Qt::ApplicationModal); + errorDialog->setGeometry(QRect(0, 426, 900, 426)); + } -Cook::CookType AbstractCook::type() -{ - return type_; + errorDialog->showMessage(errorMessage); + errorDialog->exec(); } -QString AbstractCook::name() +Cook::Cook() + : type(Define::InvalidCookType), + isInitialized_(false), isLoaded_(false), isCoreTempValid_(false), + time_(0), coreTemp_(0) { - return name_; + for (int i = 0; i < 5; i++) + configs[i].type = Define::InvalidConfig; } -int AbstractCook::time() +Cook::Cook(Define::CookType type, QString root, QString name) + : Cook() { - int t = time_; - for (int idx = 0; idx < 5; idx++) - if (configurations[idx] != NULL) - t = configurations[idx]->configureTime(t); - - return t; -} + if (!root.endsWith("/")) + root += "/"; -bool AbstractCook::interTempEnabled() -{ - return interTempEnabled_; -} + this->type = type; + this->root = root; + this->name = name; -void AbstractCook::setInterTempEnabled(bool enabled) -{ - interTempEnabled_ = enabled; + initialize(); } -int AbstractCook::interTemp() +void Cook::initialize() { - int t = interTemp_; - for (int idx = 0; idx < 5; idx++) - if (configurations[idx] != NULL) - t = configurations[idx]->configureInterTemp(t); + if (type == Define::InvalidCookType || root.isEmpty() || name.isEmpty()) + return; - return t; -} + QFile file(root + "config.csv"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + showError("File not found: " + file.fileName()); + return; + } -Cook::Step AbstractCook::currentStep() -{ - return step(currentStepIndex()); -} + int lineCount = 0; + int configIndex = 0; + while (!file.atEnd()) + { + if (configIndex == 5) + break; -int AbstractCook::currentStepIndex() -{ - return currentStep_; -} + lineCount++; -void AbstractCook::setCurrentStepIndex(int index) -{ - if (index < stepCount_ && index >= 0) - currentStep_ = index; -} + QString line = QString::fromUtf8(file.readLine()).trimmed(); + if (line.isEmpty()) + continue; -int AbstractCook::stepCount() -{ - return stepCount_; -} + if (line.startsWith("use")) + continue; -Cook::Step AbstractCook::step(int index) -{ - if (index < stepCount_) - { - Cook::Step s = stepList[index]; - for (int idx = 0; idx < 5; idx++) - if (configurations[idx] != NULL) - s = configurations[idx]->configureStep(s); + QString errorMessage = QString("%3: %1, line %2").arg(file.fileName()).arg(lineCount); - return s; - } - else - return Cook::Step { Cook::Invalid, Cook::SteamMode, 0, 0 }; -} + QString use = line.section(',', 0, 0).trimmed(); + if (use.isEmpty()) + { + showError(errorMessage.arg("Use column must be filled")); + file.close(); + return; + } -Cook::StepClass Cook::classify(Cook::StepType type) -{ - switch (type) - { - case Preheat: - return PreheatClass; - case PutThermometer: - case Load: - case Cut: - case Pour: - return DoorClass; - case Bake: - case Dry: - case Ferment: - case BlowSteam: - case CoolDown: - case Steam: - case Roast: - case Boil: - case Thicken: - case WarmUp: - case MakeCrispy: - case Finish: - case Damp: - case Defer: - case Grill: - case End: - case Burn: - case Fry: - case HeatUp: - case Ripen: - case RipenKeep: - case BoilSteadily: - case CookGratin: - case Brown: - case Simmer: - case Moisten: - return CookClass; - default: - return InvalidClass; + if (use == "yes") + { + CookConfig config; + + config.type = Define::identifyConfigType(line.section(',', 1, 1).trimmed()); + if (config.type == Define::InvalidConfig) + { + showError(errorMessage.arg("Invalid configuration type")); + file.close(); + return; + } + + bool ok; + config.maximum = line.section(',', 2, 2).trimmed().toInt(&ok); + if (!ok) + { + showError(errorMessage.arg("Invalid count")); + file.close(); + return; + } + + config.current = line.section(',', 3, 3).trimmed().toInt(&ok); + if (!ok) + { + showError(errorMessage.arg("Invalid default")); + file.close(); + return; + } + + configs[configIndex++] = config; + } + else + configs[configIndex++] = CookConfig { Define::ConfigNotUsed, 0, 0 }; } -} -Cook::Configuration AbstractCookConfig::type() -{ - return type_; -} + file.close(); -QString AbstractCookConfig::icon() -{ - return icon_; -} + for (int i = configIndex; i < 5; i++) + configs[configIndex++] = CookConfig { Define::ConfigNotUsed, 0, 0 }; -QString AbstractCookConfig::overlayIcon() -{ - return overayIcon_; + isInitialized_ = true; } -QString AbstractCookConfig::minLabel() +void Cook::setConfig(int first, int second, int third, int fourth, int fifth) { - return minLabel_; -} + if (!isInitialized()) + return; -QString AbstractCookConfig::maxLabel() -{ - return maxLabel_; -} + int currents[5] = { first, second, third, fourth, fifth }; + for (int i = 0; i < 5; i++) + { + if (configs[i].type == Define::ConfigNotUsed) + continue; -QString AbstractCookConfig::currentLabel() -{ - return currentLabel_; + if (configs[i].current != currents[i]) + { + configs[i].current = currents[i]; + isLoaded_ = false; + } + } } -int AbstractCookConfig::count() +void Cook::load() { - return count_; -} + if (!isInitialized()) + return; -void AbstractCookConfig::setCount(int value) -{ - count_ = value; - if (current_ > count_) - current_ = count_; -} + QString selection; + for (int i = 0; i < 5; i++) + { + if (configs[i].type == Define::ConfigNotUsed) + continue; -int AbstractCookConfig::current() -{ - return current_; -} + selection += QString::number(configs[i].current); + } -void AbstractCookConfig::setCurrent(int value) -{ - current_ = qBound(1, value, count_); -} + QFile dataFile(root + "data." + selection + ".csv"); + if (!dataFile.open(QIODevice::ReadOnly | QIODevice::Text)) + { + showError("File not found: " + dataFile.fileName()); + return; + } -int AbstractCookConfig::standard() -{ - return standard_; -} + steps.clear(); -void AbstractCookConfig::setStandard(int value) -{ - standard_ = qBound(1, value, count_); - setCurrent(standard_); -} + int lineCount = 0; + while (!dataFile.atEnd()) + { + lineCount++; -int AbstractCookConfig::configureTime(int standardTime) -{ - return standardTime; -} + QString line = QString::fromUtf8(dataFile.readLine()).trimmed(); + if (line.isEmpty()) + continue; -int AbstractCookConfig::configureInterTemp(int standardInterTemp) -{ - return standardInterTemp; -} + if (line.startsWith("type")) + continue; -Cook::Step AbstractCookConfig::configureStep(Cook::Step standardStep) -{ - return standardStep; -} + QString errorMessage = QString("%3: %1, line %2").arg(dataFile.fileName()).arg(lineCount); -BrightnessConfig::BrightnessConfig() -{ - type_ = Cook::Brightness; - icon_ = ":/images/slider_icon/gau_icon_01.png"; - overayIcon_ = ":/images/slider_icon/gau_icon_01_ov.png"; - minLabel_ = "연한색"; - maxLabel_ = "진한색"; -} + CookStep step; + bzero(&step, sizeof(step)); -Cook::Step BrightnessConfig::configureStep(Cook::Step standardStep) -{ - int dVal = current_ - standard_; - qreal m = 1.0 - 0.05 * dVal; + step.type = Define::identifyStepType(line.section(',', 0, 0).trimmed()); + switch (Define::classify(step.type)) + { + case Define::InvalidClass: + showError(errorMessage.arg("Invalid type")); + continue; + case Define::DoorClass: + steps.append(step); + continue; + default: + break; + } - standardStep.humidity = - qBound(0, (int) round(standardStep.humidity * m), 100); + step.mode = Define::identifyMode(line.section(',', 1, 1).trimmed()); + if (step.mode == Define::InvalidMode) + { + showError(errorMessage.arg("Invalid mode")); + continue; + } - return standardStep; -} + bool ok; -TimeConfig::TimeConfig() -{ - type_ = Cook::Time; - icon_ = ":/images/slider_icon/time.png"; - overayIcon_ = ":/images/slider_icon/time_ov.png"; - minLabel_ = "단시간"; - maxLabel_ = "장시간"; -} + step.humidity = line.section(',', 3, 3).trimmed().toInt(&ok); + if (!ok || step.humidity < 0 || step.humidity > 100) + { + showError(errorMessage.arg("Invalid humidity")); + continue; + } -int TimeConfig::configureTime(int standardTime) -{ - int dVal = current_ - standard_; - qreal m = 1.0 + 0.1 * dVal; + step.temp = line.section(',', 4, 4).trimmed().toInt(&ok); + if (!ok || step.temp < 30 || step.temp > 300) + { + showError(errorMessage.arg("Invalid temperature")); + continue; + } - standardTime = qBound(0, (int) round(standardTime * m), 24 * 60 * 60); + step.fan = line.section(',', 6, 6).trimmed().toInt(&ok); + if (!ok || step.fan < 1 || step.fan > 5) + { + showError(errorMessage.arg("Invalid fan level")); + continue; + } - return standardTime; -} + if (step.type == Define::Preheat) + { + steps.append(step); + continue; + } -BurnDegreeConfig::BurnDegreeConfig() -{ - type_ = Cook::BurnDegree; - icon_ = ":/images/slider_icon/gau_icon_02.png"; - overayIcon_ = ":/images/slider_icon/gau_icon_02_ov.png"; - minLabel_ = "중간 익힘"; - maxLabel_ = "완전 익힘"; -} + step.time = line.section(',', 2, 2).trimmed().toInt(&ok); + if (!ok || step.time <= 0) + { + showError(errorMessage.arg("Invalid time")); + continue; + } -Cook::Step BurnDegreeConfig::configureStep(Cook::Step standardStep) -{ - int dVal = current_ - standard_; - qreal m = 1.0 + 0.03 * dVal; + int tInt = line.section(',', 5, 5).trimmed().toInt(&ok); + if (ok) + { + if (tInt < 0 || tInt > 100) + { + showError(errorMessage.arg("Invalid coreTemperature")); + continue; + } - standardStep.temp = - qBound(30, (int) round(standardStep.temp * m), 300); + step.coreTemp = tInt; + } - return standardStep; -} + tInt = line.section(',', 7, 7).trimmed().toInt(&ok); + if (ok) + { + if (tInt < 0) + { + showError(errorMessage.arg("Invalid damper")); + continue; + } + + step.dehumidification = tInt; + + tInt = line.section(',', 9, 9).trimmed().toInt(&ok); + if (ok) + { + if (tInt < 0) + { + showError(errorMessage.arg("Invalid damperRepeat")); + continue; + } + + step.dehumidificationRepeatDelay = tInt; + + tInt = line.section(',', 11, 11).trimmed().toInt(&ok); + if (ok) + { + if (tInt < 0) + { + showError(errorMessage.arg("Invalid damperRepeatCount")); + continue; + } + + step.dehumidificationRepeatCount = tInt; + } + } + } -int BurnDegreeConfig::configureInterTemp(int standardInterTemp) -{ - int dVal = current_ - standard_; - qreal m = 1.0 + 0.03 * dVal; + tInt = line.section(',', 8, 8).trimmed().toInt(&ok); + if (ok) + { + if (tInt < 0) + { + showError(errorMessage.arg("Invalid sideNozzle")); + continue; + } + + step.humidification = tInt; + + tInt = line.section(',', 10, 10).trimmed().toInt(&ok); + if (ok) + { + if (tInt < 0) + { + showError(errorMessage.arg("Invalid sideNozzleRepeat")); + continue; + } + + step.humidificationRepeatDelay = tInt; + + tInt = line.section(',', 12, 12).trimmed().toInt(&ok); + if (ok) + { + if (tInt < 0) + { + showError(errorMessage.arg("Invalid sideNozzleRepeatCount")); + continue; + } + + step.humidificationRepeatCount = tInt; + } + } + } - standardInterTemp = qBound(0, (int) round(standardInterTemp * m), 99); + steps.append(step); + } - return standardInterTemp; -} + dataFile.close(); -QString Cook::name(Cook::StepType type) -{ - switch (type) + QFile processFile(root + "process.csv"); + if (!processFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - case Cook::Roast: - return "로스팅"; - case Cook::Grill: - return "그릴"; - case Cook::Boil: - return "끓이기"; - case Cook::BoilSteadily: - return "뭉근하게 끓이기"; - case Cook::HeatUp: - return "온도 높이기"; - case Cook::Thicken: - return "걸쭉하게 만들기"; - case Cook::WarmUp: - return "데우기"; - case Cook::Simmer: - return "약한 불로 끓이기"; - case Cook::End: - return "종료"; - case Cook::MakeCrispy: - return "바삭함 주기"; - case Cook::Brown: - return "브라우닝(갈색 내기)"; - case Cook::BlowSteam: - return "스팀 쏘이기"; - case Cook::Damp: - return "습윤 주기"; - case Cook::Finish: - return "피니싱"; - case Cook::Burn: - return "그을리기"; - case Cook::CookGratin: - return "그라탱 요리"; - case Cook::CoolDown: - return "식히기"; - case Cook::Defer: - return "보류"; - case Cook::RipenKeep: - return "숙성 & 보존"; - case Cook::Bake: - return "베이킹"; - case Cook::Fry: - return "기름에 재빨리 볶기"; - case Cook::Steam: - return "찌기"; - case Cook::Ripen: - return "촉촉하게"; - case Cook::Ferment: - return "숙성"; - case Cook::Moisten: - return "발효"; - case Cook::Dry: - return "건조시키기"; - default: - return ""; + showError("File not found: " + processFile.fileName()); + return; } -} -QString Cook::icon(Cook::StepType type) -{ - switch (type) + lineCount = 0; + while (!processFile.atEnd()) { - case Cook::Roast: - case Cook::Grill: - return ":/images/cook_step_type/sys_icon_01.png"; - case Cook::Boil: - case Cook::BoilSteadily: - case Cook::HeatUp: - case Cook::Thicken: - case Cook::WarmUp: - case Cook::Simmer: - return ":/images/cook_step_type/sys_icon_02.png"; - case Cook::End: - return ":/images/cook_step_type/sys_icon_03.png"; - case Cook::MakeCrispy: - case Cook::Brown: - case Cook::BlowSteam: - case Cook::Damp: - return ":/images/cook_step_type/sys_icon_04.png"; - case Cook::Finish: - return ":/images/cook_step_type/sys_icon_05.png"; - case Cook::Burn: - case Cook::CookGratin: - return ":/images/cook_step_type/sys_icon_06.png"; - case Cook::CoolDown: - return ":/images/cook_step_type/sys_icon_07.png"; - case Cook::Defer: - case Cook::RipenKeep: - return ":/images/cook_step_type/sys_icon_08.png"; - case Cook::Bake: - return ":/images/cook_step_type/sys_icon_09.png"; - case Cook::Fry: - case Cook::Steam: - return ":/images/cook_step_type/sys_icon_10.png"; - case Cook::Ripen: - case Cook::Ferment: - case Cook::Moisten: - return ":/images/cook_step_type/sys_icon_11.png"; - case Cook::Dry: - return ":/images/cook_step_type/sys_icon_12.png"; - default: - return ""; + lineCount++; + + QString line = QString::fromUtf8(processFile.readLine()).trimmed(); + if (line.isEmpty()) + continue; + + if (line.startsWith("type")) + continue; + + QString errorMessage = QString("%3: %1, line %2").arg(processFile.fileName()).arg(lineCount); + + Define::Process process = Define::identifyProcess(line); + if (process == Define::InvalidProcess) + { + showError(errorMessage.arg("Invalid type")); + continue; + } + + processes.append(process); } -} -QString Cook::icon(Cook::CookType type) -{ - switch (type) + isLoaded_ = true; + + isCoreTempValid_ = false; + time_ = 0; + coreTemp_ = 0; + foreach (CookStep s, steps) { - case Poultry: - return ":/images/cook_type/poultry_ov.png"; - case Meat: - return ":/images/cook_type/meat_ov.png"; - case Fish: - return ":/images/cook_type/fish_ov.png"; - case Desert: - return ":/images/cook_type/desert_ov.png"; - case Vegetable: - return ":/images/cook_type/vegetable_ov.png"; - case Bread: - return ":/images/cook_type/bread_ov.png"; - case Etc: - return ":/images/cook_type/etc_ov.png"; - default: - return ""; + if (s.coreTemp) + { + isCoreTempValid_ = true; + coreTemp_ = s.coreTemp; + } + + time_ += s.time; } } -FriedRice::FriedRice() +bool Cook::isCoreTempValid() { - name_ = QCoreApplication::tr("볶음밥"); - currentStep_ = 0; - stepCount_ = 4; - - stepList[0] = { Cook::Preheat, Cook::CombiMode, 100, 150 }; - stepList[1] = { Cook::Load, Cook::CombiMode, 0, 0 }; - stepList[2] = { Cook::Roast, Cook::CombiMode, 80, 130 }; - stepList[3] = { Cook::Roast, Cook::DryMode, 30, 170 }; -} + if (!isLoaded()) + load(); -ChickenCook::ChickenCook() -{ - type_ = Cook::Poultry; - name_ = QCoreApplication::tr("닭고기 요리"); - currentStep_ = 0; - stepCount_ = 5; - - stepList[0] = { Cook::Preheat, Cook::CombiMode, 100, 230 }; - stepList[1] = { Cook::Load, Cook::CombiMode, 0, 0 }; - stepList[2] = { Cook::Roast, Cook::CombiMode, 90, 210 }; - stepList[3] = { Cook::Roast, Cook::CombiMode, 50, 173 }; - stepList[4] = { Cook::Roast, Cook::DryMode, 50, 200 }; - - time_ = 39 * 60; - interTempEnabled_ = true; - interTemp_ = 88; - - BrightnessConfig *brightness = new BrightnessConfig; - brightness->setCount(5); - brightness->setStandard(3); - brightness->setCurrent(3); - configurations[0] = brightness; - - BurnDegreeConfig *burnDegree = new BurnDegreeConfig; - burnDegree->setCount(3); - burnDegree->setStandard(3); - burnDegree->setCurrent(3); - configurations[1] = burnDegree; + return isCoreTempValid_; } -MeatPie::MeatPie() +int Cook::time() { - type_ = Cook::Meat; - name_ = QCoreApplication::tr("고기 파이"); - currentStep_ = 0; - stepCount_ = 5; - - stepList[0] = { Cook::Preheat, Cook::DryMode, 100, 211 }; - stepList[1] = { Cook::Load, Cook::DryMode, 0, 0 }; - stepList[2] = { Cook::Bake, Cook::DryMode, 100, 191 }; - stepList[3] = { Cook::CoolDown, Cook::DryMode, 100, 120 }; - stepList[4] = { Cook::Bake, Cook::DryMode, 40, 120 }; - - time_ = (1 * 60 + 17) * 60; - interTempEnabled_ = true; - interTemp_ = 62; - - BrightnessConfig *brightness = new BrightnessConfig; - brightness->setCount(5); - brightness->setStandard(3); - brightness->setCurrent(3); - configurations[0] = brightness; - - BurnDegreeConfig *burnDegree = new BurnDegreeConfig; - burnDegree->setCount(3); - burnDegree->setStandard(2); - burnDegree->setCurrent(2); - configurations[1] = burnDegree; + if (!isLoaded()) + load(); + + return time_; } -Croissant::Croissant() +int Cook::coreTemp() { - type_ = Cook::Bread; - name_ = QCoreApplication::tr("크로와상/페이스트리"); - currentStep_ = 0; - stepCount_ = 6; - - stepList[0] = { Cook::Preheat, Cook::CombiMode, 100, 180 }; - stepList[1] = { Cook::Load, Cook::DryMode, 0, 0 }; - stepList[2] = { Cook::BlowSteam, Cook::SteamMode, 100, 98 }; - stepList[3] = { Cook::Bake, Cook::DryMode, 100, 170 }; - stepList[4] = { Cook::Bake, Cook::DryMode, 70, 170 }; - stepList[5] = { Cook::Bake, Cook::DryMode, 20, 170 }; - - time_ = 18 * 60; - interTempEnabled_ = false; - interTemp_ = 0; - - BrightnessConfig *brightness = new BrightnessConfig; - brightness->setCount(5); - brightness->setStandard(3); - brightness->setCurrent(3); - configurations[0] = brightness; - - TimeConfig *timeConf = new TimeConfig; - timeConf->setCount(3); - timeConf->setStandard(2); - timeConf->setCurrent(2); - configurations[4] = timeConf; + if (!isLoaded()) + load(); + + return coreTemp_; } diff --git a/app/gui/oven_control/cook.h b/app/gui/oven_control/cook.h index 6b50178..47b09ee 100644 --- a/app/gui/oven_control/cook.h +++ b/app/gui/oven_control/cook.h @@ -1,205 +1,64 @@ #ifndef COOK_H #define COOK_H -#include -#include -#include +#include "define.h" -namespace Cook { - enum CookType - { - Poultry, - Meat, - Fish, - Desert, - Vegetable, - Bread, - Etc - }; - - enum StepClass - { - InvalidClass, - PreheatClass, - DoorClass, - CookClass - }; - - enum StepType - { - Invalid, - - Preheat, // 예열 - PutThermometer, // 중심 온도계 삽입 - Load, // 식재료 적재 - Cut, // 자르기 - Pour, // 물 붓기 - - Bake, // 베이킹 - Dry, // 건조 - Ferment, // 발효 - BlowSteam, // 스팀 쏘이기 - CoolDown, // 식히기 - Steam, // 찌기 - Roast, // 로스팅 - Boil, // 끓이기 - Thicken, // 걸쭉하게 만들기 - WarmUp, // 데우기 - MakeCrispy, // 바삭하게 만들기 - Finish, // 피니싱 - Damp, // 습윤하게 만들기 - Defer, // 보류 - Grill, // 그릴 - End, // 종료 - Burn, // 그을리기 - Fry, // 기름에 볶기 - HeatUp, // 온도 높이기 - Ripen, // 숙성 - RipenKeep, // 숙성 & 보존 - BoilSteadily, // 뭉근하게 끓이기 - CookGratin, // 그라탱 요리 - Brown, // 브라우닝 - Simmer, // 약한 불로 끓이기 - Moisten // 촉촉하게 - }; - - enum Mode { - SteamMode, DryMode, CombiMode - }; - - struct Step { - StepType type; - Mode mode; - int humidity; - int temp; - }; - - enum Configuration { - Brightness, - Time, - BurnDegree - }; - - StepClass classify(StepType type); - QString name(StepType type); - QString icon(CookType type); - QString icon(StepType type); -} - -class AbstractCookConfig +struct CookConfig { -public: - Cook::Configuration type(); - QString icon(); - QString overlayIcon(); - QString minLabel(); - QString maxLabel(); - virtual QString currentLabel(); - - int count(); - int current(); - int standard(); - - virtual int configureTime(int standardTime); - virtual int configureInterTemp(int standardInterTemp); - virtual Cook::Step configureStep(Cook::Step standardStep); - -public slots: - void setCount(int value); - void setCurrent(int value); - void setStandard(int value); - -protected: - Cook::Configuration type_; - QString icon_; - QString overayIcon_; - QString minLabel_; - QString maxLabel_; - QString currentLabel_; - - int standard_; - int current_; - int count_; + Define::ConfigType type; + int maximum; + int current; }; -class AbstractCook +struct CookStep { -public: - AbstractCook() { for (int idx = 0; idx < 5; idx++) configurations[idx] = NULL; } - ~AbstractCook(); - - Cook::CookType type(); - QString name(); - int time(); - bool interTempEnabled(); - void setInterTempEnabled(bool enabled); - int interTemp(); - - Cook::Step currentStep(); - Cook::Step step(int index); - - int currentStepIndex(); - void setCurrentStepIndex(int index); - - int stepCount(); - - AbstractCookConfig *configurations[5]; - -protected: - Cook::CookType type_; - QString name_; - int time_; - bool interTempEnabled_; - int interTemp_; - int currentStep_; - int stepCount_; - Cook::Step stepList[10]; + Define::StepType type; + Define::Mode mode; + int humidity; + int temp; + int time; + int fan; + int coreTemp; + int dehumidification; + int humidification; + int dehumidificationRepeatDelay; + int humidificationRepeatDelay; + int dehumidificationRepeatCount; + int humidificationRepeatCount; }; -class BrightnessConfig : public AbstractCookConfig +class Cook { public: - BrightnessConfig(); - Cook::Step configureStep(Cook::Step standardStep); -}; + Cook(); + Cook(Define::CookType type, QString root, QString name); -class TimeConfig : public AbstractCookConfig -{ -public: - TimeConfig(); - int configureTime(int standardTime); -}; + Define::CookType type; + QString name; + QString root; -class BurnDegreeConfig : public AbstractCookConfig -{ -public: - BurnDegreeConfig(); - Cook::Step configureStep(Cook::Step standardStep); - int configureInterTemp(int standardInterTemp); -}; + CookConfig configs[5]; + QList steps; + QList processes; -class FriedRice : public AbstractCook -{ -public: - FriedRice(); -}; + void setConfig(int first, int second, int third, int fourth, int fifth); -class ChickenCook : public AbstractCook -{ -public: - ChickenCook(); -}; + bool isInitialized() { return isInitialized_; } + bool isLoaded() { return isLoaded_; } + void load(); -class MeatPie : public AbstractCook -{ -public: - MeatPie(); -}; + bool isCoreTempValid(); + int time(); + int coreTemp(); -class Croissant : public AbstractCook -{ -public: - Croissant(); +private: + bool isInitialized_; + bool isLoaded_; + bool isCoreTempValid_; + int time_; + int coreTemp_; + + void initialize(); }; #endif // COOK_H diff --git a/app/gui/oven_control/cookbook.cpp b/app/gui/oven_control/cookbook.cpp new file mode 100644 index 0000000..82d9954 --- /dev/null +++ b/app/gui/oven_control/cookbook.cpp @@ -0,0 +1,102 @@ +#include "cookbook.h" + +#include +#include + +static QErrorMessage *errorDialog = NULL; +static void showError(QString errorMessage) +{ + if (errorDialog == NULL) + { + errorDialog = new QErrorMessage; + errorDialog->setWindowModality(Qt::ApplicationModal); + errorDialog->setGeometry(QRect(0, 426, 900, 426)); + } + + errorDialog->showMessage(errorMessage); + errorDialog->exec(); +} + +CookBook::CookBook(Define::CookType type) + : type(type) +{ + switch (type) + { + case Define::Poultry: + root = QString("/prime/cookbook/poultry/"); + break; + case Define::Meat: + root = QString("/prime/cookbook/meat/"); + break; + case Define::Fish: + root = QString("/prime/cookbook/fish/"); + break; + case Define::Desert: + root = QString("/prime/cookbook/desert/"); + break; + case Define::Vegetable: + root = QString("/prime/cookbook/vegetable/"); + break; + case Define::Bread: + root = QString("/prime/cookbook/bread/"); + break; + case Define::Etc: + root = QString("/prime/cookbook/etc/"); + break; + default: + return; + } + + QFile file(root + "list.csv"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + showError("File not found: " + file.fileName()); + return; + } + + int lineCount = 0; + while (!file.atEnd()) + { + lineCount++; + + QString line = QString::fromUtf8(file.readLine()).trimmed(); + if (line.isEmpty()) + continue; + + if (line.startsWith("directory")) + continue; + + QString errorMessage = QString("%3: %1, line %2").arg(file.fileName()).arg(lineCount); + + QString directory = line.section(',', 0, 0).trimmed(); + if (directory.isEmpty()) + { + showError(errorMessage.arg("Directory name is missed")); + continue; + } + + QString cookname = line.section(',', 1, 1).trimmed(); + if (cookname.isEmpty()) + { + showError(errorMessage.arg("Cook name is missed")); + continue; + } + + list.append(cookname); + book.append(ListEntity { directory, cookname }); + } + + file.close(); +} + +Cook CookBook::get(int index) +{ + if (index < book.size()) + { + ListEntity e = book.at(index); + return Cook(type, root + e.directory, e.name); + } + + return Cook(); +} + diff --git a/app/gui/oven_control/cookbook.h b/app/gui/oven_control/cookbook.h new file mode 100644 index 0000000..4200492 --- /dev/null +++ b/app/gui/oven_control/cookbook.h @@ -0,0 +1,29 @@ +#ifndef COOKBOOK_H +#define COOKBOOK_H + +#include +#include + +#include "define.h" +#include "cook.h" + +class CookBook +{ +public: + CookBook() {} + CookBook(Define::CookType type); + QList list; + Cook get(int index); + +private: + struct ListEntity { + QString directory; + QString name; + }; + + Define::CookType type; + QString root; + QList book; +}; + +#endif // COOKBOOK_H diff --git a/app/gui/oven_control/define.cpp b/app/gui/oven_control/define.cpp new file mode 100644 index 0000000..5b30b87 --- /dev/null +++ b/app/gui/oven_control/define.cpp @@ -0,0 +1,495 @@ +#include "define.h" + +Define::ConfigType Define::identifyConfigType(QString type) +{ + if (type == "brightness") + return Brightness; + else if (type == "cookinglevel") + return BurnDegree; + else if (type == "boiledlevel") + return SoftBoilDegree; + else if (type == "size") + return PieceSize; + else if (type == "crispy1") + return CrispyDegree; + else if (type == "moisten1") + return MoistDegree; + else if (type == "thickness") + return Thickness; + else if (type == "humidity") + return Humidity; + else if (type == "temperature") + return Temperature; + else if (type == "cookingtime") + return Time; + else if (type == "coretemperature") + return CoreTemperature; + else if (type == "coretemperaturesensor") + return Thermometer; + else + return InvalidConfig; +} + +Define::StepType Define::identifyStepType(QString type) +{ + if (type == "preheat") + return Preheat; + else if (type == "load") // + return Load; + else if (type == "therometer") // + return PutThermometer; + else if (type == "cut") // + return Cut; + else if (type == "pour") // + return Pour; + else if (type == "bake") + return Bake; + else if (type == "dry") + return Dry; + else if (type == "ferment") + return Ferment; + else if (type == "steaming") + return BlowSteam; + else if (type == "cooldown") + return CoolDown; + else if (type == "steam") + return Steam; + else if (type == "roasting") + return Roast; + else if (type == "boil") + return Boil; + else if (type == "thicken") + return Thicken; + else if (type == "warmup") + return WarmUp; + else if (type == "crispy2") + return MakeCrispy; + else if (type == "finish") + return Finish; + else if (type == "damp") + return Damp; + else if (type == "defer") + return Defer; + else if (type == "grill") + return Grill; + else if (type == "end") + return End; + else if (type == "burn") + return Burn; + else if (type == "fry") + return Fry; + else if (type == "heatup") + return HeatUp; + else if (type == "ripen") + return Ripen; + else if (type == "ripenkeep") + return RipenKeep; + else if (type == "boilsteadily") + return BoilSteadily; + else if (type == "cookgratin") + return CookGratin; + else if (type == "brown") + return Brown; + else if (type == "simmer") + return Simmer; + else if (type == "moisten2") + return Moisten; + else + return Invalid; +} + +Define::StepClass Define::classify(Define::StepType type) +{ + switch (type) + { + case Invalid: + return InvalidClass; + case Preheat: + return PreheatClass; + case PutThermometer: + case Load: + case Cut: + case Pour: + return DoorClass; + case Bake: + case Dry: + case Ferment: + case BlowSteam: + case CoolDown: + case Steam: + case Roast: + case Boil: + case Thicken: + case WarmUp: + case MakeCrispy: + case Finish: + case Damp: + case Defer: + case Grill: + case End: + case Burn: + case Fry: + case HeatUp: + case Ripen: + case RipenKeep: + case BoilSteadily: + case CookGratin: + case Brown: + case Simmer: + case Moisten: + return CookClass; + } + + return InvalidClass; +} + +Define::Mode Define::identifyMode(QString mode) +{ + if (mode == "combi") + return CombiMode; + else if (mode == "dry") + return DryMode; + else if (mode == "steam") + return SteamMode; + else + return InvalidMode; +} + +QString Define::icon(Define::CookType type) +{ + switch (type) + { + case Poultry: + return ":/images/cook_type/poultry_ov.png"; + case Meat: + return ":/images/cook_type/meat_ov.png"; + case Fish: + return ":/images/cook_type/fish_ov.png"; + case Desert: + return ":/images/cook_type/desert_ov.png"; + case Vegetable: + return ":/images/cook_type/vegetable_ov.png"; + case Bread: + return ":/images/cook_type/bread_ov.png"; + case Etc: + return ":/images/cook_type/etc_ov.png"; + default: + return ""; + } +} + +QString Define::icon(Define::ConfigType type) +{ + switch (type) + { + case Brightness: + return ":/images/slider_icon/gau_icon_01.png"; + case BurnDegree: + return ":/images/slider_icon/gau_icon_02.png"; + case SoftBoilDegree: + return ":/images/slider_icon/gau_icon_03.png"; + case PieceSize: + return ":/images/slider_icon/gau_icon_04.png"; + case CrispyDegree: + return ":/images/slider_icon/gau_icon_05.png"; + case MoistDegree: + return ":/images/slider_icon/gau_icon_06.png"; + case Thickness: + return ":/images/slider_icon/gau_icon_07.png"; + case Humidity: + return ":/images/slider_icon/humidity.png"; + case Temperature: + return ":/images/slider_icon/temp.png"; + case Time: + return ":/images/slider_icon/time.png"; + case CoreTemperature: + return ":/images/slider_icon/core_temp_enabled.png"; + case Thermometer: + return ":/images/slider_icon/thermometer_enabled.png"; + case InvalidConfig: + case ConfigNotUsed: + default: + return ""; + } +} + +QString Define::iconOverlay(Define::ConfigType type) +{ + switch (type) + { + case Brightness: + return ":/images/slider_icon/gau_icon_01_ov.png"; + case BurnDegree: + return ":/images/slider_icon/gau_icon_02_ov.png"; + case SoftBoilDegree: + return ":/images/slider_icon/gau_icon_03_ov.png"; + case PieceSize: + return ":/images/slider_icon/gau_icon_04_ov.png"; + case CrispyDegree: + return ":/images/slider_icon/gau_icon_05_ov.png"; + case MoistDegree: + return ":/images/slider_icon/gau_icon_06_ov.png"; + case Thickness: + return ":/images/slider_icon/gau_icon_07_ov.png"; + case Humidity: + return ":/images/slider_icon/humidity_ov.png"; + case Temperature: + return ":/images/slider_icon/temp_ov.png"; + case Time: + return ":/images/slider_icon/time_ov.png"; + case CoreTemperature: + return ":/images/slider_icon/core_temp_ov.png"; + case Thermometer: + return ":/images/slider_icon/thermometer_ov.png"; + case InvalidConfig: + case ConfigNotUsed: + default: + return ""; + } +} + +QString Define::minimum(Define::ConfigType type) +{ + switch (type) + { + case Brightness: + return "연한색"; + case BurnDegree: + return "중간익힘"; + case SoftBoilDegree: + return "반숙"; + case PieceSize: + return "작은조각"; + case CrispyDegree: + return "연한색"; + case MoistDegree: + return "촉촉하게"; + case Thickness: + return "얇음"; + case Humidity: + return "건조함"; + case Temperature: + return "약"; + case Time: + return "단시간"; + case CoreTemperature: + return "따뜻함"; + case Thermometer: + return "있음"; + case InvalidConfig: + case ConfigNotUsed: + default: + return ""; + } +} + +QString Define::maximum(Define::ConfigType type) +{ + switch (type) + { + case Brightness: + return "진한색"; + case BurnDegree: + return "완전익힘"; + case SoftBoilDegree: + return "완숙"; + case PieceSize: + return "큰조각"; + case CrispyDegree: + return "진한색"; + case MoistDegree: + return "완전익힘"; + case Thickness: + return "두꺼움"; + case Humidity: + return "습윤"; + case Temperature: + return "강"; + case Time: + return "장시간"; + case CoreTemperature: + return "뜨거움"; + case Thermometer: + return "없음"; + case InvalidConfig: + case ConfigNotUsed: + default: + return ""; + } +} + +QString Define::icon(Define::StepType type) +{ + switch (type) + { + case Roast: + case Grill: + return ":/images/cook_step_type/sys_icon_01.png"; + case Boil: + case BoilSteadily: + case HeatUp: + case Thicken: + case WarmUp: + case Simmer: + return ":/images/cook_step_type/sys_icon_02.png"; + case End: + return ":/images/cook_step_type/sys_icon_03.png"; + case MakeCrispy: + case Brown: + case BlowSteam: + case Damp: + return ":/images/cook_step_type/sys_icon_04.png"; + case Preheat: + case Finish: + return ":/images/cook_step_type/sys_icon_05.png"; + case Burn: + case CookGratin: + return ":/images/cook_step_type/sys_icon_06.png"; + case CoolDown: + return ":/images/cook_step_type/sys_icon_07.png"; + case Defer: + case RipenKeep: + return ":/images/cook_step_type/sys_icon_08.png"; + case Bake: + return ":/images/cook_step_type/sys_icon_09.png"; + case Fry: + case Steam: + return ":/images/cook_step_type/sys_icon_10.png"; + case Ripen: + case Ferment: + case Moisten: + return ":/images/cook_step_type/sys_icon_11.png"; + case Dry: + return ":/images/cook_step_type/sys_icon_12.png"; + default: + return ""; + } +} + +QString Define::name(Define::StepType type) +{ + switch (type) + { + case Preheat: + return "예열"; + case PutThermometer: + return "중심 온도계 삽입"; + case Load: + return "식재료 적재"; + case Cut: + return "자르기"; + case Pour: + return "물 붓기"; + case Bake: + return "베이킹"; + case Dry: + return "건조"; + case Ferment: + return "발효"; + case BlowSteam: + return "스팀 쏘이기"; + case CoolDown: + return "식히기"; + case Steam: + return "찌기"; + case Roast: + return "로스팅"; + case Boil: + return "끓이기"; + case Thicken: + return "걸쭉하게 만들기"; + case WarmUp: + return "데우기"; + case MakeCrispy: + return "바삭하게 만들기"; + case Finish: + return "피니싱"; + case Damp: + return "습윤하게 만들기"; + case Defer: + return "보류"; + case Grill: + return "그릴"; + case End: + return "종료"; + case Burn: + return "그을리기"; + case Fry: + return "기름에 재빨리 볶기"; + case HeatUp: + return "온도 높이기"; + case Ripen: + return "숙성"; + case RipenKeep: + return "숙성 & 보존"; + case BoilSteadily: + return "뭉근하게 끓이기"; + case CookGratin: + return "그라탱 요리"; + case Brown: + return "브라우닝"; + case Simmer: + return "약한 불로 끓이기"; + case Moisten: + return "촉촉하게"; + default: + return ""; + } +} + +Define::Process Define::identifyProcess(QString type) +{ + if (type == "again") + return CookAgain; + else if (type == "crispy3") + return MakeCrisper; + else if (type == "heatreserve") + return KeepWarm; + else + return InvalidProcess; +} + +QString Define::icon(Define::Process type) +{ + switch (type) + { + case CookAgain: + return ":/images/auto_button/option_btn_01.png"; + case MakeCrisper: + return ":/images/auto_button/option_btn_01.png"; + case KeepWarm: + return ":/images/auto_button/option_btn_01.png"; + default: + return ":/images/button/152.png"; + } +} + +QString Define::iconOverlay(Define::Process type) +{ + switch (type) + { + case CookAgain: + return ":/images/auto_button/option_btn_01_ov.png"; + case MakeCrisper: + return ":/images/auto_button/option_btn_01_ov.png"; + case KeepWarm: + return ":/images/auto_button/option_btn_01_ov.png"; + default: + return ":/images/button/152_ov.png"; + } +} + +QString Define::name(Define::Process type) +{ + switch (type) + { + case CookAgain: + return "새로운 재료 넣기"; + case MakeCrisper: + return "바삭함 주기"; + case KeepWarm: + return "보온 유지"; + default: + return ""; + } +} diff --git a/app/gui/oven_control/define.h b/app/gui/oven_control/define.h new file mode 100644 index 0000000..a0962b9 --- /dev/null +++ b/app/gui/oven_control/define.h @@ -0,0 +1,118 @@ +#ifndef DEFINE_H +#define DEFINE_H + +#include + +namespace Define +{ + enum CookType + { + InvalidCookType, + Poultry, + Meat, + Fish, + Desert, + Vegetable, + Bread, + Etc + }; + + QString icon(CookType type); + + enum ConfigType + { + InvalidConfig, + ConfigNotUsed, + Brightness, + BurnDegree, + SoftBoilDegree, + PieceSize, + CrispyDegree, + MoistDegree, + Thickness, + Humidity, + Temperature, + Time, + CoreTemperature, + Thermometer + }; + + ConfigType identifyConfigType(QString type); + QString icon(ConfigType type); + QString iconOverlay(ConfigType type); + QString minimum(ConfigType type); + QString maximum(ConfigType type); + + enum StepClass + { + InvalidClass, + PreheatClass, + DoorClass, + CookClass + }; + + enum StepType + { + Invalid, + + Preheat, // 예열 + + PutThermometer, // 중심 온도계 삽입 + Load, // 식재료 적재 + Cut, // 자르기 + Pour, // 물 붓기 + + Bake, // 베이킹 + Dry, // 건조 + Ferment, // 발효 + BlowSteam, // 스팀 쏘이기 + CoolDown, // 식히기 + Steam, // 찌기 + Roast, // 로스팅 + Boil, // 끓이기 + Thicken, // 걸쭉하게 만들기 + WarmUp, // 데우기 + MakeCrispy, // 바삭하게 만들기 + Finish, // 피니싱 + Damp, // 습윤하게 만들기 + Defer, // 보류 + Grill, // 그릴 + End, // 종료 + Burn, // 그을리기 + Fry, // 기름에 볶기 + HeatUp, // 온도 높이기 + Ripen, // 숙성 + RipenKeep, // 숙성 & 보존 + BoilSteadily, // 뭉근하게 끓이기 + CookGratin, // 그라탱 요리 + Brown, // 브라우닝 + Simmer, // 약한 불로 끓이기 + Moisten // 촉촉하게 + }; + + StepType identifyStepType(QString type); + StepClass classify(StepType type); + QString icon(StepType type); + QString name(StepType type); + + enum Mode { + InvalidMode, SteamMode, DryMode, CombiMode + }; + + Mode identifyMode(QString mode); + + enum Process + { + InvalidProcess, + CookAgain, + MakeCrisper, + KeepWarm + }; + + Process identifyProcess(QString type); + QString icon(Process type); + QString iconOverlay(Process type); + QString name(Process type); +} + +#endif // DEFINE_H diff --git a/app/gui/oven_control/keepwarmpopup.cpp b/app/gui/oven_control/keepwarmpopup.cpp new file mode 100644 index 0000000..d7348ec --- /dev/null +++ b/app/gui/oven_control/keepwarmpopup.cpp @@ -0,0 +1,34 @@ +#include "keepwarmpopup.h" +#include "ui_keepwarmpopup.h" + +KeepWarmPopup::KeepWarmPopup(QWidget *parent) : + QWidget(parent), + ui(new Ui::KeepWarmPopup) +{ + ui->setupUi(this); + + setAttribute(Qt::WA_DeleteOnClose); + + connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView())); + updateViewTimer.start(100); + + startTime.start(); +} + +KeepWarmPopup::~KeepWarmPopup() +{ + delete ui; +} + +void KeepWarmPopup::updateView() +{ + int elapsed = startTime.elapsed() / 1000; + ui->timeLabel->setText(QString("%1:%2") + .arg(elapsed / 60, 2, 10, QLatin1Char('0')) + .arg(elapsed % 60, 2, 10, QLatin1Char('0'))); +} + +void KeepWarmPopup::on_stopButton_clicked() +{ + close(); +} diff --git a/app/gui/oven_control/keepwarmpopup.h b/app/gui/oven_control/keepwarmpopup.h new file mode 100644 index 0000000..76bd9a9 --- /dev/null +++ b/app/gui/oven_control/keepwarmpopup.h @@ -0,0 +1,32 @@ +#ifndef KEEPWARMPOPUP_H +#define KEEPWARMPOPUP_H + +#include +#include +#include + +namespace Ui { +class KeepWarmPopup; +} + +class KeepWarmPopup : public QWidget +{ + Q_OBJECT + +public: + explicit KeepWarmPopup(QWidget *parent = 0); + ~KeepWarmPopup(); + +private: + Ui::KeepWarmPopup *ui; + + QTime startTime; + QTimer updateViewTimer; + + +private slots: + void updateView(); + void on_stopButton_clicked(); +}; + +#endif // KEEPWARMPOPUP_H diff --git a/app/gui/oven_control/keepwarmpopup.ui b/app/gui/oven_control/keepwarmpopup.ui new file mode 100644 index 0000000..0643911 --- /dev/null +++ b/app/gui/oven_control/keepwarmpopup.ui @@ -0,0 +1,362 @@ + + + KeepWarmPopup + + + + 0 + 0 + 900 + 1600 + + + + Form + + + QPushButton { border: none; } + + + + + 21 + 446 + 858 + 984 + + + + #background { +background-image: url(:/images/background/original.png); +margin: -446px -170px -21px -21px; +padding: 446px 170px 21px 21px; +image: url(:/images/background/popup/error.png); +} + + + + + 0 + 0 + 858 + 227 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + NanumGothic + 18 + 75 + true + + + + 보온 유지 + + + Qt::AlignCenter + + + + + + 0 + 227 + 858 + 252 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + NanumGothic + 14 + 75 + true + + + + 보온 유지 중입니다 + + + Qt::AlignCenter + + + + + + 0 + 479 + 858 + 252 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 123 + 123 + 123 + + + + + + + + + NanumGothic + 22 + 75 + true + + + + 00:00 + + + Qt::AlignCenter + + + + + + 0 + 731 + 858 + 252 + + + + + 10 + + + + QPushButton { color: white; } +QPushButton:pressed { color: yellow; } + + + 중단 + + + + + + + 0 + 0 + 900 + 446 + + + + + + + + + + 0 + 446 + 21 + 984 + + + + + + + + + + 879 + 446 + 130 + 984 + + + + + + + + + + 0 + 1430 + 900 + 170 + + + + + + + + + + + upperCloseButton + clicked() + KeepWarmPopup + close() + + + 449 + 222 + + + 449 + 799 + + + + + leftCloseButton + clicked() + KeepWarmPopup + close() + + + 10 + 937 + + + 449 + 799 + + + + + rightCloseButton + clicked() + KeepWarmPopup + close() + + + 943 + 937 + + + 449 + 799 + + + + + bottomCloseButton + clicked() + KeepWarmPopup + close() + + + 449 + 1514 + + + 449 + 799 + + + + + diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index 75b0885..70d4ef6 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -14,7 +14,7 @@ TEMPLATE = app SOURCES += main.cpp\ - mainwindow.cpp \ + mainwindow.cpp \ cook.cpp \ oven.cpp \ abstractoveninterface.cpp \ @@ -46,7 +46,11 @@ SOURCES += main.cpp\ engineermenuwindow.cpp \ ovenstatics.cpp \ servicedatas.cpp \ - popupwindow.cpp + popupwindow.cpp \ + cookbook.cpp \ + define.cpp \ + autocook.cpp \ + keepwarmpopup.cpp HEADERS += mainwindow.h \ cook.h \ @@ -81,7 +85,11 @@ HEADERS += mainwindow.h \ engineermenuwindow.h \ ovenstatics.h \ servicedatas.h \ - popupwindow.h + popupwindow.h \ + cookbook.h \ + define.h \ + autocook.h \ + keepwarmpopup.h FORMS += mainwindow.ui \ manualcookwindow.ui \ @@ -100,7 +108,8 @@ FORMS += mainwindow.ui \ preheatpopup.ui \ cooldownpopup.ui \ engineermenuwindow.ui \ - popupwindow.ui + popupwindow.ui \ + keepwarmpopup.ui RESOURCES += \ resources.qrc diff --git a/app/gui/oven_control/preheattempgauge.cpp b/app/gui/oven_control/preheattempgauge.cpp index 1f6dca8..6625901 100644 --- a/app/gui/oven_control/preheattempgauge.cpp +++ b/app/gui/oven_control/preheattempgauge.cpp @@ -9,32 +9,41 @@ PreheatTempGauge::PreheatTempGauge(QWidget *parent) : QWidget(parent) indicator.load(":/images/gauge/bar_indicator.png"); body.load(":/images/gauge/bar_short_red.png"); - value = 0; + val = 0; min = 0; max = 1; } void PreheatTempGauge::setValue(int value) { - this->value = qBound(min, value, max); + if (value == val) + return; + + val = qBound(min, value, max); update(); } void PreheatTempGauge::setMinimum(int minimum) { + if (minimum == min) + return; + min = minimum; max = qMax(min, max); - value = qBound(min, value, max); + val = qBound(min, val, max); update(); } void PreheatTempGauge::setMaximum(int maximum) { + if (maximum == max) + return; + max = maximum; min = qMin(min, max); - value = qBound(min, value, max); + val = qBound(min, val, max); update(); } @@ -45,7 +54,7 @@ void PreheatTempGauge::paintEvent(QPaintEvent */*event*/) painter.setBrush(Qt::NoBrush); painter.setPen(Qt::NoPen); - qreal percentage = (qreal) (value - min) / qMax(max - min, 1); + qreal percentage = (qreal) (val - min) / qMax(max - min, 1); percentage = qBound((qreal) 0.0, percentage, (qreal) 1.0); QRect targetRect( diff --git a/app/gui/oven_control/preheattempgauge.h b/app/gui/oven_control/preheattempgauge.h index 56436c5..9340112 100644 --- a/app/gui/oven_control/preheattempgauge.h +++ b/app/gui/oven_control/preheattempgauge.h @@ -13,7 +13,7 @@ public: signals: public slots: - void setValue(int value); + void setValue(int val); void setMinimum(int minimum); void setMaximum(int maximum); @@ -25,7 +25,7 @@ protected: QPixmap border; QPixmap indicator; - int value; + int val; int min; int max; }; -- 2.1.4