#include "componenttestwindow.h" #include "ui_componenttestwindow.h" ComponentTestWindow::ComponentTestWindow(QWidget *parent, UdpHandler *udp) : QMainWindow(parent), ui(new Ui::ComponentTestWindow), udp(udp) { ui->setupUi(this); ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged())); damperTimer.setInterval(10 * 1000); connect(&damperTimer, SIGNAL(timeout()), this, SLOT(damperOff())); udp->set(TG_OVEN_MODE, 4); udp->turnOn(TG_SYSTEM); udp->turnOn(TG_MANUAL_RELAY); onDataChanged(); } ComponentTestWindow::~ComponentTestWindow() { delete ui; } void ComponentTestWindow::onDataChanged() { if (udp->hl()) ui->lampButton->setText("OFF"); else ui->lampButton->setText("ON"); if (udp->hdm()) ui->damperButton->setText("STOP"); else ui->damperButton->setText("START"); } void ComponentTestWindow::on_speakerButton_clicked() { } void ComponentTestWindow::on_lampButton_clicked() { if (udp->hl()) lampOff(); else lampOn(); } void ComponentTestWindow::on_damperButton_clicked() { if (udp->hdm()) { damperTimer.stop(); damperOff(); } else { damperTimer.start(); damperOn(); } } void ComponentTestWindow::on_backButton_clicked() { damperTimer.stop(); udp->turnOff(TG_MANUAL_RELAY); udp->turnOff(TG_SYSTEM); close(); } void ComponentTestWindow::lampOn() { udp->turnOn(TG_HL); } void ComponentTestWindow::lampOff() { udp->turnOff(TG_HL); } void ComponentTestWindow::damperOn() { udp->turnOn(TG_HDM); } void ComponentTestWindow::damperOff() { udp->turnOff(TG_HDM); }