#include "cellinfo_page.h" #include "ui_cellinfo_page.h" #include CellInfo_page::CellInfo_page(QWidget *parent, Work_Thread *wt) : custom_dialog(parent), ui(new Ui::CellInfo_page) { ui->setupUi(this); workThread = wt; set_btn_beep(ui->pushButton_Exit,SIGNAL(pressed())); connect(ui->pushButton_Exit,SIGNAL(released()),this,SLOT(buttonReleasedAction())); timer_500ms = new QTimer(this); connect(timer_500ms,SIGNAL(timeout()),this,SLOT(update_slot())); } CellInfo_page::~CellInfo_page() { delete ui; delete timer_500ms; //qDebug("~CellInfo_page"); } void CellInfo_page::showCellinfoPage() { dspValue(); timer_500ms->start(500); this->exec(); } void CellInfo_page::closeCellinfoPage() { timer_500ms->stop(); this->close(); } void CellInfo_page::SystemTime(void) { QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间 QString str = time.toString("yyyy-MM-dd hh:mm:ss"); //设置显示格式 ui->label_Time->setText(str); } void CellInfo_page::checkIcon() { /* if(workThread->iconState.usbState) ui->label_USB->setPixmap(QPixmap(":new/prefix1/usb.png")); else ui->label_USB->setPixmap(QPixmap("")); */ } void CellInfo_page::dspValue() { QString title = tr("单体信息--"); if(workThread->packParam.pack_type == PACK_TYPE_Halo){ title += tr("哈啰"); } else{ title += tr("其它"); } ui->label_Title->setText(title); pageSum = workThread->packData.cell_count/15; if(workThread->packData.cell_count%15 > 0){ pageSum += 1; } if(pageSum<1){ pageSum = 1; } pageIndex = 0; if(pageSum < 2){ ui->pushButton_pre->setEnabled(false); ui->pushButton_next->setEnabled(false); } QTableWidgetItem *item; for(int i=1;i<6;i++) { for(int j=0;j<6;j++) { item = new QTableWidgetItem(""); item->setTextAlignment(0x0084); ui->tableWidget->setItem(i,j,item); } } setTable(); updateValue(); } void CellInfo_page::setTable() { ui->label_pagecnt->setText(QString::number(pageIndex+1) + "/" +QString::number(pageSum));//+tr(" 页")); quint16 cellindexstart = pageIndex*15; QTableWidgetItem *item; int row = 0; int col = 0; for(quint8 n=0;n<15;n++){ QString str = QString::number(cellindexstart+1+n)+"#"; row = (n/3)+1; col = (n%3)*2; //qDebug("row = %d,col = %d",row,col); item = ui->tableWidget->item(row, col); item->setText(str); } } void CellInfo_page::updateValue() { QString tempstr; for(quint16 n=0;npackData.temp_count;n++){ tempstr += "T" + QString::number(n+1)+" = "; tempstr += QString::number(workThread->packData.cell_temp[n]); tempstr += " "; } ui->label_temp1->setText(tempstr); quint16 cellindexstart = pageIndex*15; QTableWidgetItem *item; int row = 0; int col = 0; for(quint8 n=0;n<15;n++){ QString str = QString::number((double)workThread->packData.cell_vol[cellindexstart+n]/1000,'f',3); row = (n/3)+1; col = (n%3)*2+1; //qDebug("row = %d,col = %d",row,col); item = ui->tableWidget->item(row, col); item->setText(str); } } void CellInfo_page::update_slot() { SystemTime(); checkIcon(); updateValue(); if(1 == workThread->remoteState.to_workpage){ closeCellinfoPage(); } } void CellInfo_page::buttonReleasedAction() { QPushButton *pb = dynamic_cast(sender()); if(ui->pushButton_Exit == pb) { close(); } }