T_TXPCL_Skyworks77316.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:45k
源码类别:

MTK

开发平台:

C++ Builder

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *   T_TXPCL_Skyworks74046.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Skyworks 74046 TX PCL source
  48.  *
  49.  * Author:
  50.  * -------
  51.  *  Andy Ueng (mtk00490)
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * $Revision$
  58.  * $Modtime$
  59.  * $Log$
  60.  *
  61.  *------------------------------------------------------------------------------
  62.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  63.  *============================================================================
  64. ****************************************************************************/
  65. #include <assert.h>
  66. #include <math.h>
  67. #pragma hdrstop
  68. #ifndef _T_META_FACTORY_CALIBRATION_H_
  69. #include "T_META_factory_calibration.H"
  70. #endif
  71. #ifndef _CAL_COMMON_H_
  72. #include "cal_common.h"
  73. #endif
  74. #ifndef _APCCAL_COMMON_H_
  75. #include "apccal_common.h"
  76. #endif
  77. #ifndef  _RF_APC_H_
  78. #include "rf_apc.h"
  79. #endif
  80. // callback
  81. #ifndef _META_FACTORY_RF_CB_H_
  82. #include "meta_factory_rf_cb.h"
  83. #endif
  84. #ifndef _META_FACTORY_NVRAM_CB_H_
  85. #include "meta_factory_nvram_cb.h"
  86. #endif
  87. // form
  88. #ifndef _META_FACTORY_H_
  89. #include "META_Factory.h"
  90. #endif
  91. // equipment
  92. #ifndef _AGECOMMON_H_
  93. #include "AgeCommon.h"
  94. #endif
  95. #ifndef  _AGE_MISC_H_
  96. #include "age_misc.h"
  97. #endif
  98. // misc
  99. #ifndef  _FT_UTILS_H_
  100. #include "ft_utils.h"
  101. #endif
  102. #ifndef  _BAND_UTILS_H_
  103. #include "band_utils.h"
  104. #endif
  105. #ifndef  _TIME_UTILS_H_
  106. #include "time_utils.h"
  107. #endif
  108. //----------------------------------------------------------------------------
  109. extern CRFAPC*  MF_rf_apc_ptr;
  110. extern CRFAPC8PSK*  MF_rf_apc_8psk_ptr;
  111. extern RfNbtx_Req *MF_rf_tx_level_req;
  112. extern bool MF_rf_tx_level_cnf;
  113. extern bool  is_suspend_cal; // in T_META_factory_calibration.cpp
  114. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115. /////////////////////////////     Skyworks 77316      ///////////////////////
  116. //---------------------------------------------------------------------------
  117. bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_Skyworks77316_cal( void )
  118. {
  119. #if 0
  120.     log->Add( "n" + DateToStr(Date()) +  " " + CurrentTimeStr() +
  121.              " ========== EPSK TX power control level calibration begin ========== n "
  122.            );
  123.     if( ! rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH ) )
  124.     {
  125.         CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
  126.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  127.                               " FAIL : "+
  128.                               m_pRct->as_RCT + " < Operation mode = EGPRS BCH+PDTCH"
  129.                             );
  130.             return false;
  131.     }
  132.     if( ! rct_ctrl.RCT_Config_EPSK_CodingScheme( m_pRct, MCS5 ) )
  133.     {
  134.         CalErrorHandler( WM_MF_AGE8960_SET_CODING_SCHEME_FAIL );
  135.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  136.                               " FAIL : "+
  137.                               m_pRct->as_RCT + " < Coding scheme = MCS5"
  138.                             );
  139.         return false;
  140.     }
  141.     eFreqBand = FrequencyBand850;
  142.     i_N_TX = -99; // TX frames
  143.     //---------------------------------------------------------------------------
  144.     while (eFreqBand < FrequencyBandCount) 
  145.     {
  146.         switch ( eFreqBand )
  147.         {
  148.             case FrequencyBand850:
  149.             {
  150.                 if (! IsFreqBankSupported(  m_asFreqBank, eFreqBand))
  151.                 {
  152.                     eFreqBand++;
  153.                     continue;
  154.                 }
  155.                 FIRST_PCL = GSM850_FIRST_PCL;
  156.                 vi_Band = age1960_GSM850_BAND;
  157.                 band_index = BANDSEL_GSM850;
  158.                 s_ARFCN = m_sARFCN_C0_GSM850;
  159.                 i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_1_CAL_COUNT;
  160.                 as_epsk_tx_cal_pcl = as_gsm850_epsk_tx_2cal_pcl;
  161.                 as_epsk_tx_pcl = as_gsm850_epsk_tx_pcl;
  162.                 as_epsk_max_p = as_gsm850_epsk_max_p;
  163.                 as_epsk_wanted_p = as_gsm850_epsk_wanted_p;
  164.                 as_epsk_min_p = as_gsm850_epsk_min_p;
  165.                 as_epsk_c = as_gsm850_epsk_c;
  166.             }
  167.             break;
  168.             case FrequencyBand900:
  169.             {
  170.                 if (! IsFreqBankSupported(  m_asFreqBank, eFreqBand))
  171.                 {
  172.                     eFreqBand++;
  173.                     continue;
  174.                 }
  175.                 FIRST_PCL = GSM900_FIRST_PCL;
  176.                 vi_Band = age1960_EGSM_BAND;
  177.                 band_index = BANDSEL_GSM900;
  178.                 s_ARFCN = m_sARFCN_C0_GSM;
  179.                 i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_2_CAL_COUNT;
  180.                 as_epsk_tx_2cal_pcl = as_gsm900_epsk_tx_2cal_pcl;
  181.                 as_epsk_tx_pcl = as_gsm900_epsk_tx_pcl;
  182.                 as_epsk_max_p = as_gsm900_epsk_max_p;
  183.                 as_epsk_wanted_p = as_gsm900_epsk_wanted_p;
  184.                 as_epsk_min_p = as_gsm900_epsk_min_p;
  185.                 as_epsk_c = as_gsm900_epsk_c;
  186.             }
  187.             break;
  188.             case FrequencyBand1800:
  189.             {
  190.                 if (! IsFreqBankSupported(  m_asFreqBank, eFreqBand))
  191.                 {
  192.                     eFreqBand++;
  193.                     continue;
  194.                 }
  195.                 FIRST_PCL = DCS1800_FIRST_PCL;
  196.                 vi_Band = age1960_DCS1800_BAND;
  197.                 band_index = BANDSEL_DCS1800;
  198.                 s_ARFCN = m_sARFCN_C0_DCS;
  199.                 i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_2_CAL_COUNT;
  200.                 as_epsk_tx_2cal_pcl = as_dcs1800_epsk_tx_2cal_pcl;
  201.                 as_epsk_tx_pcl = as_dcs1800_epsk_tx_pcl;
  202.                 as_epsk_max_p = as_dcs1800_epsk_max_p;
  203.                 as_epsk_wanted_p = as_dcs1800_epsk_wanted_p;
  204.                 as_epsk_min_p = as_dcs1800_epsk_min_p;
  205.                 as_epsk_c = as_dcs1800_epsk_c;
  206.             }
  207.             break;
  208.             case FrequencyBand1900:
  209.             {
  210.                 if (! IsFreqBankSupported(  m_asFreqBank, eFreqBand))
  211.                 {
  212.                     eFreqBand++;
  213.                     continue;
  214.                 }
  215.                 FIRST_PCL = PCS1900_FIRST_PCL;
  216.                 vi_Band = age1960_PCS1900_BAND;
  217.                 band_index = BANDSEL_PCS1900;
  218.                 s_ARFCN = m_sARFCN_C0_PCS;
  219.                 i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_2_CAL_COUNT;
  220.                 as_epsk_tx_2cal_pcl = as_pcs1900_epsk_tx_2cal_pcl;
  221.                 as_epsk_tx_pcl = as_pcs1900_epsk_tx_pcl;
  222.                 as_epsk_max_p = as_pcs1900_epsk_max_p;
  223.                 as_epsk_wanted_p = as_pcs1900_epsk_wanted_p;
  224.                 as_epsk_min_p = as_pcs1900_epsk_min_p;
  225.                 as_epsk_c = as_pcs1900_epsk_c;
  226.             }
  227.             break;
  228.             default:
  229.                 assert(false);
  230.             break;
  231.         } // switch
  232.         if ( this->Terminated )
  233.         {
  234.             this->OnTerminate = neByUser;
  235.             return false;
  236.         }
  237.         log->Add( "n" + DateToStr(Date()) +  " " + CurrentTimeStr() +
  238.                          " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  239.                        );
  240.         if(IsFreqBankSupported(  m_asFreqBank, eFreqBand))
  241.         {
  242.             if( FrequencyBand1900 == eFreqBand )
  243.             {
  244.                 if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) !=  META_SUCCESS)
  245.                 {
  246.                     CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
  247.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  248.                                   " FAIL: target < set Band1900 flag = 1"
  249.                                 );
  250.                     return false;
  251.                 }
  252.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  253.                               " target < set Band1900 flag = 1"
  254.                             );
  255.             }
  256.             else
  257.             {
  258.                 if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) !=  META_SUCCESS)
  259.                 {
  260.                     CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
  261.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  262.                                   " FAIL: target < set Band1900 flag = 0"
  263.                                 );
  264.                     return false;
  265.                 }
  266.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  267.                               " target < set Band1900 flag = 0"
  268.                             );
  269.             }
  270.             is_suspend_cal = true;
  271.             this->Suspend();
  272.             is_suspend_cal = false;
  273.         }
  274.         if( ! rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
  275.         {
  276.             CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
  277.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  278.                               " FAIL : "+
  279.                               m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
  280.                             );
  281.             return false;
  282.         }
  283.         Sleep( 100 );  // wait Agilent 8960 cell band setup ready!
  284.                    // if Agilent 8960 not read, target will get error power!
  285.         if ( this->Terminated )
  286.         {
  287.             this->OnTerminate = neByUser;
  288.             return false;
  289.         }
  290.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  291.                           m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
  292.                         );
  293.         short bch_arfcn = ::Get_SeperateChannel( vi_Band, s_ARFCN );
  294.         if( ! rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
  295.         {
  296.             CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
  297.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  298.                               " FAIL: "+
  299.                               m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
  300.                     );
  301.             return false;
  302.         }
  303.         if( ! rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_ARFCN ) )
  304.         {
  305.             CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_ARFCN_FAIL );
  306.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  307.                               " FAIL: "+
  308.                               m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
  309.                             );
  310.             return false;
  311.         }
  312.         if( this->Terminated )
  313.         {
  314.             this->OnTerminate = neByUser;
  315.             return false;
  316.         }
  317.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +  " " +
  318.                           m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
  319.                         );
  320.         if( ! rct_ctrl.RCT_ConfigTSC( m_pRct, m_cTSC ) )
  321.         {
  322.             CalErrorHandler( WM_MF_AGE8960_SET_TSC_FAIL );
  323.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  324.                               "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
  325.                             );
  326.             return false;
  327.         }
  328.         if ( this->Terminated )
  329.         {
  330.             this->OnTerminate = neByUser;
  331.             return false;
  332.         }
  333.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  334.                           m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
  335.                         );
  336.         if( ! rct_ctrl.RCT_EPSK_TXPowerContOff( m_pRct ) )
  337.         {
  338.             CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
  339.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  340.                               " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
  341.                             );
  342.             return false;
  343.         }
  344.         if ( this->Terminated )
  345.         {
  346.             this->OnTerminate = neByUser;
  347.             return false;
  348.         }
  349.         //log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  350.         //                  " TimerCal->Enabled 8= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
  351.         //                );
  352.         RestartTimerCal( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
  353.         if( ! rct_ctrl.RCT_confTXPower_EPSK( m_pRct ) )
  354.         {
  355.             CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
  356.             log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  357.                                   " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
  358.                                 );
  359.             return false;
  360.         }
  361. #endif
  362.     return true;
  363. }
  364. //----------------------------------------------------------------------------
  365. bool __fastcall T_META_factory_calibration::TXPCLCal_EvalDac_Skyworks77316_GMSK( void )
  366. {
  367.     AnsiString   as_tx_pcl;
  368.     AnsiString   as_tx_2cal_pcl;
  369.     AnsiString   as_wanted_p;
  370.     AnsiString   as_correction;
  371.     AnsiString   as_sub_tx_pcl;
  372.     AnsiString   as_sub_tx_2cal_pcl;
  373.     AnsiString   as_sub_wanted_p;
  374.     AnsiString   as_sub_correction;
  375.    // AnsiString   as_epsk_tx_pcl;
  376.    // AnsiString   as_epsk_tx_2cal_pcl;
  377.    // AnsiString   as_epsk_wanted_p;
  378.    // AnsiString   as_epsk_correction;
  379.    // AnsiString   as_epsk_sub_tx_pcl;
  380.    // AnsiString   as_epsk_sub_tx_2cal_pcl;
  381.    // AnsiString   as_epsk_sub_wanted_p;
  382.    // AnsiString   as_epsk_sub_correction;
  383.     unsigned short i_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
  384.    // unsigned short i_EPSK_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
  385.     double  slope[MAX_SUPPORT_BAND_NUM]; // DAC/slope
  386.    // double  slope_epsk[MAX_SUPPORT_BAND_NUM]; // DAC/slope
  387.     unsigned short offset[MAX_SUPPORT_BAND_NUM];
  388.    // unsigned short offset_epsk[MAX_SUPPORT_BAND_NUM];
  389.     log->Add("n" +DateToStr(Date()) +  " " + CurrentTimeStr() +
  390.                   " =================== Evaluate GMSK PCL DAC value begin =================== "
  391.                 );
  392.     E_BANDSEL band_index;
  393.     FrequencyBand eFreqBand = FrequencyBand850;
  394.     while (eFreqBand < FrequencyBandCount)
  395.     {
  396.         switch (eFreqBand)
  397.         {
  398.             case FrequencyBand850:
  399.             {
  400.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  401.                 {
  402.                     eFreqBand++;
  403.                     continue;
  404.                 }
  405.                 band_index     = BANDSEL_GSM850;
  406.                 as_tx_2cal_pcl = m_as_gsm850_tx_2cal_pcl;
  407.                 as_tx_pcl      = m_as_gsm850_tx_pcl;
  408.                 as_wanted_p    = m_as_gsm850_wanted_p;
  409.                 as_correction  = m_as_gsm850_correction;
  410.                 //as_epsk_tx_2cal_pcl = m_as_gsm850_epsk_tx_2cal_pcl;
  411.                 //as_epsk_tx_pcl      = m_as_gsm850_epsk_tx_pcl;
  412.                 //as_epsk_wanted_p    = m_as_gsm850_epsk_wanted_p;
  413.                 //as_epsk_correction  = m_as_gsm850_epsk_correction;
  414.             }
  415.             break;
  416.             case FrequencyBand900:
  417.             {
  418.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  419.                 {
  420.                     eFreqBand++;
  421.                     continue;
  422.                 }
  423.                 band_index     = BANDSEL_GSM900;
  424.                 as_tx_2cal_pcl = m_as_gsm900_tx_2cal_pcl;
  425.                 as_tx_pcl      = m_as_gsm900_tx_pcl;
  426.                 as_wanted_p    = m_as_gsm900_wanted_p;
  427.                 as_correction  = m_as_gsm900_correction;
  428.                 //as_epsk_tx_2cal_pcl = m_as_gsm900_epsk_tx_2cal_pcl;
  429.                 //as_epsk_tx_pcl      = m_as_gsm900_epsk_tx_pcl;
  430.                 //as_epsk_wanted_p    = m_as_gsm900_epsk_wanted_p;
  431.                 //as_epsk_correction  = m_as_gsm900_epsk_correction;
  432.             }
  433.             break;
  434.             case FrequencyBand1800:
  435.             {
  436.                 if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
  437.                 {
  438.                     eFreqBand++;
  439.                     continue;
  440.                 }
  441.                 band_index     = BANDSEL_DCS1800;
  442.                 as_tx_2cal_pcl = m_as_dcs1800_tx_2cal_pcl;
  443.                 as_tx_pcl      = m_as_dcs1800_tx_pcl;
  444.                 as_wanted_p    = m_as_dcs1800_wanted_p;
  445.                 as_correction  = m_as_dcs1800_correction;
  446.             }
  447.             break;
  448.             case FrequencyBand1900:
  449.             {
  450.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  451.                 {
  452.                     eFreqBand++;
  453.                     continue;
  454.                 }
  455.                 band_index     = BANDSEL_PCS1900;
  456.                 as_tx_2cal_pcl = m_as_pcs1900_tx_2cal_pcl;
  457.                 as_tx_pcl      = m_as_pcs1900_tx_pcl;
  458.                 as_wanted_p    = m_as_pcs1900_wanted_p;
  459.                 as_correction  = m_as_pcs1900_correction;
  460.             }
  461.             break;
  462.             default:
  463.             {
  464.                 assert(false);
  465.             }
  466.             break;
  467.         } // switch
  468.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  469.                               BandIdx_To_String(band_index)
  470.                         );
  471.         for(int i=0; i<CALIBRATIE_NUM_2PCL; i++)
  472.         {
  473.             if (! getAnsiStrSubItem( as_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_2cal_pcl) )
  474.             {
  475.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  476.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  477.                               " FAIL: Read config file fail(sub_tx_cal_pcl)."
  478.                         );
  479.                 return false;
  480.             }
  481.             i_PCL_Cal[band_index][i] = as_sub_tx_2cal_pcl.ToInt();
  482.             // EPSK
  483.            // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  484.            // {
  485.           //      if (! getAnsiStrSubItem( as_epsk_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_2cal_pcl) )
  486.            //     {
  487.            //         CalErrorHandler(WM_MF_CFG_READ_FAIL);
  488.            //         log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  489.            //                   " FAIL: Read config file fail(epsk_sub_tx_cal_pcl)."
  490.            //             );
  491.            //         return false;
  492.             //    }
  493.             //    i_EPSK_PCL_Cal[band_index][i] = as_epsk_sub_tx_2cal_pcl.ToInt();
  494.            // }
  495.         }
  496.         offset[band_index] = m_usPCLDacValue[band_index][0];
  497.         slope[band_index] = (m_usPCLDacValue[band_index][1]-m_usPCLDacValue[band_index][0])/(m_dPCL_dBm[band_index][1]-m_dPCL_dBm[band_index][0]);
  498.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  499.                               " slope = " + Double_To_AnsiString(slope[band_index]) + " (DAC/dBm)" +
  500.                               ", offset = " + IntToStr(offset[band_index])
  501.                             );
  502.        // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  503.        // {
  504.        //     offset_epsk[band_index] = m_usPCLDacValue_EPSK[band_index][0];
  505.        //     slope_epsk[band_index] = (m_usPCLDacValue_EPSK[band_index][1]-m_usPCLDacValue_EPSK[band_index][0])/(m_dPCL_dBm_EPSK[band_index][1]-m_dPCL_dBm_EPSK[band_index][0]);
  506.        //     log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  507.        //                       " slope_epsk = " + Double_To_AnsiString(slope_epsk[band_index]) + " (DAC/dBm)" +
  508.        //                       ", offset_epsk = " + IntToStr(offset_epsk[band_index])
  509.        //                     );
  510.        // }
  511.         for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
  512.         {
  513.             if( i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
  514.                 (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
  515.               )
  516.             {
  517.                 break;
  518.             }
  519.             if (! getAnsiStrSubItem( as_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
  520.             {
  521.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  522.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  523.                               " FAIL: Read config file fail(sub_tx_pcl)."
  524.                         );
  525.                 return false;
  526.             }
  527.             if (! getAnsiStrSubItem( as_wanted_p, i+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
  528.             {
  529.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  530.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  531.                               " FAIL: Read config file fail(sub_wanted_p)."
  532.                             );
  533.                 return false;
  534.             }
  535.             if (! getAnsiStrSubItem( as_correction, i+1, DEFAULT_SEP_CHAR, as_sub_correction) )
  536.             {
  537.                 CalErrorHandler( WM_MF_CFG_READ_FAIL );
  538.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  539.                               " FAIL: Read config file fail(as_sub_correction)."
  540.                             );
  541.                 return false;
  542.             }
  543.             if( as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_LOW_INDEX] &&
  544.                 as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_MID_INDEX]
  545.               )
  546.             {
  547.                 m_usPCLDacValue_ideal[band_index][i] = (atof(as_sub_wanted_p.c_str()) + atof(as_sub_correction.c_str()) - m_dPCL_dBm[band_index][0]) * slope[band_index] + offset[band_index];
  548.                 // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[i] = m_usPCLDacValue_ideal[band_index][i];
  549.                 MF_rf_apc_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal[band_index][i] );
  550.                 log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  551.                           // "                         " +
  552.                            " m_usPCLDacValue_ideal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  553.                              Double_To_AnsiString(m_usPCLDacValue_ideal[band_index][i]) + "n"
  554.                         );
  555.             }
  556.         }
  557.         // Evaluate DAC except highest and lowest PCL
  558.        // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  559.        // {
  560.        //     for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
  561.        //     {
  562.        //         if (i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
  563.        //             (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
  564.        //            )
  565.        //         {
  566.        //             break;
  567.        //         }
  568.        //
  569.                 // EPSK
  570.                // if (! getAnsiStrSubItem(as_epsk_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_pcl))
  571.                // {
  572.                //     CalErrorHandler(WM_MF_CFG_READ_FAIL);
  573.          //           log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  574.          //                     " FAIL: Read config file fail(epsk_sub_tx_pcl)."
  575.          //               );
  576.          //           return false;
  577.           //      }
  578.           //
  579.           //      // EPSK
  580.           //      if (! getAnsiStrSubItem( as_epsk_wanted_p, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_wanted_p) )
  581.           //      {
  582.           //          CalErrorHandler(WM_MF_CFG_READ_FAIL);
  583.           //          log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  584.           //                    " FAIL: Read config file fail(epsk_sub_wanted_p)."
  585.           //                  );
  586.           //          return false;
  587.           //      }
  588.           //
  589.           //      // EPSK
  590.           //      if (! getAnsiStrSubItem( as_epsk_correction, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_correction) )
  591.           //      {
  592.           //          CalErrorHandler(WM_MF_CFG_READ_FAIL);
  593.           //          log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  594.           //                    " FAIL: Read config file fail(as_epsk_sub_correction)."
  595.           //                  );
  596.           //          return false;
  597.           //      }
  598.           //      // EPSK
  599.           //      if (as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_LOW_INDEX] &&
  600.           //          as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_MID_INDEX]
  601.           //         )
  602.           //      {
  603.           //          m_usPCLDacValue_ideal_EPSK[band_index][i] = (atof(as_epsk_sub_wanted_p.c_str()) + atof(as_epsk_sub_correction.c_str()) - m_dPCL_dBm_EPSK[band_index][0]) * slope_epsk[band_index] + offset_epsk[band_index];
  604.           //          MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal_EPSK[band_index][i] );
  605.           //          log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  606.           //                // "                         " +
  607.           //                 " m_usPCLDacValue_ideal_EPSK[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  608.           //                   Double_To_AnsiString(m_usPCLDacValue_ideal_EPSK[band_index][i]) + "n"
  609.           //              );
  610.           //      }
  611.           //  }
  612.         //}
  613.         MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
  614.         MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, m_pCal->b_TADOSupport );
  615.         RestartTimerCal( WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL );
  616.         CHECK_TERMINATE_BY_USER
  617.         SUSPEND_CAL_THREAD
  618.         E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
  619.         if (state != METAAPP_SUCCESS)
  620.         {
  621.             if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
  622.             {
  623.                 CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
  624.                 log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  625.                              " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
  626.                              );
  627.             }
  628.             else
  629.             {
  630.                 CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  631.                 log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  632.                                       " FAIL: Target < write APC to NVRAM "
  633.                                     );
  634.             }
  635.             return false;
  636.         }
  637.         WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
  638.         // EPSK
  639. //        if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  640. //        {
  641. //            MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
  642. //            MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, false);
  643. //
  644. //            log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  645. //                      " Write to NVRAM band_index = " + IntToStr(band_index)
  646. //                    );
  647. //
  648. //
  649. //            RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  650. //            CHECK_TERMINATE_BY_USER
  651. //            SUSPEND_CAL_THREAD
  652. //
  653. //            state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
  654. //            if (state != METAAPP_SUCCESS)
  655. //            {
  656. //                if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
  657. //                {
  658. //                    CalErrorHandler(WM_MF_NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID_VERNO_FAIL);
  659. //                    log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  660. //                                              " FAIL : NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
  661. //                                              );
  662. //                }
  663. //                else
  664. //                {
  665. //                    CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  666. //                    log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  667. //                                      " FAIL: Target< write EPSK APC to NVRAM "
  668. //                                    );
  669. //                }
  670. //                return false;
  671. //            }
  672. //
  673. //            WriteEpskAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
  674. //        }
  675.         eFreqBand++;
  676.     } // while
  677.     frmFatcory->DisableAllCalTimer();
  678.     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  679.                  " ===================== Evaluate other PCL DAC value end =========== n "
  680.                 );
  681.     return true;
  682. }
  683. //----------------------------------------------------------------------------
  684. bool __fastcall T_META_factory_calibration::TXPCLCal_EvalDac_Skyworks77316_EPSK(void)
  685. {
  686.     //AnsiString   as_tx_pcl;
  687.     //AnsiString   as_tx_2cal_pcl;
  688.     //AnsiString   as_wanted_p;
  689.     //AnsiString   as_correction;
  690.     //AnsiString   as_sub_tx_pcl;
  691.     //AnsiString   as_sub_tx_2cal_pcl;
  692.     //AnsiString   as_sub_wanted_p;
  693.     //AnsiString   as_sub_correction;
  694.     AnsiString   as_epsk_tx_pcl;
  695.     AnsiString   as_epsk_tx_2cal_pcl;
  696.     AnsiString   as_epsk_wanted_p;
  697.     AnsiString   as_epsk_correction;
  698.     AnsiString   as_epsk_sub_tx_pcl;
  699.     AnsiString   as_epsk_sub_tx_2cal_pcl;
  700.     AnsiString   as_epsk_sub_wanted_p;
  701.     AnsiString   as_epsk_sub_correction;
  702.     //unsigned short i_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
  703.     unsigned short i_EPSK_PCL_Cal[MAX_SUPPORT_BAND_NUM][CALIBRATIE_NUM_2PCL];
  704.    // double  slope[MAX_SUPPORT_BAND_NUM]; // DAC/slope
  705.     double  slope_epsk[MAX_SUPPORT_BAND_NUM]; // DAC/slope
  706.     //unsigned short offset[MAX_SUPPORT_BAND_NUM];
  707.     unsigned short offset_epsk[MAX_SUPPORT_BAND_NUM];
  708.     log->Add( "n" +DateToStr(Date()) +  " " + CurrentTimeStr() +
  709.                   " =================== Evaluate EPSK PCL DAC value begin =================== "
  710.                 );
  711.     short s_ARFCN;
  712.     E_BANDSEL band_index;
  713.     FrequencyBand eFreqBand = FrequencyBand850;
  714.     while (eFreqBand < FrequencyBandCount)
  715.     {
  716.         switch (eFreqBand)
  717.         {
  718.             case FrequencyBand850:
  719.             {
  720.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  721.                 {
  722.                     eFreqBand++;
  723.                     continue;
  724.                 }
  725.                 band_index     = BANDSEL_GSM850;
  726.                 as_epsk_tx_2cal_pcl = m_as_gsm850_epsk_tx_2cal_pcl;
  727.                 as_epsk_tx_pcl      = m_as_gsm850_epsk_tx_pcl;
  728.                 as_epsk_wanted_p    = m_as_gsm850_epsk_wanted_p;
  729.                 as_epsk_correction  = m_as_gsm850_epsk_correction;
  730.             }
  731.             break;
  732.             case FrequencyBand900:
  733.             {
  734.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  735.                 {
  736.                     eFreqBand++;
  737.                     continue;
  738.                 }
  739.                 band_index     = BANDSEL_GSM900;
  740.                 as_epsk_tx_2cal_pcl = m_as_gsm900_epsk_tx_2cal_pcl;
  741.                 as_epsk_tx_pcl      = m_as_gsm900_epsk_tx_pcl;
  742.                 as_epsk_wanted_p    = m_as_gsm900_epsk_wanted_p;
  743.                 as_epsk_correction  = m_as_gsm900_epsk_correction;
  744.             }
  745.             break;
  746.             case FrequencyBand1800:
  747.             {
  748.                 if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
  749.                 {
  750.                     eFreqBand++;
  751.                     continue;
  752.                 }
  753.                 band_index     = BANDSEL_DCS1800;
  754.                 as_epsk_tx_2cal_pcl = m_as_dcs1800_epsk_tx_2cal_pcl;
  755.                 as_epsk_tx_pcl      = m_as_dcs1800_epsk_tx_pcl;
  756.                 as_epsk_wanted_p    = m_as_dcs1800_epsk_wanted_p;
  757.                 as_epsk_correction  = m_as_dcs1800_epsk_correction;
  758.             }
  759.             break;
  760.             case FrequencyBand1900:
  761.             {
  762.                 if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
  763.                 {
  764.                     eFreqBand++;
  765.                     continue;
  766.                 }
  767.                 band_index     = BANDSEL_PCS1900;
  768.                 as_epsk_tx_2cal_pcl = m_as_pcs1900_epsk_tx_2cal_pcl;
  769.                 as_epsk_tx_pcl      = m_as_pcs1900_epsk_tx_pcl;
  770.                 as_epsk_wanted_p    = m_as_pcs1900_epsk_wanted_p;
  771.                 as_epsk_correction  = m_as_pcs1900_epsk_correction;
  772.             }
  773.             break;
  774.             default:
  775.                 assert(false);
  776.             break;
  777.         } // switch
  778.         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() + " " +
  779.                               BandIdx_To_String(band_index)
  780.                         );
  781.         for(int i=0; i<CALIBRATIE_NUM_2PCL; i++)
  782.         {
  783.            // if (! getAnsiStrSubItem( as_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_2cal_pcl) )
  784.            // {
  785.           //      CalErrorHandler( WM_MF_CFG_READ_FAIL );
  786.           //      log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  787.           //                    " FAIL: Read config file fail(sub_tx_cal_pcl)."
  788.           //              );
  789.           //      return false;
  790.           //  }
  791.           //  i_PCL_Cal[band_index][i] = as_sub_tx_2cal_pcl.ToInt();
  792.             // EPSK
  793.            // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  794.             {
  795.                 if (! getAnsiStrSubItem( as_epsk_tx_2cal_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_2cal_pcl) )
  796.                 {
  797.                     CalErrorHandler(WM_MF_CFG_READ_FAIL);
  798.                     log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  799.                               " FAIL: Read config file fail(epsk_sub_tx_cal_pcl)."
  800.                         );
  801.                     return false;
  802.                 }
  803.                 i_EPSK_PCL_Cal[band_index][i] = as_epsk_sub_tx_2cal_pcl.ToInt();
  804.             }
  805.         }
  806.        // offset[band_index] = m_usPCLDacValue[band_index][0];
  807.        // slope[band_index] = (m_usPCLDacValue[band_index][1]-m_usPCLDacValue[band_index][0])/(m_dPCL_dBm[band_index][1]-m_dPCL_dBm[band_index][0]);
  808.        // log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  809.        //                       " slope = " + Double_To_AnsiString(slope[band_index]) + " (DAC/dBm)" +
  810.        //                       ", offset = " + IntToStr(offset[band_index])
  811.        //                     );
  812.        // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  813.         {
  814.             offset_epsk[band_index] = m_usPCLDacValue_EPSK[band_index][0];
  815.             slope_epsk[band_index] = (m_usPCLDacValue_EPSK[band_index][1]-m_usPCLDacValue_EPSK[band_index][0])/(m_dPCL_dBm_EPSK[band_index][1]-m_dPCL_dBm_EPSK[band_index][0]);
  816.             log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  817.                               " slope_epsk = " + Double_To_AnsiString(slope_epsk[band_index]) + " (DAC/dBm)" +
  818.                               ", offset_epsk = " + IntToStr(offset_epsk[band_index])
  819.                             );
  820.         }
  821.        // for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
  822.        // {
  823.        //
  824.        //     if( i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
  825.        //         (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
  826.        //       )
  827.        //     {
  828.        //         break;
  829.        //     }
  830.        //
  831.        //     if (! getAnsiStrSubItem( as_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
  832.        //     {
  833.        //         CalErrorHandler( WM_MF_CFG_READ_FAIL );
  834.        //         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  835.        //                       " FAIL: Read config file fail(sub_tx_pcl)."
  836.        //                 );
  837.        //         return false;
  838.        //     }
  839.        //
  840.        //     if (! getAnsiStrSubItem( as_wanted_p, i+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
  841.        //     {
  842.        //         CalErrorHandler( WM_MF_CFG_READ_FAIL );
  843.        //         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  844.        //                       " FAIL: Read config file fail(sub_wanted_p)."
  845.        //                     );
  846.        //         return false;
  847.        //     }
  848.        //
  849.        //     if (! getAnsiStrSubItem( as_correction, i+1, DEFAULT_SEP_CHAR, as_sub_correction) )
  850.        //     {
  851.        //         CalErrorHandler( WM_MF_CFG_READ_FAIL );
  852.        //         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  853.        //                       " FAIL: Read config file fail(as_sub_correction)."
  854.        //                     );
  855.        //         return false;
  856.        //     }
  857.        //
  858.        //
  859.        //     if( as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_LOW_INDEX] &&
  860.        //         as_sub_tx_pcl.ToInt() != i_PCL_Cal[band_index][PCL_MID_INDEX]
  861.        //
  862.        //       )
  863.        //     {
  864.        //         m_usPCLDacValue_ideal[band_index][i] = (atof(as_sub_wanted_p.c_str()) + atof(as_sub_correction.c_str()) - m_dPCL_dBm[band_index][0]) * slope[band_index] + offset[band_index];
  865.        //         // MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[i] = m_usPCLDacValue_ideal[band_index][i];
  866.        //         MF_rf_apc_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal[band_index][i] );
  867.        //         log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  868.        //                   // "                         " +
  869.        //                    " m_usPCLDacValue_ideal[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  870.        //                      Double_To_AnsiString(m_usPCLDacValue_ideal[band_index][i]) + "n"
  871.        //                 );
  872.        //     }
  873.        //
  874.        //
  875.        // }
  876.         // Evaluate DAC except highest and lowest PCL
  877.        // if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  878.         {
  879.             for(int i=0; i<RF_RAMP_TABLE_TX_LEVEL_COUNT; i++)
  880.             {
  881.                 if (i==RF_RAMP_TABLE_TX_LEVEL_COUNT-1 &&
  882.                     (eFreqBand==FrequencyBand850 || eFreqBand==FrequencyBand900 )
  883.                    )
  884.                 {
  885.                     break;
  886.                 }
  887.                 // EPSK
  888.                 if (! getAnsiStrSubItem(as_epsk_tx_pcl, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_pcl))
  889.                 {
  890.                     CalErrorHandler(WM_MF_CFG_READ_FAIL);
  891.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  892.                               " FAIL: Read config file fail(epsk_sub_tx_pcl)."
  893.                         );
  894.                     return false;
  895.                 }
  896.                 // EPSK
  897.                 if (! getAnsiStrSubItem( as_epsk_wanted_p, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_wanted_p) )
  898.                 {
  899.                     CalErrorHandler(WM_MF_CFG_READ_FAIL);
  900.                     log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  901.                               " FAIL: Read config file fail(epsk_sub_wanted_p)."
  902.                             );
  903.                     return false;
  904.                 }
  905.                 // EPSK
  906.                 if (! getAnsiStrSubItem( as_epsk_correction, i+1, DEFAULT_SEP_CHAR, as_epsk_sub_correction) )
  907.                 {
  908.                     CalErrorHandler(WM_MF_CFG_READ_FAIL);
  909.                     log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  910.                               " FAIL: Read config file fail(as_epsk_sub_correction)."
  911.                             );
  912.                     return false;
  913.                 }
  914.                 // EPSK
  915.                 if (as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_LOW_INDEX] &&
  916.                     as_epsk_sub_tx_pcl.ToInt() != i_EPSK_PCL_Cal[band_index][PCL_MID_INDEX]
  917.                    )
  918.                 {
  919.                     m_usPCLDacValue_ideal_EPSK[band_index][i] = (atof(as_epsk_sub_wanted_p.c_str()) + atof(as_epsk_sub_correction.c_str()) - m_dPCL_dBm_EPSK[band_index][0]) * slope_epsk[band_index] + offset_epsk[band_index];
  920.                     MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, i, m_usPCLDacValue_ideal_EPSK[band_index][i] );
  921.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  922.                           // "                         " +
  923.                            " m_usPCLDacValue_ideal_EPSK[" + IntToStr(band_index) + "][" + IntToStr(i) + "] = " +
  924.                              Double_To_AnsiString(m_usPCLDacValue_ideal_EPSK[band_index][i]) + "n"
  925.                         );
  926.                 }
  927.             }
  928.         }
  929.        // MF_rf_apc_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
  930.        // MF_rf_apc_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index, m_pCal->b_TADOSupport );
  931.        // RestartTimerCal( WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL );
  932.        // CHECK_TERMINATE_BY_USER
  933.        // SUSPEND_CAL_THREAD
  934.        // E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
  935.        // if (state != METAAPP_SUCCESS)
  936.        // {
  937.        //     if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
  938.        //     {
  939.        //         CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
  940.        //         log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  941.        //                      " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
  942.        //                      );
  943.        //     }
  944.        //     else
  945.        //     {
  946.        //         CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  947.       //          log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  948.       //                                " FAIL: Target < write APC to NVRAM "
  949.       //                              );
  950.       //      }
  951.       //      return false;
  952.       //  }
  953.       //  WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
  954.         // EPSK
  955.         if (m_pCal->i_APC_mod & APC_MOD_EPSK)
  956.         {
  957.             MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
  958.             MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index);
  959.             log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  960.                       " Write to NVRAM band_index = " + IntToStr(band_index)
  961.                     );
  962.             RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  963.             CHECK_TERMINATE_BY_USER
  964.             SUSPEND_CAL_THREAD
  965.             E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
  966.             if (state != METAAPP_SUCCESS)
  967.             {
  968.                 if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
  969.                 {
  970.                     CalErrorHandler(WM_MF_NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID_VERNO_FAIL);
  971.                     log->Add(DateToStr(Date()) +  " " + CurrentTimeStr() +
  972.                                               " FAIL : NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
  973.                                               );
  974.                 }
  975.                 else
  976.                 {
  977.                     CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
  978.                     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  979.                                       " FAIL: Target< write EPSK APC to NVRAM "
  980.                                     );
  981.                 }
  982.                 return false;
  983.             }
  984.             WriteEpskAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
  985.         }
  986.         eFreqBand++;
  987.     } // while
  988.     frmFatcory->DisableAllCalTimer();
  989.     log->Add( DateToStr(Date()) +  " " + CurrentTimeStr() +
  990.                  " ===================== Evaluate other PCL DAC value end =========== n "
  991.                 );
  992.     return true;
  993. }