washtestwindow.cpp 2.24 KB
#include "washtestwindow.h"
#include "ui_washtestwindow.h"

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

    ui->clockContainer->setParent(ui->upperStack);
    setAttribute(Qt::WA_DeleteOnClose);

    udp = UdpHandler::getInstance();
    connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged()));

    udp->set(TG_OVEN_MODE, 4);
    udp->turnOn(TG_SYSTEM);
    udp->turnOn(TG_MANUAL_RELAY);

    onDataChanged();
}

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

void WashTestWindow::onDataChanged()
{
    if (udp->dp())
        ui->steamPumpButton->setText("STOP");
    else
        ui->steamPumpButton->setText("START");

    if (udp->ssp())
        ui->cleanserPumpButton->setText("STOP");
    else
        ui->cleanserPumpButton->setText("START");

    if (udp->unp())
        ui->upperPumpButton->setText("STOP");
    else
        ui->upperPumpButton->setText("START");
}

void WashTestWindow::on_steamPumpButton_clicked()
{
    if (udp->dp())
        steamPumpOff();
    else
        steamPumpOn();
}

void WashTestWindow::on_cleanserPumpButton_clicked()
{
    if (udp->ssp())
        cleanserPumpOff();
    else
        cleanserPumpOn();
}

void WashTestWindow::on_upperPumpButton_clicked()
{
    if (udp->unp())
        upperPumpOff();
    else
        upperPumpOn();
}

void WashTestWindow::on_drainValveStartButton_clicked()
{
    drainValveOpen();
}

void WashTestWindow::on_drainValveStopButton_clicked()
{
    drainValveClose();
}

void WashTestWindow::on_backButton_clicked()
{
    steamPumpOff();
    cleanserPumpOff();
    upperPumpOff();
    drainValveClose();

    udp->turnOff(TG_MANUAL_RELAY);
    udp->turnOff(TG_SYSTEM);

    close();
}

void WashTestWindow::steamPumpOn()
{
    udp->turnOn(TG_DP);
}

void WashTestWindow::steamPumpOff()
{
    udp->turnOff(TG_DP);
}

void WashTestWindow::cleanserPumpOn()
{
    udp->turnOn(TG_SSP);
}

void WashTestWindow::cleanserPumpOff()
{
    udp->turnOff(TG_SSP);
}

void WashTestWindow::upperPumpOn()
{
    udp->turnOn(TG_UNP);
}

void WashTestWindow::upperPumpOff()
{
    udp->turnOff(TG_UNP);
}

void WashTestWindow::drainValveOpen()
{
    udp->turnOn(TG_DV);
}

void WashTestWindow::drainValveClose()
{
    udp->turnOff(TG_DV);
}