flushwaterwindow.cpp 1.63 KB
#include "flushwaterwindow.h"
#include "ui_flushwaterwindow.h"

#include "udphandler.h"
#include "notipopupdlg.h"

FlushWaterWindow::FlushWaterWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::FlushWaterWindow)
{
    ui->setupUi(this);

    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);


    UdpHandler *udp = UdpHandler::getInstance();
    udp->set(TG_OVEN_MODE, 4);
    udp->turnOn(TG_MANUAL_RELAY);
    udp->turnOn(TG_DV);
    udp->turnOn(TG_DP);
    udp->turnOn(TG_INV);
    udp->turnOff(TG_SSV);

    terminator = new QTimer(this);
    connect(terminator, SIGNAL(timeout()), SLOT(waitUser()));
    terminator->start(60 * 1000);

    QTimer *updater = new QTimer(this);
    connect(updater, SIGNAL(timeout()), SLOT(updateGauge()));
    updater->start(300);

    ui->progressGauge->setMaximum(terminator->interval());
    ui->progressGauge->setValue(0);
}

FlushWaterWindow::~FlushWaterWindow()
{
    delete ui;
}

void FlushWaterWindow::updateGauge()
{
    ui->progressGauge->setValue(terminator->interval() - terminator->remainingTime());
}

void FlushWaterWindow::waitUser()
{
    UdpHandler *udp = UdpHandler::getInstance();
    udp->turnOff(TG_DP);
    udp->turnOff(TG_INV);

    NotiPopupDlg* notidlg = new NotiPopupDlg(this, tr("동파 방지 실행이 완료되었습니다. 전원을 OFF 해주십시오"), tr("취소"));
    notidlg->exec();

    deleteLater();

    udp->turnOff(TG_MANUAL_RELAY);
}