T_TXPCL_RFMD3140.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:31k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * T_TXPCL_RFMD3140.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * TX PCL calibration RFMD3140 source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include <assert.h>
- #include <math.h>
- #pragma hdrstop
- #ifndef _T_META_FACTORY_CALIBRATION_H_
- #include "T_META_factory_calibration.H"
- #endif
- #ifndef _APCCAL_COMMON_H_
- #include "apccal_common.h"
- #endif
- #ifndef _RF_APC_H_
- #include "rf_apc.h"
- #endif
- #ifndef _META_FACTORY_RF_CB_H_
- #include "meta_factory_rf_cb.h"
- #endif
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.h"
- #endif
- // equipment
- #ifndef _AGE1968A_H_
- #include "age1968a.h"
- #endif
- // callback
- #ifndef _META_FACTORY_NVRAM_CB_H_
- #include "meta_factory_nvram_cb.h"
- #endif
- // misc
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- //----------------------------------------------------------------------------
- extern CRFAPC* MF_rf_apc_ptr;
- extern RfNbtx_Req *MF_rf_tx_level_req;
- extern bool MF_rf_tx_level_cnf;
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- // equipment
- extern CMU_VAR cmu;
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ///////////////////////////// RFMD 3140 ///////////////////////
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- ///////////////////////////////////////////////////////////////////////////////
- ////////////// 3PCLEvaluateDac() //////////////
- ///////////////////////////////////////////////////////////////////////////////
- bool __fastcall T_META_factory_calibration::TXPCLCal_RFMD3140_3PCLEvalDac( void )
- {
- AnsiString as_wanted_p;
- AnsiString as_correction;
- AnsiString as_tx_pcl;
- AnsiString as_sub_tx_pcl;
- AnsiString as_sub_wanted_p;
- AnsiString as_sub_correction;
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== Evaluate PCL DAC value begin =================== "
- );
- // calculate m_dRload_high;
- //int i;
- double Rload_high_temp1, Rload_high_temp2;
- //real_support_band_num = cfg->getFreqBankNum( m_asFreqBank);
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " real_support_band_num = " + IntToStr(real_support_band_num) + "n"
- // );
- // calculate Vset DAC value
- FrequencyBand eFreqBand = FrequencyBand850;
- while (eFreqBand < FrequencyBandCount) // only for 900, 1800, 1900
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- E_BANDSEL band_index = FreqBand_To_BandIdx(eFreqBand);
- // for(i=0; i<real_support_band_num; i++)
- // {
- if(m_dV_set[band_index][V_SET_HIGH_INDEX] >= 0 && m_dV_set[band_index][V_SET_MID_INDEX]>=0)
- {
- Rload_high_temp1 = (8.0/3.0/sqrt(2)*(m_dV_set[band_index][V_SET_HIGH_INDEX]-m_dV_set[band_index][V_SET_MID_INDEX]));
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " m_dV_set[band_index][V_SET_HIGH_INDEX] = " + Double_To_AnsiString(m_dV_set[band_index][V_SET_HIGH_INDEX]) + "n" +
- " " +
- " m_dV_set[band_index][V_SET_MID_INDEX] = " + Double_To_AnsiString(m_dV_set[band_index][V_SET_MID_INDEX]) + "n" +
- " " +
- " Rload_high_temp1 = " + Double_To_AnsiString(Rload_high_temp1));
- }
- else if(m_dV_set[band_index][V_SET_HIGH_INDEX] < 0)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : m_dV_set[band_index][V_SET_HIGH_INDEX] < 0"
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : m_dV_set[band_index][V_SET_MID_INDEX] < 0"
- );
- return false;
- }
- if(m_dPCL_power[band_index][PCL_HIGH_INDEX]>=0 && m_dPCL_power[band_index][PCL_MID_INDEX]>=0)
- {
- Rload_high_temp2 = sqrt(m_dPCL_power[band_index][PCL_HIGH_INDEX])-sqrt(m_dPCL_power[band_index][PCL_MID_INDEX]);
- log->Add(
- DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " m_dPCL_power[band_index][PCL_HIGH_INDEX] = " + Double_To_AnsiString(m_dPCL_power[band_index][PCL_HIGH_INDEX]) + "n" +
- " " +
- " m_dPCL_power[band_index][PCL_MID_INDEX] = " + Double_To_AnsiString(m_dPCL_power[band_index][PCL_MID_INDEX]) + "n" +
- " " +
- " Rload_high_temp2 = " + Double_To_AnsiString(Rload_high_temp2)
- );
- }
- else if( m_dPCL_power[band_index][PCL_HIGH_INDEX] < 0)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : m_dPCL_power[band_index][PCL_HIGH_INDEX] < 0"
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : m_dPCL_power[band_index][PCL_MID_INDEX] < 0"
- );
- return false;
- }
- if(Rload_high_temp2 != 0.0)
- {
- m_dRload_high[band_index] = pow(Rload_high_temp1 / Rload_high_temp2, 2.0);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " m_dRload_high[band_index] = " + Double_To_AnsiString(m_dRload_high[band_index])
- );
- }
- if(m_dRload_high[band_index]*m_dPCL_power[band_index][PCL_MID_INDEX] >= 0)
- {
- m_dK1_high[band_index] = 8.0/3.0/sqrt(2)*m_dV_set[band_index][V_SET_MID_INDEX]-sqrt(m_dRload_high[band_index]*m_dPCL_power[band_index][PCL_MID_INDEX]);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " m_dK1_high[band_index] = " + Double_To_AnsiString(m_dK1_high[band_index]) + "n"
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : m_dRload_high[band_index]*m_dPCL_power[band_index][PCL_MID_INDEX] < 0" +
- ", band_index = "+IntToStr(band_index)+ "n" +
- "m_dRload_high[band_index] = " + Double_To_AnsiString(m_dRload_high[band_index]) + "n" +
- "PCL_MID_INDEX = " + IntToStr(PCL_MID_INDEX) + "n" +
- "m_dPCL_power[band_index][PCL_MID_INDEX] = " + Double_To_AnsiString(m_dPCL_power[band_index][PCL_MID_INDEX])
- );
- return false;
- }
- eFreqBand++;
- } // while
- //------------------------------------------------------------------
- // calculate Rload_low
- double Rload_low_temp1, Rload_low_temp2;
- eFreqBand = FrequencyBand850;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- E_BANDSEL band_index = FreqBand_To_BandIdx(eFreqBand);
- //for(i=0; i<real_support_band_num; i++)
- //{
- Rload_low_temp1 = (8.0/3.0/sqrt(2.0)*(m_dV_set[band_index][V_SET_MID_INDEX]-m_dV_set[band_index][V_SET_LOW_INDEX]));
- if(m_dPCL_power[band_index][PCL_MID_INDEX] >=0 && m_dPCL_power[band_index][PCL_LOW_INDEX]>=0)
- {
- Rload_low_temp2 = sqrt(m_dPCL_power[band_index][PCL_MID_INDEX])-sqrt(m_dPCL_power[band_index][PCL_LOW_INDEX]);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " i = " + IntToStr(band_index) + "," +
- " Rload_low_temp2 = " + Double_To_AnsiString(Rload_low_temp2)
- );
- }
- else if (m_dPCL_power[band_index][PCL_MID_INDEX] < 0)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : m_dPCL_power[band_index][PCL_MID_INDEX] < 0"
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : m_dPCL_power[band_index][PCL_LOW_INDEX] < 0"
- );
- return false;
- }
- if(Rload_low_temp2 != 0.0)
- {
- Rload_low[band_index] = pow(Rload_low_temp1 / Rload_low_temp2, 2.0);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " Rload_low[band_index] = " + Double_To_AnsiString(Rload_low[band_index])
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Rload_low_temp2 = 0");
- return false;
- }
- if(Rload_low[band_index]*m_dPCL_power[band_index][PCL_LOW_INDEX] >= 0.0)
- {
- K1_low[band_index] = 8.0/3.0/sqrt(2)*m_dV_set[band_index][V_SET_MID_INDEX]-sqrt(Rload_low[band_index]*m_dPCL_power[band_index][PCL_MID_INDEX]);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " K1_low[band_index] = " + Double_To_AnsiString(K1_low[band_index]) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Rload_low[band_index]*m_dPCL_power[band_index][PCL_MID_INDEX] < 0");
- }
- eFreqBand++;
- } // while
- //------------------------------------------------------------------
- // calculate Vset DAC value
- eFreqBand = FrequencyBand850;
- as_wanted_p = "";
- as_correction = "";
- while (eFreqBand < FrequencyBandCount)
- {
- as_tx_pcl = "";
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- i_TX_level_index_high = TX_LEVEL_HIGH_INDEX_GSM;
- i_TX_level_index_mid = TX_LEVEL_MID_INDEX_GSM;
- i_TX_level_index_low = TX_LEVEL_LOW_INDEX_GSM;
- as_wanted_p = m_as_gsm850_wanted_p;
- as_correction = m_as_gsm850_correction;
- as_tx_pcl = m_as_gsm850_tx_pcl;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- i_TX_level_index_high = TX_LEVEL_HIGH_INDEX_GSM;
- i_TX_level_index_mid = TX_LEVEL_MID_INDEX_GSM;
- i_TX_level_index_low = TX_LEVEL_LOW_INDEX_GSM;
- as_wanted_p = m_as_gsm900_wanted_p;
- as_correction = m_as_gsm900_correction;
- as_tx_pcl = m_as_gsm900_tx_pcl;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- i_TX_level_index_high = TX_LEVEL_HIGH_INDEX_DCS;
- i_TX_level_index_mid = TX_LEVEL_MID_INDEX_DCS;
- i_TX_level_index_low = TX_LEVEL_LOW_INDEX_DCS;
- as_wanted_p = m_as_dcs1800_wanted_p;
- as_correction = m_as_dcs1800_correction;
- as_tx_pcl = m_as_dcs1800_tx_pcl;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- i_TX_level_index_high = TX_LEVEL_HIGH_INDEX_PCS;
- i_TX_level_index_mid = TX_LEVEL_MID_INDEX_PCS;
- i_TX_level_index_low = TX_LEVEL_LOW_INDEX_PCS;
- as_wanted_p = m_as_pcs1900_wanted_p;
- as_correction = m_as_pcs1900_correction;
- as_tx_pcl = m_as_pcs1900_tx_pcl;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- E_BANDSEL band_index = FreqBand_To_BandIdx(eFreqBand);
- for ( int N=i_TX_level_index_high; N>=i_TX_level_index_mid; N--) // DCS,PCS:16~1 or GSM:15~1
- {
- if (! getAnsiStrSubItem( as_wanted_p, N, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(as_sub_wanted_p)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_correction, N, DEFAULT_SEP_CHAR, as_sub_correction))
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(as_sub_correction 1)."
- );
- return false;
- }
- // added by Andy Ueng for save result
- if (! getAnsiStrSubItem( as_tx_pcl, N, DEFAULT_SEP_CHAR, as_sub_tx_pcl))
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(as_sub_tx_pcl)."
- );
- return false;
- }
- //sprintf(tempbuf, "%3d", as_sub_tx_pcl.ToInt());
- //ResultHeaderBuf2 = ResultHeaderBuf2 + tempbuf + " ";
- // end of added
- m_dPCL_power_ideal[band_index][N-1] = pow(10.0, (atof(as_sub_wanted_p.c_str())+ atof(as_sub_correction.c_str()))/10.0)/1000.0;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = "+IntToStr(band_index)+","+
- " N-1 = " + IntToStr(N-1) + "," +
- " m_dPCL_power_ideal[band_index][N-1] = " + Double_To_AnsiString(m_dPCL_power_ideal[band_index][N-1])
- );
- if(m_dRload_high[band_index]*m_dPCL_power_ideal[band_index][N-1]>=0.0)
- {
- m_dV_set_ideal[band_index][N-1] = (3.0/8.0)*sqrt(2.0)*(sqrt(m_dRload_high[band_index]*m_dPCL_power_ideal[band_index][N-1]) + m_dK1_high[band_index]);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " m_dV_set_ideal[band_index][N-1] = " + Double_To_AnsiString(m_dV_set_ideal[band_index][N-1])
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: m_dRload_high[band_index]*m_dPCL_power_ideal[band_index][N-1] < 0"
- );
- return false;
- }
- // m_usPCLDacValue_ideal[band_index][N-1] = m_dV_set_ideal[band_index][N-1]*1024.0/2.8 * 25.0 / 15.0 - MF_rf_apc_ptr->Get_HighApcDcOffset(band_index);
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_sub_tx_pcl.ToInt(), m_iApcDcOffset ) )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Get APC DC offset " +
- " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
- " eFreqBand = " + IntToStr( eFreqBand ) +
- " pcl = " + as_sub_tx_pcl
- );
- return false;
- }
- m_usPCLDacValue_ideal[band_index][N-1] = m_dV_set_ideal[band_index][N-1]*1024.0/2.8 * 25.0 / 15.0 - m_iApcDcOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " m_usPCLDacValue_ideal[band_index][N-1] = " + IntToStr(m_usPCLDacValue_ideal[band_index][N-1]) + "n"
- );
- // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[N-1] = m_usPCLDacValue_ideal[band_index][N-1];
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, N-1, m_usPCLDacValue_ideal[band_index][N-1] );
-
- //PCL_dbm_ideal[band_index][N-1] = 10.0*log10(m_dPCL_power_ideal[band_index][N-1]*1000.0);
- // sprintf(tempbuf, "%2.1f", PCL_dbm_ideal[band_index][N-1]);
- // ResultBuf = ResultBuf + tempbuf + ", ";
- //ResultBuf = ResultBuf + IntToStr(MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[N-1]) + ", ";
- } // for
- for ( int N=i_TX_level_index_mid-1; N>=i_TX_level_index_low; N--) // DCS,PCS:16~1 or GSM:15~1
- {
- if (! getAnsiStrSubItem( as_wanted_p, N, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p 4)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_correction, N, DEFAULT_SEP_CHAR, as_sub_correction))
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(as_sub_correction 2)."
- );
- return false;
- }
- // added by Andy Ueng for save result
- if (! getAnsiStrSubItem( as_tx_pcl, N, DEFAULT_SEP_CHAR, as_sub_tx_pcl))
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(as_sub_tx_pcl)."
- );
- return false;
- }
- // sprintf(tempbuf, "%3d", as_sub_tx_pcl.ToInt());
- // ResultHeaderBuf2 = ResultHeaderBuf2 + tempbuf + " ";
- // end of added
- m_dPCL_power_ideal[band_index][N-1] = pow(10.0, (atof(as_sub_wanted_p.c_str())+atof(as_sub_correction.c_str()))/10.0)/1000.0;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N-1 = " + IntToStr(N-1) + "," +
- " m_dPCL_power_ideal[band_index][N-1] = " + Double_To_AnsiString(m_dPCL_power_ideal[band_index][N-1])
- );
- if(Rload_low[band_index]*m_dPCL_power_ideal[band_index][N-1] >=0.0)
- {
- m_dV_set_ideal[band_index][N-1] = (3.0/8.0)*sqrt(2)*(sqrt(Rload_low[band_index]*m_dPCL_power_ideal[band_index][N-1]) + K1_low[band_index]);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " m_dV_set_ideal[band_index][N-1] = " + Double_To_AnsiString(m_dV_set_ideal[band_index][N-1])
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Rload_low[band_index]*m_dPCL_power_ideal[band_index][N-1] < 0.0"
- );
- return false;
- }
- // m_usPCLDacValue_ideal[band_index][N-1] = m_dV_set_ideal[band_index][N-1]*1024.0/2.8 * 25.0 / 15.0 - MF_rf_apc_ptr->Get_HighApcDcOffset(band_index);
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_sub_tx_pcl.ToInt(), m_iApcDcOffset ) )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_EVALDAC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: PCL to dBm " +
- " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
- " eFreqBand = " + IntToStr( eFreqBand ) +
- " pcl = " + as_sub_tx_pcl
- );
- return false;
- }
- m_usPCLDacValue_ideal[band_index][N-1] = m_dV_set_ideal[band_index][N-1]*1024.0/2.8 * 25.0 / 15.0 - m_iApcDcOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " " +
- " m_usPCLDacValue_ideal[band_index][N-1] = " + Double_To_AnsiString(m_usPCLDacValue_ideal[band_index][N-1]) + "n"
- );
- // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[N-1] = m_usPCLDacValue_ideal[band_index][N-1];
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, N-1, m_usPCLDacValue_ideal[band_index][N-1] );
- // PCL_dbm_ideal[band_index][N-1] = 10.0*log10(m_dPCL_power_ideal[band_index][N-1]*1000.0);
- // sprintf(tempbuf, "%2.1f", PCL_dbm_ideal[band_index][N-1]);
- // ResultBuf = ResultBuf + tempbuf + ", ";
- //ResultBuf = ResultBuf + IntToStr(MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[N-1]) + ", ";
- } // for
-
- MF_rf_apc_ptr->ConfirmCallback = ccb_write_apc_to_nvram;
- MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, m_pCal->b_TADOSupport );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Write to NVRAM band_index = " + IntToStr(band_index)
- );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 15= " + IntToStr((int)frmFatcory->TimerCal->Enabled) + "n"
- // );
- RestartTimerCal( WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL );
- // end of added
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write APC to NVRAM "
- );
- }
- return false;
- }
- WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
- eFreqBand++;
- } // while
- frmFatcory->DisableAllCalTimer();
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ===================== Evaluate other PCL DAC value end =========== n "
- );
- // ========================= Evaluate other PCL DAC value end ==================
- return true;
- }