realtimepartswindow.cpp 3.15 KB
#include "realtimepartswindow.h"
#include "ui_realtimepartswindow.h"
#include "ovenstatics.h"

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

//    for(i=0;i<CONTROL_LIST_COL_MAX;i++){
//        for(j=0;i<CONTROL_LIST_ITEM_MAX;j++){
//            m_arrLbState[i][j]=NULL;
//        }
//    }

    m_arrLbState[0][0] = ui->m_ctrlLbListState_1_1;
    m_arrLbState[0][1] = ui->m_ctrlLbListState_1_2;
    m_arrLbState[0][2] = ui->m_ctrlLbListState_1_3;
    m_arrLbState[0][3] = ui->m_ctrlLbListState_1_4;
    m_arrLbState[0][4] = ui->m_ctrlLbListState_1_5;
    m_arrLbState[0][5] = ui->m_ctrlLbListState_1_6;
    m_arrLbState[0][6] = ui->m_ctrlLbListState_1_7;
    m_arrLbState[0][7] = ui->m_ctrlLbListState_1_8;

    m_arrLbState[1][0] = ui->m_ctrlLbListState_2_1;
    m_arrLbState[1][1] = ui->m_ctrlLbListState_2_2;
    m_arrLbState[1][2] = ui->m_ctrlLbListState_2_3;
    m_arrLbState[1][3] = ui->m_ctrlLbListState_2_4;
    m_arrLbState[1][4] = ui->m_ctrlLbListState_2_5;
    m_arrLbState[1][5] = ui->m_ctrlLbListState_2_6;
    m_arrLbState[1][6] = ui->m_ctrlLbListState_2_7;
    m_arrLbState[1][7] = ui->m_ctrlLbListState_2_8;

    m_arrLbState[2][0] = ui->m_ctrlLbListState_3_1;
    m_arrLbState[2][1] = ui->m_ctrlLbListState_3_2;
    m_arrLbState[2][2] = ui->m_ctrlLbListState_3_3;
    m_arrLbState[2][3] = ui->m_ctrlLbListState_3_4;
    m_arrLbState[2][4] = ui->m_ctrlLbListState_3_5;
    m_arrLbState[2][5] = ui->m_ctrlLbListState_3_6;
    m_arrLbState[2][6] = ui->m_ctrlLbListState_3_7;
    m_arrLbState[2][7] = ui->m_ctrlLbListState_3_8;


    reloadUi();

}

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

void realtimePartsWindow::on_backButton_clicked()
{
    deleteLater();
}

void realtimePartsWindow::reloadUi(void){
    OvenStatistics* ovs = OvenStatistics::getInstance();
    QString strTemp = "";
    int i = 0,j=0;
    realtime_data realdata;
    if(ovs  != NULL){
        realdata = ovs->getPartsRealtimeData();
    }

    if(realdata.b.ssv_open) ui->m_ctrlLbListState_1_1->setText(tr("ON"));
    else ui->m_ctrlLbListState_1_1->setText(tr("OFF"));

    if(realdata.b.qnv_open) ui->m_ctrlLbListState_1_2->setText(tr("ON"));
    else ui->m_ctrlLbListState_1_2->setText(tr("OFF"));

    if(realdata.b.snv_open) ui->m_ctrlLbListState_1_3->setText(tr("ON"));
    else ui->m_ctrlLbListState_1_3->setText(tr("OFF"));

    strTemp.sprintf("%d",realdata.b.water_level);
    ui->m_ctrlLbListState_1_4->setText(strTemp);

    if(realdata.b.sgnv_open) ui->m_ctrlLbListState_1_5->setText(tr("ON"));
    else ui->m_ctrlLbListState_1_5->setText(tr("OFF"));

    if(realdata.b.dv_open) ui->m_ctrlLbListState_1_6->setText(tr("ON"));
    else ui->m_ctrlLbListState_1_6->setText(tr("OFF"));

    if(realdata.b.wsv_open) ui->m_ctrlLbListState_1_7->setText(tr("ON"));
    else ui->m_ctrlLbListState_1_7->setText(tr("OFF"));

    if(realdata.b.door_open) ui->m_ctrlLbListState_1_8->setText(tr("ON"));
    else ui->m_ctrlLbListState_1_8->setText(tr("OFF"));


    for(i=1;i<CONTROL_LIST_COL_MAX;i++){
        for(j=0;j<CONTROL_LIST_ITEM_MAX;j++){
            m_arrLbState[i][j]->setText("-");
        }
    }

}