diff --git a/app/gui/oven_control/washwindow.cpp b/app/gui/oven_control/washwindow.cpp index ae94e0e..91afb25 100644 --- a/app/gui/oven_control/washwindow.cpp +++ b/app/gui/oven_control/washwindow.cpp @@ -153,15 +153,7 @@ void WashWindow::start(int type) returnToClockTimer.stop(); - ui->animation->clear(); - ui->animation->load(":/images/animation/pull_01.png"); - ui->animation->load(":/images/animation/pull_02.png"); - ui->animation->load(":/images/animation/pull_03.png"); - ui->animation->load(":/images/animation/pull_04.png"); - ui->animation->show(); - ui->animation->start(300); - - udp->set(TG_OVEN_MODE, 2); + showOpenDoor(); } } @@ -246,10 +238,67 @@ void WashWindow::updateView() break; } } + + switch (state) + { + case Idle: + case CoolDown: + showIdle(); + break; + case OpenDoor: + if (udp->getData().door_state == 0) + showOpenDoor(); + break; + case CloseDoor: + case Request: + case Running: + case Stopping: + case RequestClean: + case RunningClean: + if (udp->getData().door_state != 0) + showCloseDoor(); + else + showWash(); + break; + } +} + +void WashWindow::showIdle() +{ + if (animationState == Stopped) + return; + + animationState = Stopped; + + ui->animation->stop(); + ui->animation->clear(); + ui->animation->load(":/images/animation/wash_04.png"); +} + +void WashWindow::showOpenDoor() +{ + if (animationState == ShowingOpenDoor) + return; + + animationState = ShowingOpenDoor; + + ui->animation->clear(); + ui->animation->load(":/images/animation/pull_01.png"); + ui->animation->load(":/images/animation/pull_02.png"); + ui->animation->load(":/images/animation/pull_03.png"); + ui->animation->load(":/images/animation/pull_04.png"); + ui->animation->show(); + ui->animation->start(300); + ui->closeDoorArrow->hide(); } void WashWindow::showCloseDoor() { + if (animationState == ShowingCloseDoor) + return; + + animationState = ShowingCloseDoor; + ui->animation->clear(); ui->animation->load(":/images/animation/door_big_09.png"); ui->animation->load(":/images/animation/door_big_08.png"); @@ -260,26 +309,39 @@ void WashWindow::showCloseDoor() ui->animation->load(":/images/animation/door_big_03.png"); ui->animation->load(":/images/animation/door_big_02.png"); ui->animation->load(":/images/animation/door_big_01.png"); + ui->animation->show(); ui->animation->start(300); ui->closeDoorArrow->show(); } -void WashWindow::request() +void WashWindow::showWash() { - udp->set(TG_CLEAN_TYPE, type); - udp->turnOn(TG_CLEANING); - - OvenStatistics::getInstance()->setWashState(true); + if (animationState == ShowingWash) + return; - SoundPlayer::playStart(); + animationState = ShowingWash; - ui->closeDoorArrow->hide(); ui->animation->clear(); ui->animation->load(":/images/animation/wash_01.png"); ui->animation->load(":/images/animation/wash_02.png"); ui->animation->load(":/images/animation/wash_03.png"); ui->animation->load(":/images/animation/wash_04.png"); + ui->animation->show(); ui->animation->start(300); + ui->closeDoorArrow->hide(); +} + +void WashWindow::request() +{ + udp->set(TG_OVEN_MODE, 2); + udp->set(TG_CLEAN_TYPE, type); + udp->turnOn(TG_CLEANING); + + OvenStatistics::getInstance()->setWashState(true); + + SoundPlayer::playStart(); + + showWash(); ui->washStepGauge->setValue(0); ui->titleLabel->setText(tr("기기의 내부를 세척 중입니다")); diff --git a/app/gui/oven_control/washwindow.h b/app/gui/oven_control/washwindow.h index d62d4ff..8919427 100644 --- a/app/gui/oven_control/washwindow.h +++ b/app/gui/oven_control/washwindow.h @@ -30,7 +30,10 @@ private slots: void updateGauge(); void updateView(); + void showIdle(); + void showOpenDoor(); void showCloseDoor(); + void showWash(); void request(); void onChanged(); @@ -48,6 +51,10 @@ private: RequestClean, RunningClean } state = Idle; + enum AnimationState { + Stopped, ShowingOpenDoor, ShowingCloseDoor, ShowingWash + } animationState = Stopped; + bool selected; bool opened; bool started;