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

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.  *   rf_apc.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   RF APC 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. #pragma hdrstop
  66. #ifndef META_DLL_H
  67. #include "meta.h"
  68. #endif
  69. #ifndef  _RF_APC_H_
  70. #include "rf_apc.h"
  71. #endif
  72. #include "man_fdm.h"
  73. #include "man_active.h"
  74. #include "form_main.h" // for GSM 850
  75. // misc
  76. #include "misc.h"
  77. #ifndef  _FT_UTILS_H_
  78. #include "ft_utils.h"
  79. #endif
  80. #ifndef  _BAND_UTILS_H_
  81. #include "band_utils.h"
  82. #endif
  83. #ifndef  _GSM_UTILS_H_
  84. #include "gsm_utils.h"
  85. #endif
  86. // NVRAM
  87. #ifndef  _NVRAM_VER_H_
  88. #include "nvram_ver.h"
  89. #endif
  90. //===========================================================================
  91. extern TfrmMainSel *frmMainSel;  // for GSM 850
  92. static CRFAPC*  rf_apc_ptr;
  93. static bool g_bIsRunning = false;
  94. //===========================================================================
  95. static const char  SUBBAND_NAME[][32] =
  96. {
  97.    "GSM900 level, ramp",
  98.    "DCS1800 level, ramp",
  99.    "PCS1900 level, ramp",
  100.    "GSM850 level, ramp",
  101. };
  102. //--------------------------------------------------------------------------
  103. static const char  SUBBAND_NAME_WORD3[32] =
  104. {
  105.    "RENESAS WORD3"
  106. };
  107. //--------------------------------------------------------------------------
  108. static const char  SUBBAND_NAME_WORD6S[32] =
  109. {
  110.    "RENESAS WORD6S"
  111. };
  112. //===========================================================================
  113. static const char  BAND_NAME1[4][12] =
  114. {  "GSM",
  115.    "DCS",
  116.    "PCS",
  117.    "GSM850"
  118. };
  119. //---------------------------------------------------------------------------
  120. static const char  BAND_NAME2[4][12] =
  121. {  "GSM900",
  122.    "DCS1800",
  123.    "PCS1900",
  124.    "GSM850"
  125. };
  126. //---------------------------------------------------------------------------
  127. static const int  LOWEST_POWER[] =
  128. {  5, 0, 0, 5  };
  129. //---------------------------------------------------------------------------
  130. static const char  BAND_PCL_COMMENT[4][128] =
  131. {  "   /*  5,  7,  9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 dBm                        */n",
  132.    "   /*    0,  2,  4,  6,  8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 dBm                      */n",
  133.    "   /*    0,  2,  4,  6,  8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 dBm                      */n",
  134.    "   /*  5,  7,  9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 dBm                        */n"
  135. };
  136. //===========================================================================
  137. static  void  REQ_ReadApcFromNVRAM( void )
  138. {
  139.    rf_apc_ptr->REQ_ReadApcFromNVRAM( );
  140. }
  141. //---------------------------------------------------------------------------
  142. static void  CNF_ReadApcFromNVRAM( void )
  143. {
  144.    rf_apc_ptr->CNF_ReadApcFromNVRAM();
  145. }
  146. //---------------------------------------------------------------------------
  147. static  void  REQ_WriteApcToNVRAM( void )
  148. {
  149.    rf_apc_ptr->REQ_WriteApcToNVRAM( );
  150. }
  151. //---------------------------------------------------------------------------
  152. static  void  CNF_WriteApcToNVRAM( void )
  153. {
  154.    rf_apc_ptr->CNF_WriteApcToNVRAM( );
  155. }
  156. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  157. //static void  CNF_ReadWord3FromNVRAM( void )
  158. //{
  159. //   rf_apc_ptr->CNF_ReadWord3FromNVRAM();
  160. //}
  161. //---------------------------------------------------------------------------
  162. //static  void  CNF_WriteWord3ToNVRAM( void )
  163. //{
  164. //   rf_apc_ptr->CNF_WriteWord3ToNVRAM( );
  165. //}
  166. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  167. static void  CNF_ReadB5PFromNVRAM( void )
  168. {
  169.    rf_apc_ptr->CNF_ReadB5PFromNVRAM();
  170. }
  171. //---------------------------------------------------------------------------
  172. static  void  CNF_WriteB5PToNVRAM( void )
  173. {
  174.    rf_apc_ptr->CNF_WriteB5PToNVRAM( );
  175. }
  176. //---------------------------------------------------------------------------
  177. static void REQ_SetW6sImmediateBSI( void )
  178. {
  179.     rf_apc_ptr->REQ_SetW6sImmediateBSI();
  180. }
  181. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  182. //---------------------------------------------------------------------------
  183. static void  REQ_TimeOut( void )
  184. {  rf_apc_ptr->REQ_TimeOut();
  185. }
  186. //---------------------------------------------------------------------------
  187. static void  REQ_Finish( void )
  188. {  rf_apc_ptr->REQ_Finish();
  189. }
  190. //---------------------------------------------------------------------------
  191. static void __stdcall CNF_RfSetRampApcLevl(const unsigned char cnf, const short token, void *usrData)
  192. {  rf_apc_ptr->CNF_RfSetRampApcLevl(cnf, token, usrData);
  193. }
  194. //---------------------------------------------------------------------------
  195. static void REQ_RfSetRampTable( void )
  196. {
  197.     rf_apc_ptr->REQ_RfSetRampTable();
  198. }
  199. //---------------------------------------------------------------------------
  200. static void Query_RfSetRampTable( void )
  201. {   rf_apc_ptr->Query_RfSetRampTable();
  202. }
  203. //---------------------------------------------------------------------------
  204. static void Query_TwoApcDcOffset( void )
  205. {   rf_apc_ptr->Query_TwoApcDcOffset();
  206. }
  207. //===========================================================================
  208. CRFAPC::CRFAPC( void )
  209. {
  210.     g_bIsRunning = false;
  211.     ConfirmCallback = 0;
  212.     ApcBufSize = 0;
  213.     ApcBuf = NULL;
  214.     B5PBufSize = 0;
  215.     B5PBuf = NULL;
  216.     // query
  217.     m_bTADOSupport = false;
  218. }
  219. //---------------------------------------------------------------------------
  220. CRFAPC::~CRFAPC()
  221. {
  222.     g_bIsRunning = false;
  223.     ConfirmCallback = 0;
  224.     if(ApcBuf)
  225.     {
  226.         delete [] ApcBuf;
  227.         ApcBuf = NULL;
  228.     }
  229.     //if(Word3Buf)
  230.    // {
  231.     //    delete [] Word3Buf;
  232.     //    Word3Buf = NULL;
  233.     //}
  234.     if(B5PBuf)
  235.     {
  236.         delete [] B5PBuf;
  237.         B5PBuf = NULL;
  238.     }
  239. }
  240. //---------------------------------------------------------------------------
  241. void  CRFAPC::REQ_Finish( void )
  242. {
  243.    if(!g_bIsRunning)  return;
  244.    Confirm( METAAPP_SUCCESS );
  245.    g_bIsRunning = false;
  246. }
  247. //---------------------------------------------------------------------------
  248. void  CRFAPC::REQ_Stop( void )
  249. {
  250.    if(!g_bIsRunning)  return;
  251.    NVRAMMan->REQ_Stop();
  252.    Confirm( METAAPP_STOP );
  253.    g_bIsRunning = false;
  254. }
  255. //---------------------------------------------------------------------------
  256. void  CRFAPC::REQ_TimeOut( void )
  257. {
  258.    if(!g_bIsRunning)  return;
  259.    NVRAMMan->REQ_Stop();
  260.    Confirm( METAAPP_TIMEOUT );
  261.    g_bIsRunning = false;
  262. }
  263. //---------------------------------------------------------------------------
  264. void CRFAPC::Confirm(E_METAAPP_RESULT_T confirm_state)
  265. {
  266.    if(!g_bIsRunning)  return;
  267.    if(ConfirmCallback==0)  return;
  268.    m_eConfirmState = confirm_state;
  269.    ActiveMan->SetActiveFunction( ConfirmCallback );
  270. }
  271. //===========================================================================
  272. //---------------------------------------------------------------------------
  273. //static char  NVRAM_RAMPNAME[][32] =
  274. //{
  275. //   "L1_RAMPTABLE_GSM900",
  276. //   "L1_RAMPTABLE_DCS1800",
  277. //   "L1_RAMPTABLE_PCS1900",
  278. //   "L1_RAMPTABLE_GSM850",
  279. //};
  280. //===========================================================================
  281. void CRFAPC::REQ_Read_APC_From_NVRAM_Start(unsigned int rf_id, bool b_tapo_support)
  282. {
  283.     rf_apc_ptr = this;
  284.     g_bIsRunning = true;
  285.     CurWRBand = BANDSEL_GSM900;
  286.     m_uiRfModId = rf_id;
  287.     m_bTADOSupport = b_tapo_support;
  288.     m_bSingleBand = false;
  289.     m_bDownloadTrigger = false;
  290.     REQ_ReadApcFromNVRAM();
  291. }
  292. //------------------------------------------------------------------------------
  293. void CRFAPC::REQ_Read_APC_From_NVRAM_Single_Band_Start(unsigned int rf_id, int band, bool b_tapo_support)
  294. {
  295.     rf_apc_ptr = this;
  296.     g_bIsRunning = true;
  297.     CurWRBand = band;
  298.     m_uiRfModId = rf_id;
  299.     m_bTADOSupport = b_tapo_support;
  300.     m_bSingleBand = true;
  301.     m_bDownloadTrigger = false;
  302.     REQ_ReadApcFromNVRAM();
  303. }
  304. //-------------------------------------
  305. void CRFAPC::REQ_ReadApcFromNVRAM(void)
  306. {
  307.     if (!g_bIsRunning)
  308.     {
  309.         return;
  310.     }
  311.     META_RESULT  MetaResult;
  312.     int  band = CurWRBand;
  313.     if (NULL == ApcBuf)
  314.     {
  315.         //bool vbias_support = NVRAMMan->Get_VbiasSupport();
  316.         MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RAMPTABLE_GSM900_LID", &ApcBufSize);
  317.         if (MetaResult != META_SUCCESS)
  318.         {
  319.             Confirm(METAAPP_FAIL);
  320.             return;
  321.         }
  322.         ApcBuf = new  char[ApcBufSize];
  323.     }
  324.     NVRAMMan->ConfirmCallback = ::CNF_ReadApcFromNVRAM;
  325.     switch(band)
  326.     {
  327.         case BANDSEL_GSM850:
  328.         {
  329.             NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM850_LID",
  330.                                             1,
  331.                                             ApcBufSize,
  332.                                             ApcBuf);
  333.         }
  334.         break;
  335.         case BANDSEL_GSM900:
  336.         {
  337.          NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM900_LID",
  338.                                           1,
  339.                                           ApcBufSize,
  340.                                           ApcBuf);
  341.         }
  342.         break;
  343.         case BANDSEL_DCS1800:
  344.         {
  345.             NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_DCS1800_LID",
  346.                                           1,
  347.                                           ApcBufSize,
  348.                                           ApcBuf);
  349.         }
  350.         break;
  351.         case BANDSEL_PCS1900:
  352.         {
  353.             NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_PCS1900_LID",
  354.                                           1,
  355.                                           ApcBufSize,
  356.                                           ApcBuf);
  357.         }
  358.         break;
  359.         default:
  360.         {
  361.             Confirm(METAAPP_FAIL);
  362.         }
  363.         break;
  364.     }
  365. }
  366. //-------------------------------------
  367. void CRFAPC::CNF_ReadApcFromNVRAM(void)
  368. {
  369.     if (!g_bIsRunning)
  370.     {
  371.         return;
  372.     }
  373.     META_RESULT  MetaResult;
  374.     int  band = CurWRBand;
  375.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  376.     switch (state)
  377.     {
  378.         case METAAPP_SUCCESS:
  379.         {
  380.             if (m_bDownloadTrigger)
  381.             {
  382.                 if (!frmMainSel->cbGSM850->Checked)
  383.                 {
  384.                     if ((BANDSEL_PCS1900 == band) | m_bSingleBand)
  385.                     {
  386.                         if (!m_bSingleBand)
  387.                         {
  388.                             CurWRBand = BANDSEL_GSM900;
  389.                         }
  390.                         REQ_WriteApcToNVRAM();
  391.                     }
  392.                     else
  393.                     {
  394.                         CurWRBand++;
  395.                         ActiveMan->SetActiveFunction(::REQ_ReadApcFromNVRAM);
  396.                     }
  397.                 }
  398.                 else
  399.                 {
  400.                     if ((BANDSEL_GSM850 == band) | m_bSingleBand)
  401.                     {
  402.                         if (!m_bSingleBand)
  403.                         {
  404.                             CurWRBand = BANDSEL_GSM900;
  405.                         }
  406.                         REQ_WriteApcToNVRAM();
  407.                     }
  408.                     else
  409.                     {
  410.                         CurWRBand++;
  411.                         ActiveMan->SetActiveFunction( ::REQ_ReadApcFromNVRAM );
  412.                     }
  413.                 }
  414.             }
  415.             else
  416.             {
  417.                 int idata;
  418.                 //bool vbias_support = NVRAMMan->Get_VbiasSupport();
  419.                 //if (vbias_support)
  420.                 //{
  421.                 //    MetaResult = META_NVRAM_Decompose_rampTable_Ex2(&m_sApcProfile[band],
  422.                 //                                                    ApcBuf,
  423.                 //                                                    ApcBufSize);
  424.                // }
  425.                // else
  426.                 {
  427.                     //l1cal_rampTable_T ramp_table;
  428.                     MetaResult = META_NVRAM_Decompose_rampTable(&m_sApcProfile[band],
  429.                                                                 ApcBuf,
  430.                                                                 ApcBufSize);
  431.                    // m_sApcProfile[band].rampData.lowest_power = ramp_table.rampData.lowest_power;
  432.                    // for (int i=0; i<MAX_APC_PCL_NUM; i++)
  433.                    // {
  434.                    //     m_sApcProfile[band].rampData.power[i] = ramp_table.rampData.power[i];
  435.                    //     m_sApcProfile[band].rampData.ramp[i]  = ramp_table.rampData.ramp[i];
  436.                    // }
  437.                    //
  438.                    // for (int i=0; i<ARFCN_SECTION_NUM; i++)
  439.                    // {
  440.                    //     m_sApcProfile[band].rampData.arfcn_weight[i] = ramp_table.rampData.arfcn_weight[i];
  441.                    // }
  442.                    //
  443.                    // for (int i=0; i<APC_BATTERY_COMP_NUM; i++)
  444.                    // {
  445.                    //     for (int j=0; j<APC_BATTERY_COMP_NUM; j++)
  446.                    //     {
  447.                 //         m_sApcProfile[band].rampData.battery_compensate[i][j] = ramp_table.rampData.battery_compensate[i][j];
  448.                    //     }
  449.                    // }
  450.                    // m_sApcProfile[band].rampData.tx_afc_offset = ramp_table.rampData.tx_afc_offset;
  451.                 }
  452.                 if (MetaResult!=META_SUCCESS)
  453.                 {
  454.                     Confirm(METAAPP_FAIL);
  455.                     return;
  456.                 }
  457.                 m_usHighApcDcOffset[band] = (m_sApcProfile[band].rampData.lowest_power>>8) & 0x03FF;
  458.                 if (m_bTADOSupport)
  459.                 {
  460.                     m_usLowApcDcOffset[band] = (m_sApcProfile[band].rampData.lowest_power>>18) & 0x03FF;
  461.                     m_iApcLowestPower[band] = m_sApcProfile[band].rampData.lowest_power & 0x00FF;
  462.                 }
  463.                 m_sApcProfile[band].rampData.lowest_power &=0x0FF;
  464.                 for (int i=0; i<ARFCN_SECTION_NUM; i++)
  465.                 {
  466.                     idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
  467.                     m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
  468.                     if (32767 == m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn)
  469.                     {
  470.                         m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn = -1;
  471.                     }
  472.                 }
  473.                 bool isAllBCEqualZero = true;
  474.                 for (int i=0; i<3; i++)
  475.                 {
  476.                     for (int j=0; j<3; j++)
  477.                     {
  478.                         if (m_sApcProfile[band].rampData.battery_compensate[i][j] != 0)
  479.                         {
  480.                             isAllBCEqualZero = false;
  481.                             break;
  482.                         }
  483.                     }
  484.                 }
  485.                 if (isAllBCEqualZero)
  486.                 {
  487.                     for (int i=0; i<3; i++)
  488.                     {
  489.                         for (int j=0; j<3; j++)
  490.                         {
  491.                             m_sApcProfile[band].rampData.battery_compensate[i][j] = BATTERY_COMPENSATE_SCALE;
  492.                         }
  493.                     }
  494.                 }
  495.                 if (!frmMainSel->cbGSM850->Checked)
  496.                 {
  497.                     if (BANDSEL_GSM900 == band)
  498.                     {
  499.                         m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  500.                     }
  501.                 }
  502.                 else
  503.                 {
  504.                     if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
  505.                     {
  506.                         m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  507.                     }
  508.                 }
  509.                 if (!frmMainSel->cbGSM850->Checked)
  510.                 {
  511.                     if ((BANDSEL_PCS1900 == band) || m_bSingleBand)
  512.                     {
  513.                         ActiveMan->SetActiveFunction(::REQ_Finish);
  514.                     }
  515.                     else
  516.                     {
  517.                         CurWRBand++;
  518.                         ActiveMan->SetActiveFunction(::REQ_ReadApcFromNVRAM);
  519.                     }
  520.                 }
  521.                 else
  522.                 {
  523.                     if ((BANDSEL_GSM850 == band) || m_bSingleBand)
  524.                     {
  525.                         ActiveMan->SetActiveFunction( ::REQ_Finish );
  526.                     }
  527.                     else
  528.                     {
  529.                         CurWRBand++;
  530.                         ActiveMan->SetActiveFunction( ::REQ_ReadApcFromNVRAM );
  531.                     }
  532.                 }
  533.             }
  534.         }
  535.         break;
  536.         default:
  537.         {
  538.             Confirm(state);
  539.         }
  540.         break;
  541.     }
  542. }
  543. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  544. void CRFAPC::REQ_Write_APC_To_NVRAM_Start(unsigned int rf_id, bool b_tapo_support)
  545. {
  546.     rf_apc_ptr = this;
  547.     g_bIsRunning = true;
  548.     m_uiRfModId  = rf_id;
  549.     m_bSingleBand = false;
  550.     CurWRBand = BANDSEL_GSM900;
  551.     m_bTADOSupport = b_tapo_support;
  552.     m_bDownloadTrigger = true;
  553.     REQ_WriteApcToNVRAM();
  554. }
  555. //-------------------------------------
  556. void CRFAPC::REQ_Write_APC_To_NVRAM_Single_Band_Start(unsigned int rf_id, int band, bool b_tapo_support)
  557. {
  558.     rf_apc_ptr = this;
  559.     g_bIsRunning = true;
  560.     m_uiRfModId  = false;
  561.     m_bSingleBand = true;
  562.     CurWRBand = band;
  563.     m_bTADOSupport = b_tapo_support;
  564.     m_bDownloadTrigger = true;
  565.     REQ_WriteApcToNVRAM();
  566. }
  567. //-------------------------------------
  568. void CRFAPC::REQ_WriteApcToNVRAM(void)
  569. {
  570.     if(!g_bIsRunning)  return;
  571.     int  i, j;
  572.     int  idata;
  573.     int  band = CurWRBand;
  574.     META_RESULT MetaResult;
  575.     if (NULL==ApcBuf)
  576.     {
  577.         MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RAMPTABLE_GSM900_LID", &ApcBufSize);
  578.         if(MetaResult!=META_SUCCESS)
  579.         {  Confirm( METAAPP_FAIL );  return;  }
  580.         ApcBuf = new  char[ApcBufSize];
  581.     }
  582.     if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
  583.     {
  584.         m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  585.     }
  586.     if( ! m_bTADOSupport )
  587.     {
  588.         m_sApcProfile[band].rampData.lowest_power =  ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
  589.                                                    NVRAM_APC_LOWEST_POWER[band];
  590.     }
  591.     else
  592.     {
  593.         m_sApcProfile[band].rampData.lowest_power = ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
  594.                                                  ((m_usLowApcDcOffset[band]&0x03FF)<<18) |
  595.                                                   m_iApcLowestPower[band];
  596.     }
  597.     for( i=0; i<12; i++ )
  598.     {
  599.         idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
  600.         m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = PCL2POWER(band, idata);
  601.     }
  602.     //bool vbias_support = NVRAMMan->Get_VbiasSupport();
  603.     //if (vbias_support)
  604.     //{
  605.     //    MetaResult = META_NVRAM_Compose_rampTable_Ex2( &m_sApcProfile[band],
  606.     //                                          ApcBuf,
  607.     //                                          ApcBufSize );
  608.     //}
  609.     //else
  610.     //{
  611.     //    l1cal_rampTable_T ramp_table;
  612.     //
  613.     //    ramp_table.rampData.lowest_power = m_sApcProfile[band].rampData.lowest_power;
  614.     //    for (int i=0; i<MAX_APC_PCL_NUM; i++)
  615.     //    {
  616.     //        ramp_table.rampData.power[i] = m_sApcProfile[band].rampData.power[i];
  617.     //        ramp_table.rampData.ramp[i]  = m_sApcProfile[band].rampData.ramp[i];
  618.     //    }
  619.     //
  620.     //    for (int i=0; i<ARFCN_SECTION_NUM; i++)
  621.     //    {
  622.     //        ramp_table.rampData.arfcn_weight[i] = m_sApcProfile[band].rampData.arfcn_weight[i];
  623.     //    }
  624.     //
  625.     //    for (int i=0; i<APC_BATTERY_COMP_NUM; i++)
  626.     //    {
  627.     //       for (int j=0; j<APC_BATTERY_COMP_NUM; j++)
  628.     //        {
  629.     //            ramp_table.rampData.battery_compensate[i][j] = m_sApcProfile[band].rampData.battery_compensate[i][j];
  630.     //        }
  631.     //    }
  632.     //    ramp_table.rampData.tx_afc_offset = m_sApcProfile[band].rampData.tx_afc_offset;
  633.     //
  634.         MetaResult = META_NVRAM_Compose_rampTable(&m_sApcProfile[band],
  635.                                               ApcBuf,
  636.                                               ApcBufSize );
  637.     //}
  638.     m_sApcProfile[band].rampData.lowest_power &= 0x0FF;
  639.     for( i=0; i<12; i++ )
  640.     {
  641.         idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
  642.         m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
  643.    }
  644.     if (MetaResult != META_SUCCESS)
  645.     {
  646.         Confirm(METAAPP_FAIL);
  647.         return;
  648.     }
  649.     NVRAMMan->ConfirmCallback = ::CNF_WriteApcToNVRAM;
  650.     switch (band)
  651.     {
  652.         case BANDSEL_GSM850:
  653.         {
  654.             unsigned short lid_ver;
  655.             MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_GSM850_LID", &lid_ver);
  656.             if (lid_ver > NVRAM_EF_L1_RAMPTABLE_GSM850_LID_VERNO)
  657.             {
  658.                 Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
  659.                 return;
  660.             }
  661.             NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM850_LID",
  662.                                             1,
  663.                                             ApcBufSize,
  664.                                             ApcBuf);
  665.         }
  666.         break;
  667.         case BANDSEL_GSM900:
  668.         {
  669.             unsigned short lid_ver;
  670.             MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_GSM900_LID", &lid_ver);
  671.             if (lid_ver > NVRAM_EF_L1_RAMPTABLE_GSM900_LID_VERNO)
  672.             {
  673.                 Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
  674.                 return;
  675.             }
  676.             NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_GSM900_LID",
  677.                                             1,
  678.                                             ApcBufSize,
  679.                                             ApcBuf);
  680.         }
  681.         break;
  682.         case BANDSEL_DCS1800:
  683.         {
  684.             unsigned short lid_ver;
  685.             MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_DCS1800_LID", &lid_ver);
  686.             if (lid_ver > NVRAM_EF_L1_RAMPTABLE_DCS1800_LID_VERNO)
  687.             {
  688.                 Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
  689.                 return;
  690.             }
  691.             NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_DCS1800_LID",
  692.                                             1,
  693.                                             ApcBufSize,
  694.                                             ApcBuf);
  695.         }
  696.         break;
  697.         case BANDSEL_PCS1900:
  698.         {
  699.             unsigned short lid_ver;
  700.             MetaResult = META_NVRAM_GetLIDVersion("NVRAM_EF_L1_RAMPTABLE_PCS1900_LID", &lid_ver);
  701.             if (lid_ver > NVRAM_EF_L1_RAMPTABLE_PCS1900_LID_VERNO)
  702.             {
  703.                 Confirm(METAAPP_NVRAM_LID_VER_NOT_SUPPORT);
  704.                 return;
  705.             }
  706.             NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RAMPTABLE_PCS1900_LID",
  707.                                             1,
  708.                                             ApcBufSize,
  709.                                             ApcBuf);
  710.         }
  711.         break;
  712.     }
  713. }
  714. //-------------------------------------
  715. void  CRFAPC::CNF_WriteApcToNVRAM( void )
  716. {
  717.     int  band = CurWRBand;
  718.     if(!g_bIsRunning)  return;
  719.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  720.     if(state==METAAPP_SUCCESS)
  721.     {
  722.         if (frmMainSel->cbGSM850->Checked)
  723.         {
  724.             if( (band==BANDSEL_GSM850)||(m_bSingleBand) )
  725.             {   ActiveMan->SetActiveFunction( ::REQ_Finish );
  726.             }
  727.             else
  728.             {
  729.                 CurWRBand++;
  730.                 ActiveMan->SetActiveFunction( ::REQ_WriteApcToNVRAM );
  731.             }
  732.         }
  733.         else
  734.         {
  735.             if( (band==BANDSEL_PCS1900)||(m_bSingleBand) )
  736.             {  ActiveMan->SetActiveFunction( ::REQ_Finish );
  737.             }
  738.             else
  739.             {
  740.                 CurWRBand++;
  741.                 ActiveMan->SetActiveFunction( ::REQ_WriteApcToNVRAM );
  742.             }
  743.         }
  744.     }
  745.     else
  746.     {   Confirm(state);
  747.     }
  748. }
  749. #if 0
  750. //===========================================================================
  751. void  CRFAPC::REQ_Read_WORD3_From_NVRAM( void )
  752. {
  753.     rf_apc_ptr = this;
  754.     g_bIsRunning = true;
  755.     if(Word3Buf==0)
  756.     {
  757.         MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  758.                                           &Word3BufSize );
  759.         if(MetaResult!=META_SUCCESS)
  760.         {  Confirm( METAAPP_FAIL );  return;  }
  761.         Word3Buf = new  char[Word3BufSize];
  762.     }
  763.     NVRAMMan->ConfirmCallback = ::CNF_ReadWord3FromNVRAM;
  764.     NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  765.                                    1, // only one record
  766.                                    Word3BufSize,
  767.                                    Word3Buf );
  768. }
  769. //-------------------------------------
  770. void  CRFAPC::CNF_ReadWord3FromNVRAM( void )
  771. {
  772.     if(!g_bIsRunning)  return;
  773.     int  state = NVRAMMan->m_eConfirmState;
  774.     if(state==METAAPP_SUCCESS)
  775.     {
  776.         int  i;
  777.         int  idata;
  778. //        MetaResult = META_NVRAM_Decompose_rampTable( &Word3Profile[band],
  779. //                                                      Word3Buf,
  780. //                                                      Word3BufSize );
  781.         if(MetaResult!=META_SUCCESS)
  782.         {  Confirm( METAAPP_FAIL );  return;  }
  783.         ActiveMan->SetActiveFunction( ::REQ_Finish );
  784.     }
  785.     else if(state==STATE_NVRAM_TIMEOUT)
  786.     {   Confirm( METAAPP_TIMEOUT );
  787.     }
  788.     else if(state==STATE_NVRAM_STOP)
  789.     {   Confirm( METAAPP_STOP );
  790.     }
  791.     else
  792.     {   Confirm( METAAPP_FAIL );
  793.     }
  794. }
  795. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  796. void  CRFAPC::REQ_Write_WORD3_To_NVRAM( void )
  797. {
  798.     rf_apc_ptr = this;
  799.     g_bIsRunning = true;
  800.     if(Word3Buf==0)
  801.     {
  802.         MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  803.                                           &Word3BufSize );
  804.         if(MetaResult!=META_SUCCESS)
  805.         {  Confirm( METAAPP_FAIL );  return;  }
  806.         Word3Buf = new  char[Word3BufSize];
  807.     }
  808.    // MetaResult = META_NVRAM_Compose_rampTable( &m_sApcProfile[band],
  809.    //                                           Word3Buf,
  810.    //                                           Word3BufSize );
  811.     if(MetaResult!=META_SUCCESS)
  812.     {   Confirm( METAAPP_FAIL );  return;  }
  813.     NVRAMMan->ConfirmCallback = ::CNF_WriteApcToNVRAM;
  814.     NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  815.                                             1, // only 1 record
  816.                                             Word3BufSize,
  817.                                             Word3Buf );
  818. }
  819. //-------------------------------------
  820. void  CRFAPC::CNF_WriteWord3ToNVRAM( void )
  821. {
  822.     if(!g_bIsRunning)  return;
  823.     int  state = NVRAMMan->m_eConfirmState;
  824.     if(state==METAAPP_SUCCESS)
  825.     {
  826.         ActiveMan->SetActiveFunction( ::REQ_Finish );
  827.     }
  828.     else if(state==STATE_NVRAM_TIMEOUT)
  829.     {   Confirm( METAAPP_TIMEOUT );
  830.     }
  831.     else if(state==STATE_NVRAM_STOP)
  832.     {   Confirm( METAAPP_STOP );
  833.     }
  834.     else
  835.     {   Confirm( METAAPP_FAIL );
  836.     }
  837. }
  838. #endif
  839. //===========================================================================
  840. void  CRFAPC::Compose_wordC3(sC3Mode c3mode, unsigned int &wordC3)
  841. {
  842.     wordC3 = (c3mode.uc_tn << 11) | (c3mode.uc_to << 7) | ( 0x06 << 3 ) | ADDR_WORD_C3;
  843. }
  844. //---------------------------------------------------------------------------
  845. void  CRFAPC::DeCompose_wordC3(unsigned int wordC3, sC3Mode & c3mode)
  846. {
  847.     c3mode.uc_tn = (wordC3 >> 11) & 0x3F;
  848.     c3mode.uc_to = (wordC3 >> 7) & 0x0F;
  849.     c3mode.uc_pm = (wordC3 >> 3) & 0x0F;
  850.     c3mode.uc_addr = (wordC3 ) & 0x07;
  851. }
  852. //---------------------------------------------------------------------------
  853. void  CRFAPC::Compose_word6_4_0(sBVW0 &bvw0, unsigned int &word6_4_0)
  854. {
  855.     word6_4_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_4_0;
  856. }
  857. //---------------------------------------------------------------------------
  858. void  CRFAPC::Compose_word6_5_0(sBVW0 &bvw0, unsigned int &word6_5_0)
  859. {
  860.     word6_5_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_5_0;
  861. }
  862. //---------------------------------------------------------------------------
  863. void  CRFAPC::Compose_word6_6_0(sBVW0 &bvw0, unsigned int &word6_6_0)
  864. {
  865.     word6_6_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_6_0;
  866. }
  867. //---------------------------------------------------------------------------
  868. void  CRFAPC::Compose_word6_7_0(sBVW0 &bvw0, unsigned int &word6_7_0)
  869. {
  870.     word6_7_0 = (bvw0.uc_ap<<20) | (bvw0.uc_as<<17) | (bvw0.uc_ao<<11) | (bvw0.uc_bd<<6) | ADDR_BV_WORD_6_7_0;
  871. }
  872. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  873. void  CRFAPC::DeCompose_word6_x_0(unsigned int &word6_x_0, sBVW0 &bvw6x0)
  874. {
  875.     bvw6x0.uc_ap = word6_x_0>>20 & 0x07;
  876.     bvw6x0.uc_as = word6_x_0>>17 & 0x07;
  877.     bvw6x0.uc_ao = word6_x_0>>11 & 0x3F;
  878.     bvw6x0.uc_bd = word6_x_0>>6  & 0x1F;
  879. }
  880. //===========================================================================
  881. void  CRFAPC::REQ_Read_B5P_From_NVRAM( void )
  882. {
  883.     rf_apc_ptr = this;
  884.     g_bIsRunning = true;
  885.     if(B5PBuf==0)
  886.     {
  887.         META_RESULT MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  888.                                           &B5PBufSize );;
  889.         if(MetaResult!=META_SUCCESS)
  890.         {
  891.             Confirm(METAAPP_FAIL);
  892.             return;
  893.         }
  894.         B5PBuf = new  char[B5PBufSize];
  895.     }
  896.     NVRAMMan->ConfirmCallback = ::CNF_ReadB5PFromNVRAM;
  897.     NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  898.                                    1, // only one record
  899.                                    B5PBufSize,
  900.                                    B5PBuf );
  901. }
  902. //-------------------------------------
  903. void  CRFAPC::CNF_ReadB5PFromNVRAM( void )
  904. {
  905.     if(!g_bIsRunning)  return;
  906.     E_METAAPP_RESULT_T  state = NVRAMMan->Get_ConfirmState();
  907.     if(state==METAAPP_SUCCESS)
  908.     {
  909.         int  i;
  910.         int  idata;
  911.         META_RESULT MetaResult = META_NVRAM_Decompose_BRIGHT5P_RFSpecialCoef( &b5p_coef,
  912.                                                       B5PBuf,
  913.                                                       B5PBufSize );
  914.         if(MetaResult!=META_SUCCESS)
  915.         {  Confirm( METAAPP_FAIL );  return;  }
  916.         ActiveMan->SetActiveFunction( ::REQ_Finish );
  917.     }
  918.     else
  919.     {   Confirm(state);
  920.     }
  921. }
  922. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  923. void  CRFAPC::REQ_Write_B5P_To_NVRAM( void )
  924. {
  925.     rf_apc_ptr = this;
  926.     g_bIsRunning = true;
  927.     META_RESULT MetaResult;
  928.     if(B5PBuf==0)
  929.     {
  930.         MetaResult = META_NVRAM_GetRecLen( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  931.                                           &B5PBufSize );;
  932.         if(MetaResult!=META_SUCCESS)
  933.         {  Confirm( METAAPP_FAIL );  return;  }
  934.         B5PBuf = new  char[B5PBufSize];
  935.     }
  936.     MetaResult = META_NVRAM_Compose_BRIGHT5P_RFSpecialCoef(&b5p_coef, B5PBuf, B5PBufSize );
  937.     if(MetaResult!=META_SUCCESS)
  938.     {   Confirm( METAAPP_FAIL );  return;  }
  939.     NVRAMMan->ConfirmCallback = ::CNF_WriteApcToNVRAM;
  940.     NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_RFSPECIALCOEF_LID",
  941.                                             1, // only 1 record
  942.                                             B5PBufSize,
  943.                                             B5PBuf );
  944. }
  945. //-------------------------------------
  946. void CRFAPC::CNF_WriteB5PToNVRAM(void)
  947. {
  948.     if (!g_bIsRunning)
  949.     {
  950.         return;
  951.     }
  952.     E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
  953.     Confirm(state);
  954. }
  955. //============================================================================
  956. ////////////////////////////////   INI file   ////////////////////////////////
  957. //============================================================================
  958. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  959. bool  CRFAPC::ApcGSM850SectionExist( char *filename )
  960. {
  961.     TIniFile   *ini_file;
  962.     ini_file = new TIniFile( filename );
  963.     if( ini_file == NULL ) return false;
  964.     if( ini_file->SectionExists(  "GSM850 level, ramp" )  )
  965.     {
  966.             return true;
  967.     }
  968.     return false;
  969. }
  970. //----------------------------------------------------------------------------
  971. bool  CRFAPC::ApcGSM900SectionExist( char *filename )
  972. {
  973.     TIniFile   *ini_file;
  974.     ini_file = new TIniFile( filename );
  975.     if( ini_file == NULL ) return false;
  976.     if( ini_file->SectionExists( "GSM900 level, ramp" )  )
  977.     {
  978.             return true;
  979.     }
  980.     return false;
  981. }
  982. //----------------------------------------------------------------------------
  983. bool  CRFAPC::ApcDCS1800SectionExist( char *filename )
  984. {
  985.     TIniFile   *ini_file;
  986.     ini_file = new TIniFile( filename );
  987.     if( ini_file == NULL ) return false;
  988.     if( ini_file->SectionExists(  "DCS1800 level, ramp" )  )
  989.     {
  990.             return true;
  991.     }
  992.     return false;
  993. }
  994. //----------------------------------------------------------------------------
  995. bool  CRFAPC::ApcPCS1900SectionExist( char *filename )
  996. {
  997.     TIniFile   *ini_file;
  998.     ini_file = new TIniFile( filename );
  999.     if( ini_file == NULL ) return false;
  1000.     if( ini_file->SectionExists(  "PCS1900 level, ramp" )  )
  1001.     {
  1002.             return true;
  1003.     }
  1004.     return false;
  1005. }
  1006. //----------------------------------------------------------------------------
  1007. bool  CRFAPC::ApcSectionExist( char *filename, int band )
  1008. {
  1009.     int         total_band_num;
  1010.     TIniFile   *ini_file;
  1011.     ini_file = new TIniFile( filename );
  1012.     if( ini_file == NULL ) return false;
  1013.     if( ini_file->SectionExists( (AnsiString) SUBBAND_NAME[band] ) )
  1014.     {
  1015.         return true;
  1016.     }
  1017.     return false;
  1018. }
  1019. //----------------------------------------------------------------------------
  1020. bool  CRFAPC::AnyApcSectionExist( char *filename )
  1021. {
  1022.     int         total_band_num;
  1023.     TIniFile   *ini_file;
  1024.     ini_file = new TIniFile( filename );
  1025.     if( ini_file == NULL ) return false;
  1026.    // frmMainSel->Get_FinalBandSupport( band_support );
  1027.     if(frmMainSel->cbGSM850->Checked)
  1028.    // if( band_support.GSM850 )
  1029.     {   total_band_num = 4;
  1030.     }
  1031.     else
  1032.     {
  1033.         total_band_num = 3;
  1034.     }
  1035.     for(int band = 0; band<total_band_num; band++)
  1036.     {
  1037.         if( ini_file->SectionExists( (AnsiString) SUBBAND_NAME[band] ) )
  1038.         {
  1039.             return true;
  1040.         }
  1041.     }
  1042.     return false;
  1043. }
  1044. //----------------------------------------------------------------------------
  1045. bool  CRFAPC::RenesasWord3SectionExist( char *filename )
  1046. {
  1047.     TIniFile   *ini_file;
  1048.     ini_file = new TIniFile( filename );
  1049.     if( ini_file == NULL ) return false;
  1050.     if( ini_file->SectionExists(  "RENESAS WORD3" )  )
  1051.     {
  1052.             return true;
  1053.     }
  1054.     return false;
  1055. }
  1056. //----------------------------------------------------------------------------
  1057. bool  CRFAPC::RenesasWord6sSectionExist( char *filename )
  1058. {
  1059.     int         total_band_num;
  1060.     TIniFile   *ini_file;
  1061.     ini_file = new TIniFile( filename );
  1062.     if( ini_file == NULL ) return false;
  1063.     if( ini_file->SectionExists(  "RENESAS WORD6S" )  )
  1064.     {
  1065.             return true;
  1066.     }
  1067.     return false;
  1068. }
  1069. //-----------------------------------------------------------------------------
  1070. bool  CRFAPC::REQ_Read_TX_AFC_DAC_offset_From_File_Single_Band( char *filename, int band )
  1071. {
  1072.     TIniFile   *ini_file;
  1073.     ini_file = new TIniFile( filename );
  1074.     if( ini_file == NULL )  return false;
  1075.     // TX AFC DAC offset
  1076.     m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger(SUBBAND_NAME[band],
  1077.                                                                        "TX AFC DAC offset",
  1078.                                                                        0);
  1079.     delete  ini_file;
  1080.     return true;
  1081. }
  1082. //-----------------------------------------------------------------------------
  1083. bool  CRFAPC::REQ_Read_TX_AFC_DAC_offset_From_File( char *filename )
  1084. {
  1085.     TIniFile   *ini_file;
  1086.     int         band;
  1087.     int         total_band_num;
  1088.     ini_file = new TIniFile( filename );
  1089.     if( ini_file == NULL )  return false;
  1090.     if(frmMainSel->cbGSM850->Checked)
  1091.     {   total_band_num = 4;
  1092.     }
  1093.     else
  1094.     {
  1095.         total_band_num = 3;
  1096.     }
  1097.     for (band = 0; band<total_band_num; band++)
  1098.     {
  1099.         // TX AFC DAC offset
  1100.         m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger( SUBBAND_NAME[band],
  1101.                                                                        "TX AFC DAC offset",
  1102.                                                                        0);
  1103.     }
  1104.     return true;
  1105. }
  1106. //-----------------------------------------------------------------------------
  1107. bool  CRFAPC::REQ_Read_APC_From_File_Single_Band(char *filename, unsigned int rf_id, int band, bool b_tapo_support)
  1108. {
  1109.     TIniFile   *ini_file;
  1110.     AnsiString  data;
  1111.     char        ini_section[128];
  1112.     char        str[2048];
  1113.     int         idata[16];
  1114.     unsigned short usdata[MAX_APC_PCL_NUM];
  1115.     float       fdata[16];
  1116.     int         i, pcl;
  1117.     int         total_band_num;
  1118.     ini_file = new TIniFile( filename );
  1119.     if( ini_file == NULL )  return false;
  1120.     m_bTADOSupport = b_tapo_support;
  1121.     m_uiRfModId   = rf_id;
  1122.     data = ini_file->ReadString( SUBBAND_NAME[band],
  1123.                                      "APC dc offset",
  1124.                                      "0");
  1125.     strcpy( str, data.c_str() );
  1126.     String_To_Array_int( str, idata, 1 );
  1127.     m_usHighApcDcOffset[band] = idata[0];
  1128.     if( m_bTADOSupport )
  1129.     {
  1130.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1131.                                      "Low APC dc offset",
  1132.                                      "0");
  1133.         strcpy( str, data.c_str() );
  1134.         String_To_Array_int( str, idata, 1 );
  1135.         m_usLowApcDcOffset[band] = idata[0];
  1136.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1137.                                      "APC lowest power",
  1138.                                      "0");
  1139.         strcpy( str, data.c_str() );
  1140.         String_To_Array_int( str, idata, 1 );
  1141.         m_iApcLowestPower[band] = idata[0];
  1142.     }
  1143.     data = ini_file->ReadString( SUBBAND_NAME[band],
  1144.                                      "TX power level",
  1145.                                      "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  1146.     strcpy(str, data.c_str());
  1147.     String_To_Array_UnsignedShort(str, usdata, MAX_APC_PCL_NUM);
  1148.     for (i=0; i<MAX_APC_PCL_NUM; i++)
  1149.     {
  1150.         m_sApcProfile[band].rampData.power[i] = usdata[i];
  1151.     }
  1152.     for( pcl=0; pcl<16; pcl++)
  1153.     {
  1154.         sprintf( ini_section, "profile %d ramp up", pcl );
  1155.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1156.                                          ini_section,
  1157.                                          "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  1158.         strcpy( str, data.c_str() );
  1159.         String_To_Array_int( str, idata, 16 );
  1160.         for( i=0; i<16; i++ )
  1161.         {
  1162.             m_sApcProfile[band].rampData.ramp[pcl].point[0][i] = idata[i];
  1163.         }
  1164.         sprintf( ini_section, "profile %d ramp down", pcl );
  1165.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1166.                                         ini_section,
  1167.                                         "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  1168.         strcpy( str, data.c_str() );
  1169.         String_To_Array_int( str, idata, 16 );
  1170.         for( i=0; i<16; i++ )
  1171.         {  m_sApcProfile[band].rampData.ramp[pcl].point[1][i] = idata[i];  }
  1172.     }
  1173.     data = ini_file->ReadString( SUBBAND_NAME[band],
  1174.                                      "Subband max arfcn",
  1175.                                      "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1");
  1176.     strcpy( str, data.c_str() );
  1177.     String_To_Array_int( str, idata, 11 );
  1178.     idata[11] = -1;
  1179.     for( i=0; i<12; i++ )
  1180.     {  m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn = idata[i];  }
  1181.     data = ini_file->ReadString( SUBBAND_NAME[band],
  1182.                                      "Subband mid level",
  1183.                                      "0,0,0,0,0,0,0,0,0,0,0");
  1184.     strcpy( str, data.c_str() );
  1185.     String_To_Array_int( str, idata, 11 );
  1186.     idata[11] = 0;
  1187.     for( i=0; i<12; i++ )
  1188.     {   m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = idata[i];  }
  1189.     data = ini_file->ReadString( SUBBAND_NAME[band],
  1190.                                      "Subband high weight",
  1191.                                      "1,1,1,1,1,1,1,1,1,1,1");
  1192.     strcpy( str, data.c_str() );
  1193.     String_To_Array_float( str, fdata, 11 );
  1194.     fdata[11] = 0.0;
  1195.     for( i=0; i<12; i++ )
  1196.     {   m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight = (int)(fdata[i]*WEIGHT_SCALE);  }
  1197.     data = ini_file->ReadString( SUBBAND_NAME[band],
  1198.                                      "Subband low weight",
  1199.                                      "1,1,1,1,1,1,1,1,1,1,1");
  1200.     strcpy( str, data.c_str() );
  1201.     String_To_Array_float( str, fdata, 11 );
  1202.     fdata[11] = 0.0;
  1203.     for( i=0; i<12; i++ )
  1204.     {
  1205.         m_sApcProfile[band].rampData.arfcn_weight[i].low_weight = (int)(fdata[i]*WEIGHT_SCALE);
  1206.     }
  1207.     // battery compensate
  1208.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1209.                                "Battery compensate, low voltage, low temperature",
  1210.                                "1.0"
  1211.                                );
  1212.     m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]
  1213.     = atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1214.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1215.                                 "Battery compensate, low voltage, mid temperature",
  1216.                                 "1.0");
  1217.     m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
  1218.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1219.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1220.                                 "Battery compensate, low voltage, high temperature",
  1221.                                 "1.0");
  1222.     m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
  1223.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1224.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1225.                                 "Battery compensate, mid voltage, low temperature",
  1226.                                 "1.0");
  1227.     m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
  1228.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1229.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1230.                                 "Battery compensate, mid voltage, mid temperature",
  1231.                                 "1.0");
  1232.     m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
  1233.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1234.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1235.                                 "Battery compensate, mid voltage, high temperature",
  1236.                                 "1.0");
  1237.     m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
  1238.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1239.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1240.                                 "Battery compensate, high voltage, low temperature",
  1241.                                 "1.0");
  1242.     m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
  1243.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1244.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1245.                                 "Battery compensate, high voltage, mid temperature",
  1246.                                 "1.0");
  1247.     m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
  1248.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1249.     data = ini_file->ReadString(SUBBAND_NAME[band],
  1250.                                 "Battery compensate, high voltage, high temperature",
  1251.                                 "1.0");
  1252.     m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
  1253.     atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1254.     // TX AFC DAC offset
  1255.     m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger( SUBBAND_NAME[band],
  1256.                                                                        "TX AFC DAC offset",
  1257.                                                                        0);
  1258.     if( band==BANDSEL_GSM900 || band==BANDSEL_GSM850 )
  1259.     {
  1260.         m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  1261.     }
  1262.     delete  ini_file;
  1263.     return true;
  1264. }
  1265. //-----------------------------------------------------------------------------
  1266. bool  CRFAPC::REQ_Read_APC_From_File(char *filename, unsigned int rf_id, bool b_tapo_support)
  1267. {
  1268.     TIniFile   *ini_file;
  1269.     AnsiString  data;
  1270.     char        ini_section[128];
  1271.     char        str[2048];
  1272.     int         idata[16];
  1273.     unsigned short usdata[MAX_APC_PCL_NUM];
  1274.     float       fdata[16];
  1275.     int         i, pcl, band;
  1276.     int         total_band_num;
  1277.     ini_file = new TIniFile( filename );
  1278.     if( ini_file == NULL )  return false;
  1279.     m_bTADOSupport = b_tapo_support;
  1280.     m_uiRfModId   = rf_id;
  1281.     if(frmMainSel->cbGSM850->Checked)
  1282.     {   total_band_num = 4;
  1283.     }
  1284.     else
  1285.     {
  1286.         total_band_num = 3;
  1287.     }
  1288.     for( band = 0; band<total_band_num; band++)
  1289.     {
  1290.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1291.                                      "APC dc offset",
  1292.                                      "0");
  1293.         strcpy( str, data.c_str() );
  1294.         String_To_Array_int( str, idata, 1 );
  1295.         m_usHighApcDcOffset[band] = idata[0];
  1296.         if (m_bTADOSupport)
  1297.         {
  1298.             data = ini_file->ReadString( SUBBAND_NAME[band],
  1299.                                      "Low APC dc offset",
  1300.                                      "0");
  1301.             strcpy( str, data.c_str() );
  1302.             String_To_Array_int( str, idata, 1 );
  1303.             m_usLowApcDcOffset[band] = idata[0];
  1304.             data = ini_file->ReadString( SUBBAND_NAME[band],
  1305.                                      "APC lowest power",
  1306.                                      "0");
  1307.             strcpy( str, data.c_str() );
  1308.             String_To_Array_int( str, idata, 1 );
  1309.             m_iApcLowestPower[band] = idata[0];
  1310.         }
  1311.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1312.                                      "TX power level",
  1313.                                      "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  1314.         strcpy(str, data.c_str());
  1315.         String_To_Array_UnsignedShort(str, usdata, 16);
  1316.         for (i=0; i<MAX_APC_PCL_NUM; i++)
  1317.         {
  1318.             m_sApcProfile[band].rampData.power[i] = usdata[i];
  1319.         }
  1320.         for( pcl=0; pcl<16; pcl++)
  1321.         {
  1322.             sprintf( ini_section, "profile %d ramp up", pcl );
  1323.             data = ini_file->ReadString( SUBBAND_NAME[band],
  1324.                                          ini_section,
  1325.                                          "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  1326.             strcpy( str, data.c_str() );
  1327.             String_To_Array_int( str, idata, 16 );
  1328.             for (i=0; i<16; i++)
  1329.             {
  1330.                 m_sApcProfile[band].rampData.ramp[pcl].point[0][i] = idata[i];
  1331.             }
  1332.             sprintf( ini_section, "profile %d ramp down", pcl );
  1333.             data = ini_file->ReadString( SUBBAND_NAME[band],
  1334.                                         ini_section,
  1335.                                         "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
  1336.             strcpy( str, data.c_str() );
  1337.             String_To_Array_int( str, idata, 16 );
  1338.             for( i=0; i<16; i++ )
  1339.             {  m_sApcProfile[band].rampData.ramp[pcl].point[1][i] = idata[i];  }
  1340.         }
  1341.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1342.                                      "Subband max arfcn",
  1343.                                      "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1");
  1344.         strcpy( str, data.c_str() );
  1345.         String_To_Array_int( str, idata, 11 );
  1346.         idata[11] = -1;
  1347.         for( i=0; i<12; i++ )
  1348.         {  m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn = idata[i];  }
  1349.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1350.                                      "Subband mid level",
  1351.                                      "0,0,0,0,0,0,0,0,0,0,0");
  1352.         strcpy( str, data.c_str() );
  1353.         String_To_Array_int( str, idata, 11 );
  1354.         idata[11] = 0;
  1355.         for( i=0; i<12; i++ )
  1356.         {   m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = idata[i];  }
  1357.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1358.                                      "Subband high weight",
  1359.                                      "1,1,1,1,1,1,1,1,1,1,1");
  1360.         strcpy( str, data.c_str() );
  1361.         String_To_Array_float( str, fdata, 11 );
  1362.         fdata[11] = 0.0;
  1363.         for( i=0; i<12; i++ )
  1364.         {   m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight = (int)(fdata[i]*WEIGHT_SCALE);  }
  1365.         data = ini_file->ReadString( SUBBAND_NAME[band],
  1366.                                      "Subband low weight",
  1367.                                      "1,1,1,1,1,1,1,1,1,1,1");
  1368.         strcpy( str, data.c_str() );
  1369.         String_To_Array_float( str, fdata, 11 );
  1370.         fdata[11] = 0.0;
  1371.         for( i=0; i<12; i++ )
  1372.         {   m_sApcProfile[band].rampData.arfcn_weight[i].low_weight = (int)(fdata[i]*WEIGHT_SCALE);
  1373.         }
  1374.         // battery compensate
  1375.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1376.                                     "Battery compensate, low voltage, low temperature",
  1377.                                     "1.0");
  1378.         m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
  1379.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1380.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1381.                                     "Battery compensate, low voltage, mid temperature",
  1382.                                     "1.0");
  1383.         m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
  1384.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1385.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1386.                                     "Battery compensate, low voltage, high temperature",
  1387.                                     "1.0");
  1388.         m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
  1389.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1390.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1391.                                     "Battery compensate, mid voltage, low temperature",
  1392.                                     "1.0");
  1393.         m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
  1394.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1395.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1396.                                     "Battery compensate, mid voltage, mid temperature",
  1397.                                     "1.0");
  1398.         m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
  1399.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1400.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1401.                                     "Battery compensate, mid voltage, high temperature",
  1402.                                     "1.0");
  1403.         m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
  1404.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1405.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1406.                                     "Battery compensate, high voltage, low temperature",
  1407.                                     "1.0");
  1408.         m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX] =
  1409.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1410.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1411.                                     "Battery compensate, high voltage, mid temperature",
  1412.                                     "1.0");
  1413.         m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX] =
  1414.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1415.         data = ini_file->ReadString(SUBBAND_NAME[band],
  1416.                                     "Battery compensate, high voltage, high temperature",
  1417.                                     "1.0");
  1418.         m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX] =
  1419.         atof(data.c_str()) * BATTERY_COMPENSATE_SCALE;
  1420.         // TX AFC DAC offset
  1421.         m_sApcProfile[band].rampData.tx_afc_offset = ini_file->ReadInteger( SUBBAND_NAME[band],
  1422.                                                                        "TX AFC DAC offset",
  1423.                                                                        0);
  1424.     }
  1425.     delete  ini_file;
  1426.     band = BANDSEL_GSM900;
  1427.     m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  1428.     if( frmMainSel->cbGSM850->Checked )
  1429.     {
  1430.         band = BANDSEL_GSM850;
  1431.         m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  1432.     }    
  1433.     return true;
  1434. }
  1435. //===========================================================================
  1436. bool  CRFAPC::REQ_Write_APC_To_File_Single_Band(char *filename, unsigned int rf_id, int band, bool b_tapo_support)
  1437. {
  1438.     TIniFile   *ini_file;
  1439.     AnsiString  data;
  1440.     char        ini_section[128];
  1441.     char        str[2048];
  1442.     int         idata[MAX_APC_PCL_NUM];
  1443.     float       fdata[MAX_APC_PCL_NUM];
  1444.     unsigned short usdata[MAX_APC_PCL_NUM];
  1445.     unsigned char  ucdata[MAX_APC_PCL_NUM];
  1446.     int         i, pcl;
  1447.     ini_file = new TIniFile(filename);
  1448.     if (NULL == ini_file)
  1449.     {
  1450.         return  false;
  1451.     }
  1452.     m_bTADOSupport = b_tapo_support;
  1453.     m_uiRfModId   = rf_id;
  1454.     usdata[0] = m_usHighApcDcOffset[band];
  1455.     sprintf(str, "%d", usdata[0] );
  1456.     ini_file->WriteString( SUBBAND_NAME[band],
  1457.                                "APC dc offset",
  1458.                                str );
  1459.     if (m_bTADOSupport)
  1460.     {
  1461.         usdata[0] = m_usLowApcDcOffset[band];
  1462.         sprintf(str, "%d", usdata[0] );
  1463.         ini_file->WriteString( SUBBAND_NAME[band],
  1464.                                "Low APC dc offset",
  1465.                                str );
  1466.         usdata[0] = m_iApcLowestPower[band];
  1467.         sprintf(str, "%d", usdata[0] );
  1468.         ini_file->WriteString( SUBBAND_NAME[band],
  1469.                                 "APC lowest power",
  1470.                                str );
  1471.     }
  1472.     if (BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
  1473.     {
  1474.         m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  1475.     }
  1476.     // TX power level
  1477.     for (i=0; i<MAX_APC_PCL_NUM ; i++)
  1478.     {
  1479.         usdata[i] = m_sApcProfile[band].rampData.power[i];
  1480.     }
  1481.     Array_To_String_UnsignedShort(str, usdata, MAX_APC_PCL_NUM , ',');
  1482.     ini_file->WriteString( SUBBAND_NAME[band],
  1483.                                "TX power level",
  1484.                                str );
  1485.     // ramp
  1486.     for (pcl=0; pcl<MAX_APC_PCL_NUM ; pcl++)
  1487.     {
  1488.         for (i=0; i<APC_RAMP_UP_NUM; i++)
  1489.         {
  1490.             ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[0][i];
  1491.         }
  1492.         Array_To_String_UnsignedChar(str, ucdata, APC_RAMP_UP_NUM, ',');
  1493.         sprintf(ini_section, "profile %d ramp up", pcl);
  1494.         ini_file->WriteString( SUBBAND_NAME[band],
  1495.                                    ini_section,
  1496.                                    str);
  1497.         for (i=0; i<APC_RAMP_DN_NUM; i++ )
  1498.         {
  1499.             ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[1][i];
  1500.         }
  1501.         Array_To_String_UnsignedChar(str, ucdata, APC_RAMP_DN_NUM, ',');
  1502.         sprintf( ini_section, "profile %d ramp down", pcl );
  1503.         ini_file->WriteString( SUBBAND_NAME[band],
  1504.                                    ini_section,
  1505.                                    str);
  1506.     }
  1507.     for (i=0; i<ARFCN_SECTION_NUM-1; i++)
  1508.     {
  1509.         idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn;
  1510.     }
  1511.     idata[ARFCN_SECTION_NUM-1] = -1;
  1512.     Array_To_String_int( str, idata, 11, ',' );
  1513.     ini_file->WriteString( SUBBAND_NAME[band],
  1514.                                "Subband max arfcn",
  1515.                                str);
  1516.     for (i=0; i<ARFCN_SECTION_NUM-1; i++)
  1517.     {
  1518.         idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
  1519.     }
  1520.     idata[ARFCN_SECTION_NUM-1] = 0;
  1521.     Array_To_String_int(str, idata, ARFCN_SECTION_NUM-1, ',');
  1522.     ini_file->WriteString( SUBBAND_NAME[band],
  1523.                                "Subband mid level",
  1524.                                str);
  1525.     for (i=0; i<ARFCN_SECTION_NUM-1; i++)
  1526.     {
  1527.         fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight*1.0/WEIGHT_SCALE;
  1528.     }
  1529.     fdata[ARFCN_SECTION_NUM-1] = 0;
  1530.     Array_To_String_float(str, fdata, ARFCN_SECTION_NUM-1, ',');
  1531.     ini_file->WriteString(SUBBAND_NAME[band],
  1532.                                "Subband high weight",
  1533.                                str);
  1534.     for (i=0; i<ARFCN_SECTION_NUM-1; i++)
  1535.     {
  1536.         fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].low_weight*1.0/WEIGHT_SCALE;
  1537.     }
  1538.     fdata[ARFCN_SECTION_NUM-1] = 0;
  1539.     Array_To_String_float( str, fdata, ARFCN_SECTION_NUM-1, ',' );
  1540.     ini_file->WriteString( SUBBAND_NAME[band],
  1541.                              "Subband low weight",
  1542.                              str);
  1543.     // battery compensate
  1544.     ini_file->WriteString( SUBBAND_NAME[band],
  1545.                              "Battery compensate, low voltage, low temperature",
  1546.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1547.     ini_file->WriteString( SUBBAND_NAME[band],
  1548.                              "Battery compensate, low voltage, mid temperature",
  1549.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1550.     ini_file->WriteString( SUBBAND_NAME[band],
  1551.                              "Battery compensate, low voltage, high temperature",
  1552.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1553.     ini_file->WriteString( SUBBAND_NAME[band],
  1554.                              "Battery compensate, mid voltage, low temperature",
  1555.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1556.     ini_file->WriteString( SUBBAND_NAME[band],
  1557.                              "Battery compensate, mid voltage, mid temperature",
  1558.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1559.     ini_file->WriteString( SUBBAND_NAME[band],
  1560.                              "Battery compensate, mid voltage, high temperature",
  1561.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1562.     ini_file->WriteString( SUBBAND_NAME[band],
  1563.                              "Battery compensate, high voltage, low temperature",
  1564.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1565.     ini_file->WriteString( SUBBAND_NAME[band],
  1566.                              "Battery compensate, high voltage, mid temperature",
  1567.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1568.     ini_file->WriteString( SUBBAND_NAME[band],
  1569.                              "Battery compensate, high voltage, high temperature",
  1570.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1571.     ini_file->WriteString( SUBBAND_NAME[band],
  1572.                              "TX AFC DAC offset",
  1573.                              m_sApcProfile[band].rampData.tx_afc_offset);
  1574.     delete  ini_file;
  1575.     return  true;
  1576. }
  1577. //--------------------------------------------------------------------------
  1578. bool  CRFAPC::REQ_Write_APC_To_File(char *filename, unsigned int rf_id, bool b_tapo_support)
  1579. {
  1580.     TIniFile   *ini_file;
  1581.     AnsiString  data;
  1582.     char        ini_section[128];
  1583.     char        str[2048];
  1584.     int         idata[16];
  1585.     unsigned short usdata[MAX_APC_PCL_NUM];
  1586.     unsigned char  ucdata[MAX_APC_PCL_NUM];
  1587.     float       fdata[16];
  1588.     int         i, pcl;
  1589.     int         total_band_num;
  1590.     ini_file = new TIniFile( filename );
  1591.     if( ini_file == NULL )  return  false;
  1592.     m_uiRfModId   = rf_id;
  1593.     m_bTADOSupport = b_tapo_support;
  1594.     m_sApcProfile[BANDSEL_GSM900].rampData.power[15] = m_sApcProfile[BANDSEL_GSM900].rampData.power[14];
  1595.     m_sApcProfile[BANDSEL_GSM850].rampData.power[15] = m_sApcProfile[BANDSEL_GSM850].rampData.power[14];
  1596.     if( frmMainSel->cbGSM850->Checked )
  1597.     {  total_band_num = 4;
  1598.     }
  1599.     else
  1600.     {
  1601.       total_band_num = 3;
  1602.     }
  1603.     for (int band = 0; band<total_band_num; band++)
  1604.     {
  1605.         sprintf(str, "%d", m_usHighApcDcOffset[band] );
  1606.         ini_file->WriteString( SUBBAND_NAME[band],
  1607.                                "APC dc offset",
  1608.                                str );
  1609.         if (m_bTADOSupport)
  1610.         {
  1611.             sprintf(str, "%d", m_usLowApcDcOffset[band] );
  1612.             ini_file->WriteString( SUBBAND_NAME[band],
  1613.                                "Low APC dc offset",
  1614.                                str );
  1615.             sprintf(str, "%d", m_iApcLowestPower[band] );
  1616.             ini_file->WriteString( SUBBAND_NAME[band],
  1617.                                "APC lowest power",
  1618.                                str );
  1619.         }
  1620.         for (i=0; i<MAX_APC_PCL_NUM; i++)
  1621.         {
  1622.             usdata[i] = m_sApcProfile[band].rampData.power[i];
  1623.         }
  1624.         Array_To_String_UnsignedShort(str, usdata, MAX_APC_PCL_NUM, ',');
  1625.         ini_file->WriteString(SUBBAND_NAME[band],
  1626.                                "TX power level",
  1627.                                str );
  1628.         for (pcl=0; pcl<MAX_APC_PCL_NUM; pcl++)
  1629.         {
  1630.             for (i=0; i<APC_RAMP_UP_NUM; i++)
  1631.             {
  1632.                 ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[0][i];
  1633.             }
  1634.             Array_To_String_UnsignedChar(str, ucdata, 16, ',');
  1635.             sprintf(ini_section, "profile %d ramp up", pcl);
  1636.             ini_file->WriteString( SUBBAND_NAME[band],
  1637.                                    ini_section,
  1638.                                    str);
  1639.             for( i=0; i<APC_RAMP_DN_NUM; i++ )
  1640.             {
  1641.                 ucdata[i] = m_sApcProfile[band].rampData.ramp[pcl].point[1][i];
  1642.             }
  1643.             Array_To_String_UnsignedChar(str, ucdata, 16, ',');
  1644.             sprintf(ini_section, "profile %d ramp down", pcl);
  1645.             ini_file->WriteString(SUBBAND_NAME[band],
  1646.                                    ini_section,
  1647.                                    str);
  1648.         }
  1649.         for( i=0; i<11; i++ )
  1650.         {  idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn;  }
  1651.         idata[11] = -1;
  1652.         Array_To_String_int( str, idata, 11, ',' );
  1653.         ini_file->WriteString( SUBBAND_NAME[band],
  1654.                                "Subband max arfcn",
  1655.                                str);
  1656.         for( i=0; i<11; i++ )
  1657.         {  idata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;  }
  1658.         idata[11] = 0;
  1659.         Array_To_String_int( str, idata, 11, ',' );
  1660.         ini_file->WriteString( SUBBAND_NAME[band],
  1661.                                "Subband mid level",
  1662.                                str);
  1663.         for( i=0; i<11; i++ )
  1664.         {   fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight*1.0/WEIGHT_SCALE;  }
  1665.         fdata[11] = 0;
  1666.         Array_To_String_float( str, fdata, 11, ',' );
  1667.         ini_file->WriteString( SUBBAND_NAME[band],
  1668.                                "Subband high weight",
  1669.                                str);
  1670.         for( i=0; i<11; i++ )
  1671.         {   fdata[i] = m_sApcProfile[band].rampData.arfcn_weight[i].low_weight*1.0/WEIGHT_SCALE;  }
  1672.         fdata[11] = 0;
  1673.         Array_To_String_float( str, fdata, 11, ',' );
  1674.         ini_file->WriteString( SUBBAND_NAME[band],
  1675.                              "Subband low weight",
  1676.                              str);
  1677.        // battery compensate
  1678.         ini_file->WriteString( SUBBAND_NAME[band],
  1679.                              "Battery compensate, low voltage, low temperature",
  1680.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0) );
  1681.         ini_file->WriteString( SUBBAND_NAME[band],
  1682.                              "Battery compensate, low voltage, mid temperature",
  1683.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1684.         ini_file->WriteString( SUBBAND_NAME[band],
  1685.                              "Battery compensate, low voltage, high temperature",
  1686.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[LOW_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1687.         ini_file->WriteString( SUBBAND_NAME[band],
  1688.                              "Battery compensate, mid voltage, low temperature",
  1689.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1690.         ini_file->WriteString( SUBBAND_NAME[band],
  1691.                              "Battery compensate, mid voltage, mid temperature",
  1692.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1693.         ini_file->WriteString( SUBBAND_NAME[band],
  1694.                              "Battery compensate, mid voltage, high temperature",
  1695.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[MID_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1696.         ini_file->WriteString( SUBBAND_NAME[band],
  1697.                              "Battery compensate, high voltage, low temperature",
  1698.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][LOW_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1699.         ini_file->WriteString( SUBBAND_NAME[band],
  1700.                              "Battery compensate, high voltage, mid temperature",
  1701.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][MID_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1702.         ini_file->WriteString( SUBBAND_NAME[band],
  1703.                              "Battery compensate, high voltage, high temperature",
  1704.                              Double_To_AnsiString( (long) (m_sApcProfile[band].rampData.battery_compensate[HIGH_VOLTAGE_INDEX][HIGH_TEMPERATURE_INDEX]*1.0/BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ) );
  1705.         ini_file->WriteString( SUBBAND_NAME[band],
  1706.                              "TX AFC DAC offset",
  1707.                              m_sApcProfile[band].rampData.tx_afc_offset);
  1708.     }
  1709.     delete  ini_file;
  1710.     return  true;
  1711. }
  1712. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1713. bool  CRFAPC::REQ_Read_Word3_From_File( char *filename )
  1714. {
  1715.     TIniFile   *ini_file;
  1716.     ini_file = new TIniFile( filename );
  1717.     if( ini_file == NULL )  return  false;
  1718.     b5p_coef.tx.c3mode = ini_file->ReadInteger( SUBBAND_NAME_WORD3, "c3mode",0);
  1719.     b5p_coef.tx.wordC3 = ini_file->ReadInteger( SUBBAND_NAME_WORD3, "WordC3",0);
  1720.     delete  ini_file;
  1721.     return  true;
  1722. }
  1723. //---------------------------------------------------------------------------
  1724. bool  CRFAPC::REQ_Write_Word3_To_File( char *filename )
  1725. {
  1726.     TIniFile   *ini_file;
  1727.     ini_file = new TIniFile( filename );
  1728.     if( ini_file == NULL )  return  false;
  1729.     ini_file->WriteString(SUBBAND_NAME_WORD3, "c3mode", b5p_coef.tx.c3mode );
  1730.     ini_file->WriteString(SUBBAND_NAME_WORD3, "WordC3", b5p_coef.tx.wordC3 );
  1731.     delete  ini_file;
  1732.     return  true;
  1733. }
  1734. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1735. bool  CRFAPC::REQ_Read_Word6s_From_File( char *filename  )
  1736. {
  1737.     TIniFile   *ini_file;
  1738.     ini_file = new TIniFile( filename );
  1739.     if( ini_file == NULL )  return  false;
  1740.     b5p_coef.tx.bvmode = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"bvmode",0);
  1741.     b5p_coef.tx.word6_4_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-4-0",0);
  1742.     b5p_coef.tx.word6_5_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-5-0",0);
  1743.     b5p_coef.tx.word6_6_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-6-0",0);
  1744.     b5p_coef.tx.word6_7_0 = ini_file->ReadInteger( SUBBAND_NAME_WORD6S,"W6-7-0",0);
  1745.     delete  ini_file;
  1746.     return  true;
  1747. }
  1748. //---------------------------------------------------------------------------
  1749. bool  CRFAPC::REQ_Read_W64_From_File( TIniFile   *ini_file )
  1750. {
  1751. #if 0
  1752.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1753.                              "BD",
  1754.                              );
  1755.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1756.                              "AO",
  1757.                              );
  1758.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1759.                              "AS",
  1760.                              );
  1761.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1762.                              "AP",
  1763.                              );
  1764.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1765.                              "KAG",
  1766.                              );
  1767.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1768.                              "KSG",
  1769.                              );
  1770. #endif
  1771.     return true;
  1772. }
  1773. //---------------------------------------------------------------------------
  1774. bool  CRFAPC::REQ_Read_W65_From_File( TIniFile   *ini_file )
  1775. {
  1776. #if 0
  1777.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1778.                              "BD",
  1779.                              );
  1780.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1781.                              "AO",
  1782.                              );
  1783.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1784.                              "AS",
  1785.                              );
  1786.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1787.                              "AP",
  1788.                              );
  1789.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1790.                              "KAD",
  1791.                              );
  1792.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1793.                              "KSD",
  1794.                              );
  1795. #endif
  1796.     return true;
  1797. }
  1798. //---------------------------------------------------------------------------
  1799. bool  CRFAPC::REQ_Read_W66_From_File( TIniFile   *ini_file )
  1800. {
  1801. #if 0
  1802.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1803.                              "BD",
  1804.                              );
  1805.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1806.                              "AO",
  1807.                              );
  1808.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1809.                              "AS",
  1810.                              );
  1811.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1812.                              "AP",
  1813.                              );
  1814.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1815.                              "VRE",
  1816.                              );
  1817.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1818.                              "VOF",
  1819.                              );
  1820.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1821.                              "ARE",
  1822.                              );
  1823.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1824.                              "AOF",
  1825.                              );
  1826. #endif
  1827.     return true;
  1828. }
  1829. //---------------------------------------------------------------------------
  1830. bool  CRFAPC::REQ_Read_W67_From_File( TIniFile   *ini_file )
  1831. {
  1832. #if 0
  1833.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1834.                              "BD",
  1835.                              );
  1836.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1837.                              "AO",
  1838.                              );
  1839.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1840.                              "AS",
  1841.                              );
  1842.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1843.                              "AP",
  1844.                              );
  1845. #endif
  1846.     return true;
  1847. }
  1848. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1849. bool  CRFAPC::REQ_Write_Word6s_To_File( char *filename )
  1850. {
  1851.     TIniFile   *ini_file;
  1852.     ini_file = new TIniFile( filename );
  1853.     if( ini_file == NULL )  return  false;
  1854.     ini_file->WriteString( SUBBAND_NAME_WORD6S,"bvmode",b5p_coef.tx.bvmode);
  1855.     ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-4-0",b5p_coef.tx.word6_4_0);
  1856.     ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-5-0",b5p_coef.tx.word6_5_0);
  1857.     ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-6-0",b5p_coef.tx.word6_6_0);
  1858.     ini_file->WriteString( SUBBAND_NAME_WORD6S,"W6-7-0",b5p_coef.tx.word6_7_0);
  1859.     delete  ini_file;
  1860.     return  true;
  1861. }
  1862. //---------------------------------------------------------------------------
  1863. bool  CRFAPC::REQ_Write_W64_To_File( TIniFile   *ini_file )
  1864. {
  1865. #if 0
  1866.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1867.                              "BD",
  1868.                              );
  1869.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1870.                              "AO",
  1871.                              );
  1872.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1873.                              "AS",
  1874.                              );
  1875.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1876.                              "AP",
  1877.                              );
  1878.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1879.                              "KAG",
  1880.                              );
  1881.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1882.                              "KSG",
  1883.                              );
  1884. #endif
  1885.     return true;
  1886. }
  1887. //---------------------------------------------------------------------------
  1888. bool  CRFAPC::REQ_Write_W65_To_File( TIniFile   *ini_file )
  1889. {
  1890. #if 0
  1891.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1892.                              "BD",
  1893.                              );
  1894.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1895.                              "AO",
  1896.                              );
  1897.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1898.                              "AS",
  1899.                              );
  1900.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1901.                              "AP",
  1902.                              );
  1903.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1904.                              "KAD",
  1905.                              );
  1906.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1907.                              "KSD",
  1908.                              );
  1909. #endif
  1910.     return true;
  1911. }
  1912. //---------------------------------------------------------------------------
  1913. bool  CRFAPC::REQ_Write_W66_To_File( TIniFile   *ini_file )
  1914. {
  1915. #if 0
  1916.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1917.                              "BD",
  1918.                              );
  1919.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1920.                              "AO",
  1921.                              );
  1922.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1923.                              "AS",
  1924.                              );
  1925.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1926.                              "AP",
  1927.                              );
  1928.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1929.                              "VRE",
  1930.                              );
  1931.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1932.                              "VOF",
  1933.                              );
  1934.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1935.                              "ARE",
  1936.                              );
  1937.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1938.                              "AOF",
  1939.                              );
  1940. #endif
  1941.     return true;
  1942. }
  1943. //---------------------------------------------------------------------------
  1944. bool  CRFAPC::REQ_Write_W67_To_File( TIniFile   *ini_file )
  1945. {
  1946. #if 0
  1947.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1948.                              "BD",
  1949.                              );
  1950.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1951.                              "AO",
  1952.                              );
  1953.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1954.                              "AS",
  1955.                              );
  1956.     ini_file->WriteString( SUBBAND_NAME_BV[band],
  1957.                              "AP",
  1958.                              );
  1959.     
  1960. #endif
  1961.     return true;
  1962. }
  1963. //---------------------------------------------------------------------------
  1964. bool  CRFAPC::REQ_Write_To_M12193(char *filename, unsigned int rf_id)
  1965. {
  1966.    FILE *fs;
  1967.    int  arfcn, loss;
  1968.    int  band, profile, i;
  1969.    fs = fopen( filename, "a+t" );
  1970.    if (fs==NULL)  return(false);
  1971.    fprintf( fs, "/*----------------------------------------*/n");
  1972.    fprintf( fs, "/* Calibration data for power ramp        */n");
  1973.    fprintf( fs, "/*----------------------------------------*/n");
  1974.    fprintf( fs, "n");
  1975.    fprintf( fs, "#define  APC_DC_OFFSET   %dn", m_usHighApcDcOffset[0]);
  1976.    for(band=0; band<3; band++)
  1977.    {
  1978.       fprintf( fs, "n");
  1979.       fprintf( fs, "/* %s....................................................................*/n", BAND_NAME2[band] );
  1980.       fprintf( fs, "n");
  1981.       fprintf( fs, "sRAMPDATA  %s_RampData =n", BAND_NAME1[band] );
  1982.       fprintf( fs, "{n");
  1983.       fprintf( fs, "   /*-------------------------------------------------------------------------------------------*/n");
  1984.       fprintf( fs, "   /* lowest power */n");
  1985.       fprintf( fs, "   ((APC_DC_OFFSET)<<8) | %d,n", LOWEST_POWER[band] );
  1986.       fprintf( fs, "   /*-------------------------------------------------------------------------------------------*/n");
  1987.       fprintf( fs, "   /* power level  */n");
  1988.       fprintf( fs, "%s", BAND_PCL_COMMENT[band] );
  1989.       fprintf( fs, "   { ");
  1990.   for(i=0; i<15; i++)  fprintf( fs, "%3d,", m_sApcProfile[band].rampData.power[i] );
  1991.   fprintf( fs, "%3d },n", m_sApcProfile[band].rampData.power[15] );
  1992.       fprintf( fs, "   /*-------------------------------------------------------------------------------------------*/n");
  1993.       fprintf( fs, "   {n");
  1994.       for( profile=0; profile<16; profile++ )
  1995.       {
  1996.          fprintf( fs, "      /* profile %2d : %2d dBm | p00,p01,p02,p03,p04,p05,p06,p07,p08,p09,p10,p11,p12,p13,p14,p15  */n", profile, LOWEST_POWER[band]+2*profile);
  1997.          fprintf( fs, "      {  /* ramp up   */ {  { ");
  1998.  for(i=0; i<15; i++)  fprintf( fs, "%3d,", m_sApcProfile[band].rampData.ramp[profile].point[0][i] );
  1999.  fprintf( fs, "%3d },n", m_sApcProfile[band].rampData.ramp[profile].point[0][15] );
  2000.          fprintf( fs, "         /* ramp down */    { ");
  2001.  for(i=0; i<15; i++)  fprintf( fs, "%3d,", m_sApcProfile[band].rampData.ramp[profile].point[1][i] );
  2002.  fprintf( fs, "%3d }  }n", m_sApcProfile[band].rampData.ramp[profile].point[1][15] );
  2003.          fprintf( fs, "      }, /*-------------------------------------------------------------------------------------*/n");
  2004.       }
  2005.       fprintf( fs, "   },n");
  2006.       fprintf( fs, "   /* ARFCN WEIGHT */n");
  2007.       fprintf( fs, "   {  /* max arfcn , mid_level ,  hi_weight   ,  lo_weight   */n");
  2008.       for(i=0; i<11; i++)
  2009.     {  int  arfcn = m_sApcProfile[band].rampData.arfcn_weight[i].max_arfcn;
  2010.          if( (arfcn<0)||(arfcn>1023) )    break;
  2011.  int  mid_level = PCL2POWER(band, m_sApcProfile[band].rampData.arfcn_weight[i].mid_level);
  2012.  int  hi_weight = m_sApcProfile[band].rampData.arfcn_weight[i].hi_weight;
  2013.  int  lo_weight = m_sApcProfile[band].rampData.arfcn_weight[i].low_weight;
  2014.          fprintf( fs, "      {    %4d    ,    %2d     , WEIGHT(%.3f), WEIGHT(%.3f) },n", arfcn, mid_level, (float)(1.0*hi_weight/WEIGHT_SCALE), (float)(1.0*lo_weight/WEIGHT_SCALE));
  2015.       }
  2016.       fprintf( fs, "      /*------------------------------------------------------*/n");
  2017.       fprintf( fs, "      { TABLE_END }n");
  2018.       fprintf( fs, "   },n");
  2019.       fprintf( fs, "};n");
  2020.       fprintf( fs, "n");
  2021.    }
  2022.    fprintf( fs, "/*..........................................................................*/n");
  2023.    fprintf( fs, "n");
  2024.    fprintf( fs, "sRAMPDATA*  RampData[] =n");
  2025.    fprintf( fs, "{n");
  2026.    fprintf( fs, "   0,                                 /* FrequencyBand400 (not support)  */n");
  2027.    fprintf( fs, "   0,                                 /* FrequencyBand850 (not support)  */n");
  2028.    fprintf( fs, "   &GSM_RampData,                     /* FrequencyBand900                */n");
  2029.    fprintf( fs, "   &DCS_RampData,                     /* FrequencyBand1800               */n");
  2030.    fprintf( fs, "   &PCS_RampData,                     /* FrequencyBand1900               */n");
  2031.    fprintf( fs, "};n");
  2032.    fprintf( fs, "n");
  2033.    fprintf( fs, "#undef  APC_DC_OFFSETn");
  2034.    fclose(fs);
  2035.    return(true);
  2036. }
  2037. //===========================================================================
  2038. void CRFAPC::Req_Rf_SetRampApcLevel(FrequencyBand rf_band, int power_level, int apc_dac)
  2039. {
  2040.     g_bIsRunning = true;
  2041.     RampApcLevelReq.rf_band = rf_band;
  2042.     RampApcLevelReq.power_level = power_level;
  2043.     RampApcLevelReq.apc_dac = apc_dac;
  2044.     META_RESULT MetaResult = META_Rf_SetRampApcLevel_r(m_META_HANDLE_Obj.Get_MainHandle(), &RampApcLevelReq, ::CNF_RfSetRampApcLevl, &RampApcLevelToken, NULL);
  2045.     if(MetaResult!=META_SUCCESS)
  2046.     {  Confirm( METAAPP_FAIL );  return;  }
  2047. }
  2048. //-------------------------------------------------------------------------------------------------
  2049. void __stdcall CRFAPC::CNF_RfSetRampApcLevl(const unsigned char cnf, const short token, void *usrData)
  2050. {
  2051.     if(cnf == false)
  2052.     {  Confirm( METAAPP_FAIL );  return;  }
  2053.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  2054. }
  2055. #if 0
  2056. //----------------------------------------------------------------------------
  2057. bool CRFAPC::Req_SetWord3ToReg( RF_BRIGHT5P_Coef_T &rf_mod_coef )
  2058. {
  2059.     b5p_coef = rf_mod_coef;
  2060.     MetaResult = META_Rf_BRIGHT5P_SetSpecialCoef_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, &b5p_coef);
  2061.     if(MetaResult!=META_SUCCESS)
  2062.     {
  2063.         Confirm( METAAPP_FAIL );
  2064.         return false;
  2065.     }
  2066.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  2067.     return true;
  2068. }
  2069. #endif
  2070. //----------------------------------------------------------------------------
  2071. bool CRFAPC::Req_SetB5PToReg( RF_BRIGHT5P_Coef_T &rf_mod_coef )
  2072. {
  2073.     b5p_coef = rf_mod_coef;
  2074.     META_RESULT MetaResult = META_Rf_BRIGHT5P_SetSpecialCoef_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, &b5p_coef);
  2075.     if(MetaResult!=META_SUCCESS)
  2076.     {
  2077.         Confirm( METAAPP_FAIL );
  2078.         return false;
  2079.     }
  2080.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  2081.     return true;
  2082. }
  2083. //-----------------------------------------------------------------------------
  2084. bool CRFAPC::Set_RenesasCoef( RF_BRIGHT5P_Coef_T &rf_mod_coef )
  2085. {
  2086.     b5p_coef = rf_mod_coef;
  2087.     return true;
  2088. }
  2089. //-----------------------------------------------------------------------------
  2090. bool CRFAPC::Get_RenesasCoef( RF_BRIGHT5P_Coef_T &rf_mod_coef )
  2091. {
  2092.     rf_mod_coef = b5p_coef;
  2093.     return true;
  2094. }
  2095. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2096. bool CRFAPC::Get_BvMode( void )
  2097. {
  2098.     return b5p_coef.tx.bvmode;
  2099. }
  2100. //-----------------------------------------------------------------------------
  2101. void CRFAPC::Set_BvMode( unsigned int bvmode )
  2102. {
  2103.     b5p_coef.tx.bvmode = bvmode;
  2104. }
  2105. //-----------------------------------------------------------------------------
  2106. void CRFAPC::REQ_SetW6sImmediateBSI_Start( unsigned int w6s )
  2107. {
  2108.     W6S = w6s;
  2109.     ActiveMan->SetActiveFunction( ::REQ_SetW6sImmediateBSI );
  2110. }
  2111. //-----------------------------------------------------------------------------
  2112. void CRFAPC::REQ_SetW6sImmediateBSI( void )
  2113. {
  2114.     META_RESULT MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, W6S);
  2115.     if(MetaResult!=META_SUCCESS)
  2116.     {
  2117.         Confirm( METAAPP_FAIL );
  2118.         return;
  2119.     }
  2120.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  2121. }
  2122. //=============================================================================
  2123. bool  CRFAPC::Get_SubBandWeighting(l1cal_rampTable_T  apc_profile, int arfcn, unsigned short pcl, unsigned short &weight)
  2124. {
  2125.     short  max_arfcn;
  2126.     for(int i=0; i<ARFCN_SECTION_NUM; i++ )
  2127.     {
  2128.         max_arfcn = apc_profile.rampData.arfcn_weight[i].max_arfcn;
  2129.         if (max_arfcn == -1)  return false;
  2130.         if (arfcn <= max_arfcn)
  2131.         {
  2132.             if( pcl >= apc_profile.rampData.arfcn_weight[i].mid_level )
  2133.             {
  2134.                 weight = apc_profile.rampData.arfcn_weight[i].low_weight;
  2135.             }
  2136.             else
  2137.             {
  2138.                 weight = apc_profile.rampData.arfcn_weight[i].hi_weight;
  2139.             }
  2140.             break;
  2141.         }
  2142.     }    
  2143.     return true;
  2144. }
  2145. //----------------------------------------------------------------------------
  2146. bool CRFAPC::Get_RightTopRampUpValue(l1cal_rampTable_T  apc_profile, E_BANDSEL band_idx, int pcl_idx, unsigned short &ramp_value)
  2147. {
  2148.     switch (band_idx)
  2149.     {
  2150.         case BANDSEL_GSM850:
  2151.         case BANDSEL_GSM900:
  2152.         case BANDSEL_DCS1800:
  2153.         case BANDSEL_PCS1900:
  2154.         {
  2155.             ramp_value = apc_profile.rampData.ramp[pcl_idx].point[RAMP_UP_INDEX][15];
  2156.         }
  2157.         break;
  2158.         default:
  2159.             return false;
  2160.         
  2161.     }
  2162.     return true;
  2163. }
  2164. //---------------------------------------------------------------------------
  2165. bool  CRFAPC::Get_BatteryCompensate( l1cal_rampTable_T  apc_profile, int voltage_idx, int temp_idx, unsigned short &battery_compensate)
  2166. {
  2167.     if( voltage_idx > 2 || temp_idx > 2 )  return false;
  2168.     battery_compensate = apc_profile.rampData.battery_compensate[voltage_idx][temp_idx];
  2169.     return true;
  2170. }
  2171. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2172. void CRFAPC::REQ_RfSetRampTable_Start(unsigned int rf_id, bool b_tapo_support, int band_idx)
  2173. {
  2174.     rf_apc_ptr = this;
  2175.     g_bIsRunning = true;
  2176.     CurWRBand = band_idx;
  2177.     m_uiRfModId = rf_id;
  2178.     m_bTADOSupport = b_tapo_support;
  2179.     ActiveMan->SetActiveFunction( ::REQ_RfSetRampTable );
  2180. }
  2181. //-------------------------------------------------------------------------
  2182. bool CRFAPC::REQ_RfSetRampTable( void )
  2183. {
  2184.     int  band = CurWRBand;
  2185.     int  idata;
  2186.     META_RESULT  MetaResult;
  2187.     
  2188.     if(BANDSEL_GSM900 == band || BANDSEL_GSM850 == band)
  2189.     {
  2190.         m_sApcProfile[band].rampData.power[15] = m_sApcProfile[band].rampData.power[14];
  2191.     }
  2192.     if( ! m_bTADOSupport )
  2193.     {
  2194.         m_sApcProfile[band].rampData.lowest_power =  ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
  2195.                                                    NVRAM_APC_LOWEST_POWER[band];
  2196.     }
  2197.     else
  2198.     {
  2199.         m_sApcProfile[band].rampData.lowest_power = ((m_usHighApcDcOffset[band]&0x03FF)<<8) |
  2200.                                                  ((m_usLowApcDcOffset[band]&0x03FF)<<18) |
  2201.                                                   m_iApcLowestPower[band];
  2202.     }
  2203.     for(int i=0; i<12; i++ )
  2204.     {
  2205.         idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
  2206.         m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = PCL2POWER(band, idata);
  2207.     }
  2208.     FrequencyBand  freqband = BandIdx_To_FreqBand((E_BANDSEL)CurWRBand);
  2209.    // bool vbias_support = NVRAMMan->Get_VbiasSupport();
  2210.    // if (vbias_support)
  2211.     //{
  2212.     //    MetaResult = META_Rf_SetRampTable_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, freqband, &m_sApcProfile[band]);
  2213.    // }
  2214.    // else
  2215.    // {
  2216.    //     l1cal_rampTable_T ramp_table;
  2217.    //
  2218.    //     ramp_table.rampData.lowest_power = m_sApcProfile[band].rampData.lowest_power;
  2219.    //     for (int i=0; i<MAX_APC_PCL_NUM; i++)
  2220.    //     {
  2221.    //         ramp_table.rampData.power[i] = m_sApcProfile[band].rampData.power[i];
  2222.    //         ramp_table.rampData.ramp[i]  = m_sApcProfile[band].rampData.ramp[i];
  2223.    //     }
  2224.    //
  2225.    //     for (int i=0; i<ARFCN_SECTION_NUM; i++)
  2226.    //     {
  2227.    //         ramp_table.rampData.arfcn_weight[i] = m_sApcProfile[band].rampData.arfcn_weight[i];
  2228.     //    }
  2229.     //
  2230.     //    for (int i=0; i<APC_BATTERY_COMP_NUM; i++)
  2231.     //    {
  2232.     //        for (int j=0; j<APC_BATTERY_COMP_NUM; j++)
  2233.     //        {
  2234.     //            ramp_table.rampData.battery_compensate[i][j] = m_sApcProfile[band].rampData.battery_compensate[i][j];
  2235.      //       }
  2236.      //   }
  2237.      //   ramp_table.rampData.tx_afc_offset = m_sApcProfile[band].rampData.tx_afc_offset;
  2238.         MetaResult = META_Rf_SetRampTable_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, freqband, &m_sApcProfile[band]);
  2239.     //}
  2240.     for (int i=0; i<12; i++)
  2241.     {
  2242.         idata = m_sApcProfile[band].rampData.arfcn_weight[i].mid_level;
  2243.         m_sApcProfile[band].rampData.arfcn_weight[i].mid_level = POWER2PCL(band, idata);
  2244.     }
  2245.     if (MetaResult!=META_SUCCESS)
  2246.     {
  2247.         if (MetaResult!=META_TIMEOUT)
  2248.         {
  2249.             Confirm(METAAPP_FAIL);
  2250.             return false;
  2251.         }
  2252.         else
  2253.         {
  2254.             Confirm(METAAPP_TIMEOUT);
  2255.             return false;
  2256.         }
  2257.     }
  2258.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  2259.     return  true;
  2260. }
  2261. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2262. bool CRFAPC::Get_RealApcDcOffset( bool b_tadosupport, int band_idx, int pcl, int &apc_dc_offset )
  2263. {
  2264.     if( ! b_tadosupport )
  2265.     {
  2266.         apc_dc_offset = m_usHighApcDcOffset[band_idx];
  2267.     }
  2268.     else
  2269.     {
  2270.         int min_dBm;
  2271.         FrequencyBand FreqBand = BandIdx_To_FreqBand((E_BANDSEL) band_idx );
  2272.         if( ! PCL_To_MindBm( FreqBand, pcl, min_dBm ) )   return false;
  2273.         if( min_dBm >= m_iApcLowestPower[band_idx] )
  2274.             apc_dc_offset = m_usHighApcDcOffset[band_idx];
  2275.         else
  2276.             apc_dc_offset = m_usLowApcDcOffset[band_idx];
  2277.     }
  2278.     return true;
  2279. }
  2280. //---------------------------------------------------------------------------
  2281. bool CRFAPC::Set_RealApcDcOffset( bool b_tadosupport, int band_idx, int pcl, int apc_dc_offset )
  2282. {
  2283.     if( ! b_tadosupport )
  2284.     {
  2285.         m_usHighApcDcOffset[band_idx] = apc_dc_offset;
  2286.     }
  2287.     else
  2288.     {
  2289.         int min_dBm;
  2290.         FrequencyBand FreqBand = BandIdx_To_FreqBand((E_BANDSEL) band_idx );
  2291.         if( ! PCL_To_MindBm( FreqBand, pcl, min_dBm ) )   return false;
  2292.         if( min_dBm >= m_iApcLowestPower[band_idx] )
  2293.             m_usHighApcDcOffset[band_idx] = apc_dc_offset;
  2294.         else
  2295.             m_usLowApcDcOffset[band_idx]  = apc_dc_offset;
  2296.     }
  2297.     return true;
  2298. }
  2299. //===========================================================================
  2300. /////////////////////////        Query         //////////////////////////////
  2301. //===========================================================================
  2302. void CRFAPC::Query_RfSetRampTable_Start( bool &RfSetRampTableSupport )
  2303. {
  2304.     rf_apc_ptr = this;
  2305.     g_bIsRunning = true;
  2306.     p_rf_set_ramp_table_support = &RfSetRampTableSupport;
  2307.     Query_RfSetRampTable();
  2308. }
  2309. //-------------------------------------------------------------------------
  2310. bool CRFAPC::Query_RfSetRampTable( void )
  2311. {
  2312.     META_RESULT  MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, "META_Rf_SetRampTable");
  2313.     if(MetaResult!=META_SUCCESS)
  2314.     {
  2315.         *p_rf_set_ramp_table_support = false;
  2316.         if( MetaResult!=META_TIMEOUT )
  2317.         {   Confirm( METAAPP_FAIL );  return false;  }
  2318.         else
  2319.         {   Confirm( METAAPP_TIMEOUT );  return false;  }
  2320.     }
  2321.     *p_rf_set_ramp_table_support = true;
  2322.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  2323.     return  true;
  2324. }
  2325. //--------------------------------------------------------------------------
  2326. void CRFAPC::Query_TwoApcDcOffset_Start( bool &b_two_apc_dc_offset_support )
  2327. {
  2328.     rf_apc_ptr = this;
  2329.     g_bIsRunning = true;
  2330.     pb_TwoApcDcOffsetSupport = &b_two_apc_dc_offset_support;
  2331.     Query_TwoApcDcOffset();
  2332. }
  2333. //-------------------------------------------------------------------------
  2334. bool CRFAPC::Query_TwoApcDcOffset( void )
  2335. {
  2336.     META_RESULT  MetaResult = META_Rf_QueryIfTwoApcDCOffsetSupport_r( m_META_HANDLE_Obj.Get_MainHandle(), 300 );
  2337.     if(MetaResult!=META_SUCCESS)
  2338.     {
  2339.         *pb_TwoApcDcOffsetSupport = false;
  2340.         return false;
  2341.     }
  2342.     *pb_TwoApcDcOffsetSupport = true;
  2343. //    ActiveMan->SetActiveFunction( ::REQ_Finish );
  2344.     return  true;
  2345. }
  2346. #if 0
  2347. //-------------------------------------------------------------------------
  2348. bool CRFAPC::Query_TwoApcDcOffset( void )
  2349. {
  2350.     META_RESULT  MetaResult = META_Rf_QueryIfTwoApcDCOffsetSupport_r( 500 );
  2351.     if(MetaResult!=META_SUCCESS)
  2352.     {
  2353.         *pb_TwoApcDcOffsetSupport = false;
  2354.         if( MetaResult!=META_TIMEOUT )
  2355.         {   Confirm( METAAPP_FAIL );  return false;  }
  2356.         else
  2357.         {   Confirm( METAAPP_TIMEOUT );  return false;  }
  2358.     }
  2359.     *pb_TwoApcDcOffsetSupport = true;
  2360.     ActiveMan->SetActiveFunction( ::REQ_Finish );
  2361.     return  true;
  2362. }
  2363. #endif
  2364. //===========================================================================
  2365. /////////////////////////  Global information  //////////////////////////////
  2366. //===========================================================================
  2367. E_METAAPP_RESULT_T CRFAPC::Get_ConfirmState(void)
  2368. {
  2369.     return  m_eConfirmState;
  2370. }
  2371. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2372. unsigned short CRFAPC::Get_HighApcDcOffset(int band_idx)
  2373. {
  2374.     return m_usHighApcDcOffset[band_idx];
  2375. }
  2376. //---------------------------------------------------------------------------
  2377. void CRFAPC::Set_HighApcDcOffset( int band_idx, unsigned short ApcDcOffset)
  2378. {
  2379.     m_usHighApcDcOffset[band_idx] = ApcDcOffset;
  2380. }
  2381. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2382. unsigned short CRFAPC::Get_LowApcDcOffset(int band_idx)
  2383. {
  2384.     return m_usLowApcDcOffset[band_idx];
  2385. }
  2386. //---------------------------------------------------------------------------
  2387. void CRFAPC::Set_LowApcDcOffset(int band_idx, unsigned short ApcDcOffset)
  2388. {
  2389.     m_usLowApcDcOffset[band_idx] = ApcDcOffset;
  2390. }
  2391. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2392. int  CRFAPC::Get_ApcLowestPower( int band_idx )
  2393. {
  2394.     return  m_iApcLowestPower[band_idx];
  2395. }
  2396. //---------------------------------------------------------------------------
  2397. void CRFAPC::Set_ApcLowestPower( int band_idx, int apc_lowest_power )
  2398. {
  2399.     m_iApcLowestPower[band_idx] = apc_lowest_power;
  2400. }
  2401. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2402. l1cal_rampTable_T* CRFAPC::Get_ApcProfile( int band_idx )
  2403. {
  2404.     return &m_sApcProfile[band_idx];
  2405. }
  2406. //---------------------------------------------------------------------------
  2407. void CRFAPC::Set_ApcProfile(int band_idx, l1cal_rampTable_T apc_profile )
  2408. {
  2409.     m_sApcProfile[band_idx] = apc_profile;
  2410. }
  2411. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2412. unsigned short CRFAPC::Get_ApcProfilePower( int band_idx, int pcl_idx )
  2413. {
  2414.     return  m_sApcProfile[band_idx].rampData.power[pcl_idx];
  2415. }
  2416. //---------------------------------------------------------------------------
  2417. void CRFAPC::Set_ApcProfilePower( int band_idx, int pcl_idx, unsigned short power )
  2418. {
  2419.     m_sApcProfile[band_idx].rampData.power[pcl_idx] = power;
  2420. }
  2421. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2422. short CRFAPC::Get_TxAfcOffset( int band_idx )
  2423. {
  2424.     return  m_sApcProfile[band_idx].rampData.tx_afc_offset;
  2425. }
  2426. //---------------------------------------------------------------------------
  2427. void CRFAPC::Set_TxAfcOffset( int band_idx, short tx_afc_offset )
  2428. {
  2429.     m_sApcProfile[band_idx].rampData.tx_afc_offset = tx_afc_offset;
  2430. }