diff --git a/softwareDirectory/AutoVerScheme/checkwindow.cpp b/softwareDirectory/AutoVerScheme/checkwindow.cpp index 82050e1..976715c 100644 --- a/softwareDirectory/AutoVerScheme/checkwindow.cpp +++ b/softwareDirectory/AutoVerScheme/checkwindow.cpp @@ -345,6 +345,7 @@ iEquipType = CliTable[0].belong_standard_equipment.toInt(); } //QStringList headlist; + pageButtons.clear(); headList.clear(); calibrationList.clear(); headTableList.clear(); @@ -423,6 +424,7 @@ //tackedWidget->setCurrentIndex(index); initCheckTable(index); }); + pageButtons.append(button); ++index; } ui->HeadListLayout->addStretch(); @@ -770,6 +772,10 @@ // } if(curHeadIdx==idx) return; + + + pageButtons[idx]->setChecked(true); + curHeadIdx = idx; QString sLabel = headTableList.keys()[curHeadIdx]; const auto &dataRes = caliDataList.value(sLabel); @@ -835,15 +841,22 @@ } return dTmp; } -//double CheckWindow::TranDecimals(QString sLabel,QStringList data,double TestValue) -//{ - /* int dex=getIndexByHeader(sLabel,"标准值"); - double StanValue=data[dex].toDouble(); - while (tmp != std::floor(tmp)) { - tmp *= 10; - ++decimalPlaces; - }*/ -//} +QString CheckWindow::TranDecimals(QString sLabel,QStringList data,double TestValue) +{ + int dex=getIndexByHeader(sLabel,"标准值"); + QString StanValue=data[dex]; + int decimalPlaces = 0; + int decimalPos = StanValue.indexOf('.'); + if (decimalPos == -1) { + decimalPlaces=1; + }else{ + decimalPlaces=StanValue.length() - decimalPos - 1; + } + + + QString formattedTestValue = QString::number(TestValue, 'f', decimalPlaces); + return formattedTestValue; +} QString CheckWindow::transCmd(QString sCmd,QString sLabel,QStringList data,bool devicetype) { QString sNewCmd = sCmd; @@ -881,11 +894,13 @@ void CheckWindow::on_pushButton_start_clicked() { - BaseCommonApi::SaveLogInfo(1,QString("---------------------")); + BaseCommonApi::SaveLogInfo(1,QString("-----------------------------------")); connectDevice(); for(int i=0;i dataRes = caliDataList.value(sLabel); @@ -894,6 +909,7 @@ QString sRet=""; QString newCmd; double dStdValue,dError; + QString newdStdValue,newdError; //标准器输出 BaseCommonApi::SaveLogInfo(1,QString("标准器输出")); int idx= getIndexByHeader(sLabel,"检定项目"); @@ -928,14 +944,14 @@ } } } - Delay_MSec(2000); + newCmd = transCmd(instrcutLib->instruct_read,sLabel,dataRes[i]); if(newCmd!=""){ qDebug() << "query cmds:" << newCmd; sRet = deviceEngine.queryData(newCmd); idx= getIndexByHeader(sLabel,"单位"); dStdValue = transUnit(sRet,dataRes[i][idx]); - BaseCommonApi::SaveLogInfo(1,QString("测试值: %1").arg(dStdValue)); + } } } @@ -953,15 +969,20 @@ } //item.measure_indication_value = sRet; if(iEquipType==1){ + newdStdValue= TranDecimals(sLabel,dataRes[i],dStdValue); idx= getIndexByHeader(sLabel,"示值"); - dataRes[i][idx] = QString::number(dStdValue); - ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(QString::number(dStdValue))); //示值 + dataRes[i][idx] = newdStdValue; + ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(newdStdValue)); //示值 idx= getIndexByHeader(sLabel,"标准值"); double dTmp = dataRes[i][idx].toDouble(); dError = dStdValue-dTmp; + newdError=TranDecimals(sLabel,dataRes[i],dError); idx= getIndexByHeader(sLabel,"绝对误差"); - dataRes[i][idx] = QString::number(dError); - ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(QString::number(dError))); //示值 + dataRes[i][idx] = newdError; + ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(newdError)); //示值 + + BaseCommonApi::SaveLogInfo(1,QString("示值: %1 绝对误差 %2").arg(newdStdValue).arg(newdError)); + Delay_MSec(2000); } //ui->tableWidgetCheck->setItem(i,19,new QTableWidgetItem(sRet)); } diff --git a/softwareDirectory/AutoVerScheme/checkwindow.cpp b/softwareDirectory/AutoVerScheme/checkwindow.cpp index 82050e1..976715c 100644 --- a/softwareDirectory/AutoVerScheme/checkwindow.cpp +++ b/softwareDirectory/AutoVerScheme/checkwindow.cpp @@ -345,6 +345,7 @@ iEquipType = CliTable[0].belong_standard_equipment.toInt(); } //QStringList headlist; + pageButtons.clear(); headList.clear(); calibrationList.clear(); headTableList.clear(); @@ -423,6 +424,7 @@ //tackedWidget->setCurrentIndex(index); initCheckTable(index); }); + pageButtons.append(button); ++index; } ui->HeadListLayout->addStretch(); @@ -770,6 +772,10 @@ // } if(curHeadIdx==idx) return; + + + pageButtons[idx]->setChecked(true); + curHeadIdx = idx; QString sLabel = headTableList.keys()[curHeadIdx]; const auto &dataRes = caliDataList.value(sLabel); @@ -835,15 +841,22 @@ } return dTmp; } -//double CheckWindow::TranDecimals(QString sLabel,QStringList data,double TestValue) -//{ - /* int dex=getIndexByHeader(sLabel,"标准值"); - double StanValue=data[dex].toDouble(); - while (tmp != std::floor(tmp)) { - tmp *= 10; - ++decimalPlaces; - }*/ -//} +QString CheckWindow::TranDecimals(QString sLabel,QStringList data,double TestValue) +{ + int dex=getIndexByHeader(sLabel,"标准值"); + QString StanValue=data[dex]; + int decimalPlaces = 0; + int decimalPos = StanValue.indexOf('.'); + if (decimalPos == -1) { + decimalPlaces=1; + }else{ + decimalPlaces=StanValue.length() - decimalPos - 1; + } + + + QString formattedTestValue = QString::number(TestValue, 'f', decimalPlaces); + return formattedTestValue; +} QString CheckWindow::transCmd(QString sCmd,QString sLabel,QStringList data,bool devicetype) { QString sNewCmd = sCmd; @@ -881,11 +894,13 @@ void CheckWindow::on_pushButton_start_clicked() { - BaseCommonApi::SaveLogInfo(1,QString("---------------------")); + BaseCommonApi::SaveLogInfo(1,QString("-----------------------------------")); connectDevice(); for(int i=0;i dataRes = caliDataList.value(sLabel); @@ -894,6 +909,7 @@ QString sRet=""; QString newCmd; double dStdValue,dError; + QString newdStdValue,newdError; //标准器输出 BaseCommonApi::SaveLogInfo(1,QString("标准器输出")); int idx= getIndexByHeader(sLabel,"检定项目"); @@ -928,14 +944,14 @@ } } } - Delay_MSec(2000); + newCmd = transCmd(instrcutLib->instruct_read,sLabel,dataRes[i]); if(newCmd!=""){ qDebug() << "query cmds:" << newCmd; sRet = deviceEngine.queryData(newCmd); idx= getIndexByHeader(sLabel,"单位"); dStdValue = transUnit(sRet,dataRes[i][idx]); - BaseCommonApi::SaveLogInfo(1,QString("测试值: %1").arg(dStdValue)); + } } } @@ -953,15 +969,20 @@ } //item.measure_indication_value = sRet; if(iEquipType==1){ + newdStdValue= TranDecimals(sLabel,dataRes[i],dStdValue); idx= getIndexByHeader(sLabel,"示值"); - dataRes[i][idx] = QString::number(dStdValue); - ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(QString::number(dStdValue))); //示值 + dataRes[i][idx] = newdStdValue; + ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(newdStdValue)); //示值 idx= getIndexByHeader(sLabel,"标准值"); double dTmp = dataRes[i][idx].toDouble(); dError = dStdValue-dTmp; + newdError=TranDecimals(sLabel,dataRes[i],dError); idx= getIndexByHeader(sLabel,"绝对误差"); - dataRes[i][idx] = QString::number(dError); - ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(QString::number(dError))); //示值 + dataRes[i][idx] = newdError; + ui->tableWidgetCheck->setItem(i,idx,new QTableWidgetItem(newdError)); //示值 + + BaseCommonApi::SaveLogInfo(1,QString("示值: %1 绝对误差 %2").arg(newdStdValue).arg(newdError)); + Delay_MSec(2000); } //ui->tableWidgetCheck->setItem(i,19,new QTableWidgetItem(sRet)); } diff --git a/softwareDirectory/AutoVerScheme/checkwindow.h b/softwareDirectory/AutoVerScheme/checkwindow.h index 29faa51..35707bf 100644 --- a/softwareDirectory/AutoVerScheme/checkwindow.h +++ b/softwareDirectory/AutoVerScheme/checkwindow.h @@ -4,6 +4,7 @@ #include #include "basecommonapi.h" #include "visacommonengine.h" +#include "QPushButton" namespace Ui { class CheckWindow; @@ -82,6 +83,8 @@ QString transCmd(QString sCmd,QString sLabel,QStringList data,bool reverse=false); void SetStandardCombox(CatDeviceInfor info); void updateStandardTable(); + QString TranDecimals(QString sLabel,QStringList data,double TestValue); + private: Ui::CheckWindow *ui; QList programList; @@ -105,6 +108,7 @@ QMap cmdPlaceHolderList; QString standardId; int currConnectIdx; + QList pageButtons; }; #endif // CHECKWINDOW_H