Exemplo n.º 1
0
void DACCalibration::on_saveBut_clicked()
{
    QString l_strFileName;
            l_strFileName = "ICMCalibration.xml";

    QFile *file = new QFile(l_strFileName);
    if (!file->open(QIODevice::WriteOnly | QIODevice::Text)) {
            return;
    }
    QXmlStreamWriter objCalibration(file);

    objCalibration.setAutoFormatting(true);
    objCalibration.writeStartDocument();

    objCalibration.writeStartElement("Calibration");

    int ICM_Current_Index=ui.ICM->currentIndex();

     for (int l_nGainIndex = 0; l_nGainIndex<ui.comboBox->count(); l_nGainIndex++) {

         for (int l_nValueIndex = 0; l_nValueIndex<(ui.ICM->count()); l_nValueIndex++) {

                 if(ui.comboBox->itemText(l_nGainIndex)=="ICM-R")
                                on_comboBox_currentIndexChanged(0);
                 if(ui.comboBox->itemText(l_nGainIndex)=="ICM-L")
                                on_comboBox_currentIndexChanged(1);
                 if(ui.comboBox->itemText(l_nGainIndex)=="ICM-C")
                        on_comboBox_currentIndexChanged(2);

                    objCalibration.writeStartElement(ui.comboBox->itemText(l_nGainIndex));

                    objCalibration.writeAttribute("Value", ui.ICM->itemText(l_nValueIndex));
                    qDebug()<<"Value"<<ui.ICM->itemText(l_nValueIndex);

                    objCalibration.writeAttribute("Slope", QString::number(m_nSlope[l_nGainIndex][l_nValueIndex],'f',10));
                    qDebug()<<"Gain"<<QString::number(m_nSlope[l_nGainIndex][l_nValueIndex],'f',10);;

                    objCalibration.writeAttribute("Constant", QString::number(m_nConstant[l_nGainIndex][l_nValueIndex],'f',10));
                    qDebug()<<"Constant"<<QString::number(m_nConstant[l_nGainIndex][l_nValueIndex],'f',10);

                    objCalibration.writeStartElement("range");
                    for (int l_nElementIndex = 0; l_nElementIndex < m_nNoOfSamples; l_nElementIndex++) {

                              QString xValue="X"+QString::number(l_nElementIndex+1)+"Value";
                              objCalibration.writeAttribute(xValue, QString::number(XVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex],'f',15));
                              qDebug()<<"File-XValue:"<<QString::number((XVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex]),'f',15);

                              QString yValue="Y"+QString::number(l_nElementIndex+1)+"Value";
                              objCalibration.writeAttribute(yValue, QString::number(YVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex],'f',15));
                              qDebug()<<"File-YValue:"<<QString::number((YVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex]),'f',15);


                      }
                    objCalibration.writeEndElement();
                    objCalibration.writeEndElement();
                }

            }

    objCalibration.writeEndElement();
    objCalibration.writeEndDocument();

    file->close();

    ui.slope->clear();
    ui.constant->clear();
    m_objLE_NoOfPoints->clear();

    on_comboBox_currentIndexChanged(ICM_Current_Index);
}
Exemplo n.º 2
0
void DACCalibration::on_saveBut_clicked()
{
    QString l_strFileName;
    if(ui.comboBox_3->currentIndex()==0)
            l_strFileName = "./HAADC1.xml";
    else if(ui.comboBox_3->currentIndex()==1)
    		l_strFileName = "./HAADC2.xml";
    else if(ui.comboBox_3->currentIndex()==4)
    	l_strFileName = "VIADC1.xml";

    QFile *file = new QFile(l_strFileName);
    if (!file->open(QIODevice::WriteOnly | QIODevice::Text)) {
            return;
    }
    QXmlStreamWriter objCalibration(file);

    objCalibration.setAutoFormatting(true);
    objCalibration.writeStartDocument();

    objCalibration.writeStartElement("RXCalibration");
    if(ui.comboBox_3->currentIndex()==4){
//    	  for(int l_nGainIndex=0;l_nGainIndex<ui.comboBox_2->count();l_nGainIndex++)
    	     for (int l_nValueIndex = 0; l_nValueIndex< ui.comboBox->count(); l_nValueIndex++) {
    	                    objCalibration.writeStartElement("VoltageRange");

    	                    objCalibration.writeAttribute("Gain", ui.comboBox_2->itemText(0));
    	                    qDebug()<<"Gain"<<ui.comboBox_2->itemText(0);

    	                    objCalibration.writeAttribute("Value", ui.comboBox->itemText(l_nValueIndex));
    	                    qDebug()<<"Value"<<ui.comboBox->itemText(l_nValueIndex);

    	                    objCalibration.writeAttribute("Slope", QString::number(m_nRangeSlope[0][l_nValueIndex],'f',5));
    	                    qDebug()<<"Slope"<<QString::number(m_nRangeSlope[0][l_nValueIndex],'f',5);;

    	                    objCalibration.writeAttribute("Constant", QString::number(m_nRangeConstant[0][l_nValueIndex],'f',5));
    	                    qDebug()<<"Constant"<<QString::number(m_nRangeConstant[0][l_nValueIndex],'f',5);

    	                    for (int l_nElementIndex = 0; l_nElementIndex < m_nNoOfSamples; l_nElementIndex++) {
    	                            objCalibration.writeStartElement("Voltage");

    	                            objCalibration.writeAttribute("XVoltage", QString::number(XVoltage[0][l_nValueIndex][l_nElementIndex],'f',5));
    	                            qDebug()<<"File-XVoltage:"<<QString::number((XVoltage[0][l_nValueIndex][l_nElementIndex]),'f',5);

    	                            objCalibration.writeAttribute("YVoltage", QString::number(YVoltage[0][l_nValueIndex][l_nElementIndex],'f',5));
    	                            qDebug()<<"File-YVoltage:"<<QString::number((YVoltage[0][l_nValueIndex][l_nElementIndex]),'f',5);

    	                            objCalibration.writeEndElement();
    	                    }

    	                    objCalibration.writeEndElement();
    	            }

    }else{
  for(int l_nGainIndex=0;l_nGainIndex<ui.comboBox_2->count();l_nGainIndex++)
     for (int l_nValueIndex = 0; l_nValueIndex< ui.comboBox->count(); l_nValueIndex++) {
                    objCalibration.writeStartElement("VoltageRange");

                    objCalibration.writeAttribute("Gain", ui.comboBox_2->itemText(l_nGainIndex));
                    qDebug()<<"Gain"<<ui.comboBox_2->itemText(l_nGainIndex);

                    objCalibration.writeAttribute("Value", ui.comboBox->itemText(l_nValueIndex));
                    qDebug()<<"Value"<<ui.comboBox->itemText(l_nValueIndex);

                    objCalibration.writeAttribute("Slope", QString::number(m_nRangeSlope[l_nGainIndex][l_nValueIndex],'f',5));
                    qDebug()<<"Slope"<<QString::number(m_nRangeSlope[l_nGainIndex][l_nValueIndex],'f',5);;

                    objCalibration.writeAttribute("Constant", QString::number(m_nRangeConstant[l_nGainIndex][l_nValueIndex],'f',5));
                    qDebug()<<"Constant"<<QString::number(m_nRangeConstant[l_nGainIndex][l_nValueIndex],'f',5);

                    for (int l_nElementIndex = 0; l_nElementIndex < m_nNoOfSamples; l_nElementIndex++) {
                            objCalibration.writeStartElement("Voltage");

                            objCalibration.writeAttribute("XVoltage", QString::number(XVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex],'f',5));
                            qDebug()<<"File-XVoltage:"<<QString::number((XVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex]),'f',5);

                            objCalibration.writeAttribute("YVoltage", QString::number(YVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex],'f',5));
                            qDebug()<<"File-YVoltage:"<<QString::number((YVoltage[l_nGainIndex][l_nValueIndex][l_nElementIndex]),'f',5);

                            objCalibration.writeEndElement();
                    }

                    objCalibration.writeEndElement();
            }
    }
    objCalibration.writeEndElement();
    objCalibration.writeEndDocument();
    file->close();

    ui.slope->clear();
    ui.constant->clear();
    m_objLE_NoOfPoints->clear();
    timer->stop();
}