T_TXPCL_common.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:268k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * T_TXPCL_common.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * TX PCL calibration common source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include <assert.h>
- #include <math.h>
- #pragma hdrstop
- #ifndef _T_META_FACTORY_CALIBRATION_H_
- #include "T_META_factory_calibration.H"
- #endif
- #ifndef _APCCAL_COMMON_H_
- #include "apccal_common.h"
- #endif
- #ifndef _RF_APC_H_
- #include "rf_apc.h"
- #endif
- // callback
- #ifndef _META_FACTORY_RF_CB_H_
- #include "meta_factory_rf_cb.h"
- #endif
- #ifndef _META_FACTORY_NVRAM_CB_H_
- #include "meta_factory_nvram_cb.h"
- #endif
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.h"
- #endif
- // equipment
- #ifndef _AGECOMMON_H_
- #include "agecommon.h"
- #endif
- #ifndef _AGE1968A_H_
- #include "age1968a.h"
- #endif
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- //----------------------------------------------------------------------------
- // equipment
- extern CMU_VAR cmu;
- extern CRFAPC* MF_rf_apc_ptr;
- extern RfNbtx_Req *MF_rf_tx_level_req;
- extern bool MF_rf_tx_level_cnf;
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- //============================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_2cal(void)
- {
- int FIRST_PCL=0;
- AnsiString as_tx_pcl;
- AnsiString as_tx_2cal_pcl;
- AnsiString as_sub_tx_2cal_pcl;
- AnsiString as_max_p;
- AnsiString as_wanted_p;
- AnsiString as_min_p;
- AnsiString as_c;
- AnsiString as_sub_tx_pcl;
- AnsiString as_sub_max_p;
- AnsiString as_sub_wanted_p;
- AnsiString as_sub_min_p;
- AnsiString as_sub_c;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============ GMSK TX power control level calibration begin ============ n "
- );
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_GSM_BCH_TCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GSM BCH+TCH"
- );
- return false;
- }
- }
- else
- {
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_GPRS_BCH_PDTCH) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GPRS BCH+PDTCH"
- );
- return false;
- }
- }
- short s_ARFCN;
- FrequencyBand eFreqBand = FrequencyBand850;
- i_N_TX = 2000; // TX frames
- //---------------------------------------------------------------------------
- while (eFreqBand < FrequencyBandCount)
- {
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM850_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_tx_2cal_pcl = m_as_gsm850_tx_2cal_pcl;
- as_tx_pcl = m_as_gsm850_tx_pcl;
- as_max_p = m_as_gsm850_max_p;
- as_wanted_p = m_as_gsm850_wanted_p;
- as_min_p = m_as_gsm850_min_p;
- as_c = m_as_gsm850_c;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_tx_2cal_pcl = m_as_gsm900_tx_2cal_pcl;
- as_tx_pcl = m_as_gsm900_tx_pcl;
- as_max_p = m_as_gsm900_max_p;
- as_wanted_p = m_as_gsm900_wanted_p;
- as_min_p = m_as_gsm900_min_p;
- as_c = m_as_gsm900_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_tx_2cal_pcl = m_as_dcs1800_tx_2cal_pcl;
- as_tx_pcl = m_as_dcs1800_tx_pcl;
- as_max_p = m_as_dcs1800_max_p;
- as_wanted_p = m_as_dcs1800_wanted_p;
- as_min_p = m_as_dcs1800_min_p;
- as_c = m_as_dcs1800_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_tx_2cal_pcl = m_as_pcs1900_tx_2cal_pcl;
- as_tx_pcl = m_as_pcs1900_tx_pcl;
- as_max_p = m_as_pcs1900_max_p;
- as_wanted_p = m_as_pcs1900_wanted_p;
- as_min_p = m_as_pcs1900_min_p;
- as_c = m_as_pcs1900_c;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- E_BANDSEL band_index = FreqBand_To_BandIdx(eFreqBand);
- int vi_Band = FreqBand_To_AgeBand(eFreqBand);
-
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_ptr->ApcSectionExist(m_pCal->as_IniFile.c_str(), band_index))
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " APC section is not in initial file: " + FreqBand_To_Str(eFreqBand)
- );
- return false;
- }
- if (IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- if(eFreqBand == FrequencyBand1900)
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 1"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- return false;
- }
- Sleep( 100 ); // wait Agilent 8960 cell band setup ready!
- // if Agilent 8960 not read, target will get error power!
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- short bch_arfcn = ::Get_SeperateChannel( vi_Band, s_ARFCN );
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- if( ! m_rct_ctrl.RCT_TCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr( s_ARFCN )
- );
- return false;
- }
- }
- else
- {
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
- );
- return false;
- }
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr( s_ARFCN )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
- );
- }
- // ----------------------- set Agilent 8960 < TSC -------------------------
- if( ! m_rct_ctrl.RCT_ConfigTSC( m_pRct, m_cTSC ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TSC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 8= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- if (!m_rct_ctrl.RCT_Config_ExpectedTxPower(m_pRct, true, 0))
- {
- RestartTimerCal(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < config expected TX power to auto fail"
- );
- return false;
- }
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- if( ! m_rct_ctrl.RCT_confTXPower( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power ."
- );
- return false;
- }
- }
- else
- {
- if( ! m_rct_ctrl.RCT_confMultiSlotTxPower( m_pRct, AGE1960_TX_POWER_MEASURE_COUNT, MOD_GMSK ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- }
- if( ! m_rct_ctrl.RCT_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // calibration from high power to low power
- // index from big to little.
- // PCL string in config file from right to left.
- int iRealRecursiveTimes = 0;
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- for ( int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ------------------------------------------------------------------ "
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " N = " + N
- );
- if (! getAnsiStrSubItem( as_tx_2cal_pcl, N+1, DEFAULT_SEP_CHAR, as_sub_tx_2cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl)."
- );
- return false;
- }
- for( iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes;
- iRealRecursiveTimes++) // marked by Andy Ueng for no iteration test
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " RecursiveTimes = " + IntToStr(iRealRecursiveTimes)
- );
- if( 0 == iRealRecursiveTimes )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " band_index = " + IntToStr(band_index) + "," +
- // " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()) + "," +
- " MF_rf_apc_ptr->ApcProfile[" + IntToStr(band_index) + "].rampData.power[" +
- IntToStr(FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()) + "] = " +
- // IntToStr(MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()])
- IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() ) )
- );
- // not support GSM400
- // m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()];
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " band_index = " + IntToStr(band_index) + "," +
- // " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue[" +IntToStr(band_index) + "][" + IntToStr(N) + "] = " +
- IntToStr(m_usPCLDacValue[band_index][N])
- );
- }
- // index start from 1
- if (! getAnsiStrSubItem( as_tx_pcl, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl 2)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_max_p, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_max_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_min_p, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_min_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_wanted_p, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_c, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_c) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(c)."
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( ! m_rct_ctrl.RCT_MSTXLevel( m_pRct, as_sub_tx_pcl.ToInt()) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : cmu200 > MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Agilent 8960< MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU200 < MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- RestartTimerCal( WM_MF_RF_STOP_FAIL );
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- MF_rf_tx_level_req->arfcn = s_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = as_sub_tx_pcl.ToInt();
- MF_rf_tx_level_req->frames = i_N_TX;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC; // NB burst
- if ( META_Rf_NB_TX_r( m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- MF_rf_tx_level_cb,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr( s_ARFCN ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- #ifdef _MYDEBUG_
- ":" + AnsiString( ms ) +
- #endif
- " Target< TX: ARFCN = " + IntToStr( s_ARFCN ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before suspend " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 7= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- RestartTimerCal( WM_MF_RF_TX_LEVEL_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after resume " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (! MF_rf_tx_level_cnf )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : ! MF_rf_tx_level_cnf"
- );
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- RestartTimerCal( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_ReadTxPower( m_pRct, m_virTX ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< read TX power 1."
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : CMU 200< read TX power 1."
- );
- }
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm[band_index][N] = m_virTX ;
- m_dPCL_power[band_index][N] = pow(10.0, m_dPCL_dBm[band_index][N]/10.0)/1000.0;
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Agilent 8960< read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU 200< read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- }
- signed short ss1;
- double d1;
- if (iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( m_virTX > (atof(as_sub_wanted_p.c_str())+ m_dAPC_Delta) ||
- m_virTX < (atof(as_sub_wanted_p.c_str())- m_dAPC_Delta))
- {
- d1 = atof(as_sub_c.c_str()) * (atof(as_sub_wanted_p.c_str()) - m_virTX );
- // modified by Andy Ueng for always increment 1
- // ss1 = (signed short) (d1>0) ? floor(d1+0.5): ceil(d1-0.5); // to round up or down
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- unsigned short us_org_apc_dac = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() );
- unsigned short us_new_apc_dac;
- if ((us_org_apc_dac + ss1) <= MIN_APC_DAC )
- {
- us_new_apc_dac = 1;
- //MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt(), 1 );
- }
- else if ((us_org_apc_dac + ss1) > MAX_APC_DAC)
- {
- us_new_apc_dac = MAX_APC_DAC;
- //MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt(), MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() )+ss1 );
- }
- else
- {
- us_new_apc_dac = us_org_apc_dac + ss1;
- }
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt(), us_new_apc_dac );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()) + "," +
- " MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(us_new_apc_dac )
- );
- // m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()];
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- //" band_index = " + IntToStr(band_index) + "," +
- //" N = " + IntToStr(N) + "," +
- " m_usPCLDacValue[" + IntToStr(band_index) +"][" + IntToStr(N) +"] = " +
- IntToStr(m_usPCLDacValue[band_index][N])
- );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // // " MF_rf_apc_ptr->ApcDcOffset[band_index] = " + IntToStr(MF_rf_apc_ptr->ApcDcOffset[band_index])
- // " MF_rf_apc_ptr->HighApcDcOffset[band_index] = " + IntToStr(MF_rf_apc_ptr->Get_HighApcDcOffset(band_index))
- // );
- //m_dV_set[band_index][N] = (MF_rf_apc_ptr->ApcDcOffset[band_index] + m_usPCLDacValue[band_index][N]) / 1024.0 * 2.8 * 15.0 / 25.0; // added by Andy Ueng
- //log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " band_index = " + IntToStr(band_index) + "," +
- // " N = " + IntToStr(N) + "," +
- // " m_dV_set[band_index][N] = " + Double_To_AnsiString(m_dV_set[band_index][N])
- // );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- // AnsiString( MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()] )
- AnsiString( MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- MF_rf_apc_ptr->ConfirmCallback = ccb_set_apc_level;
- // MF_rf_apc_ptr->Req_Rf_SetRampApcLevel(eFreqBand, as_sub_tx_2cal_pcl.ToInt(), MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()]);
- MF_rf_apc_ptr->Req_Rf_SetRampApcLevel(eFreqBand, as_sub_tx_2cal_pcl.ToInt(), MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() ));
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_SET_APC_DAC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 9= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_SET_APC_DAC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_sub_tx_2cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() )) + "n"
- );
- return false;
- }
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_sub_tx_2cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt() )) + "n"
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0 "
- );
- break; // for iRealRecursiveTimes
- }
- } // if no iteration
- else if( iRealRecursiveTimes == i_TXlevelRecusiveTimes-1 )
- {
- double d_max_p = atof(as_sub_max_p.c_str());
- double d_min_p = atof(as_sub_min_p.c_str());
- if ( m_virTX > d_max_p || m_virTX < d_min_p )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Out of Range ), min TX power = " + Double_To_AnsiString( d_min_p ) + ", max TX power = " + Double_To_AnsiString( d_max_p )
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Pass ), min TX power = " + Double_To_AnsiString( d_min_p ) + ", max TX power = " + Double_To_AnsiString( d_max_p )
- );
- }
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- } // for N
- } // single slot
- else // multi-slot
- {
- unsigned int ui_tx_2cal_pcl[RF_TX_LEVEL_2_CAL_COUNT];
- double d_max_p[RF_TX_LEVEL_2_CAL_COUNT];
- double d_min_p[RF_TX_LEVEL_2_CAL_COUNT];
- double d_wanted_p[RF_TX_LEVEL_2_CAL_COUNT];
- S_MULTISLOT_BURST_POWER virTX_p;
- unsigned int ui_c[RF_TX_LEVEL_2_CAL_COUNT];
- unsigned short us_apc_dac[RF_TX_LEVEL_2_CAL_COUNT];
- for( int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- if (! getAnsiStrSubItem( as_tx_2cal_pcl, N+1, DEFAULT_SEP_CHAR, as_sub_tx_2cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl)."
- );
- return false;
- }
- ui_tx_2cal_pcl[N] = as_sub_tx_2cal_pcl.ToInt();
- if (! getAnsiStrSubItem( as_max_p, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_max_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p)."
- );
- return false;
- }
- d_max_p[N] = atof(as_sub_max_p.c_str());
- if (! getAnsiStrSubItem( as_min_p, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_min_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p)."
- );
- return false;
- }
- d_min_p[N] = atof(as_sub_min_p.c_str());
- if (! getAnsiStrSubItem( as_wanted_p, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- d_wanted_p[N] = atof(as_sub_wanted_p.c_str());
- if (! getAnsiStrSubItem( as_c, FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_c) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(c)."
- );
- return false;
- }
- ui_c[N] = as_sub_c.ToInt();
- } // for(N)
- for( iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes;
- iRealRecursiveTimes++) // marked by Andy Ueng for no iteration test
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " RecursiveTimes = " + IntToStr(iRealRecursiveTimes)
- );
- if( 0 == iRealRecursiveTimes )
- {
- m_usPCLDacValue[band_index][0] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[0] );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" +IntToStr(band_index) + "][" + IntToStr(0) + "] = " +
- IntToStr(m_usPCLDacValue[band_index][0])
- );
- }
- RestartTimerCal( WM_MF_RF_STOP_FAIL );
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- pcl[0] = ui_tx_2cal_pcl[0];
- pcl[1] = ui_tx_2cal_pcl[1];
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = s_ARFCN;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x03;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = NB_TX_RANDOM_WITH_TSC;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_RF_TX_LEVEL_FAIL );
- SUSPEND_CAL_THREAD
- if( RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_readMultiSlotAverageTxPower( m_pRct, &virTX_p ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < read multislot TX power ."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- for ( int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- m_dPCL_dBm[band_index][N] = virTX_p.d_burstpower[N] ;
- m_dPCL_power[band_index][N] = pow(10.0, m_dPCL_dBm[band_index][N]/10.0)/1000.0;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read slot " + IntToStr(N) + " TX power = " + Double_To_AnsiString( virTX_p.d_burstpower[N] )
- );
- signed short ss1;
- double d1;
- if (iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( virTX_p.d_burstpower[N] > (d_wanted_p[N]+ m_dAPC_Delta) ||
- virTX_p.d_burstpower[N] < (d_wanted_p[N]- m_dAPC_Delta))
- {
- d1 = ui_c[N] * ( d_wanted_p[N] - virTX_p.d_burstpower[N] );
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- unsigned short us_org_apc_dac = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N] );
- unsigned short us_new_apc_dac;
- if ( (us_org_apc_dac + ss1) <= 0 )
- {
- us_new_apc_dac = 1;
- //MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N], 1 );
- }
- else if ( (us_org_apc_dac + ss1) > MAX_APC_DAC )
- {
- us_new_apc_dac = MAX_APC_DAC;
- //MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N], MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N] )+ss1 );
- }
- else
- {
- us_new_apc_dac = us_org_apc_dac + ss1;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()) + "," +
- " MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr( us_new_apc_dac )
- );
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N] );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" + IntToStr(band_index) +"][" + IntToStr(N) +"] = " +
- IntToStr(m_usPCLDacValue[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- AnsiString( MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N] ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- MF_rf_apc_ptr->ConfirmCallback = ccb_set_apc_level;
- MF_rf_apc_ptr->Req_Rf_SetRampApcLevel(eFreqBand, ui_tx_2cal_pcl[N], MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N] ));
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_SET_APC_DAC_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 9= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler( WM_MF_SET_APC_DAC_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_sub_tx_2cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N] )) + "n"
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_sub_tx_2cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_2cal_pcl[N] )) + "n"
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0 "
- );
- break; // for iRealRecursiveTimes
- }
- } // if no iteration
- else if( iRealRecursiveTimes == i_TXlevelRecusiveTimes-1 )
- {
- if( virTX_p.d_burstpower[N] > d_max_p[N] || virTX_p.d_burstpower[N] < d_min_p[N] )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " > read TX power = "+ Double_To_AnsiString( virTX_p.d_burstpower[N] ) +
- " ( Out of Range ), min TX power = " + Double_To_AnsiString( d_min_p[N] ) + ", max TX power = " + Double_To_AnsiString( d_max_p[N] )
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " > read TX power = "+ Double_To_AnsiString( virTX_p.d_burstpower[N] ) +
- " ( Pass ), min TX power = " + Double_To_AnsiString( d_min_p[N] ) + ", max TX power = " + Double_To_AnsiString( d_max_p[N] )
- );
- }
- }
- } // for(N)
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for(iRealRecursiveTimes)
- } // multi-slot
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- // Sleep( i_N_TX*4.615);
- if( ! m_rct_ctrl.RCT_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< set continuous TX power OFF "
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : cmu200 < set continuous TX power OFF "
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
-
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============= TX power control level calibration end ============= n "
- );
- RestartTimerCal(WM_MF_RF_TX_LEVEL_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============= GMSK TX power control level calibration end ============= n "
- );
-
- if( m_asAPC_Check.AnsiCompareIC("yes") != 0 )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_LEVEL_CALIBRATION_DONE_NO_CHECK,
- 0,
- 0
- );
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " "+ CurrentTimeStr() +
- " TX PCL calibration done (without TX PCL check procedure)! n"
- );
- }
-
- return true;
- }
- //=========================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_3cal(void)
- {
- AnsiString as_tx_pcl;
- AnsiString as_tx_cal_pcl;
- AnsiString as_max_p;
- AnsiString as_wanted_p;
- AnsiString as_min_p;
- AnsiString as_c;
- AnsiString as_sub_tx_pcl;
- AnsiString as_sub_tx_cal_pcl;
- AnsiString as_sub_max_p;
- AnsiString as_sub_wanted_p;
- AnsiString as_sub_min_p;
- AnsiString as_sub_c;
- int FIRST_PCL=0;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============ GMSK TX power control level calibration begin ============ n "
- );
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_GSM_BCH_TCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GSM BCH+TCH"
- );
- return false;
- }
- }
- else
- {
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_GPRS_BCH_PDTCH) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GPRS BCH+PDTCH"
- );
- return false;
- }
- }
- short s_ARFCN;
- FrequencyBand eFreqBand = FrequencyBand850;
- i_N_TX = -99; // TX frames
- //---------------------------------------------------------------------------
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM850_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_tx_cal_pcl = m_as_gsm850_tx_cal_pcl;
- as_tx_pcl = m_as_gsm850_tx_pcl;
- as_max_p = m_as_gsm850_max_p;
- as_wanted_p = m_as_gsm850_wanted_p;
- as_min_p = m_as_gsm850_min_p;
- as_c = m_as_gsm850_c;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_tx_cal_pcl = m_as_gsm900_tx_cal_pcl;
- as_tx_pcl = m_as_gsm900_tx_pcl;
- as_max_p = m_as_gsm900_max_p;
- as_wanted_p = m_as_gsm900_wanted_p;
- as_min_p = m_as_gsm900_min_p;
- as_c = m_as_gsm900_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_tx_cal_pcl = m_as_dcs1800_tx_cal_pcl;
- as_tx_pcl = m_as_dcs1800_tx_pcl;
- as_max_p = m_as_dcs1800_max_p;
- as_wanted_p = m_as_dcs1800_wanted_p;
- as_min_p = m_as_dcs1800_min_p;
- as_c = m_as_dcs1800_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_tx_cal_pcl = m_as_pcs1900_tx_cal_pcl;
- as_tx_pcl = m_as_pcs1900_tx_pcl;
- as_max_p = m_as_pcs1900_max_p;
- as_wanted_p = m_as_pcs1900_wanted_p;
- as_min_p = m_as_pcs1900_min_p;
- as_c = m_as_pcs1900_c;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- E_BANDSEL band_index = FreqBand_To_BandIdx(eFreqBand);
- int vi_Band = FreqBand_To_AgeBand(eFreqBand);
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_ptr->ApcSectionExist(m_pCal->as_IniFile.c_str(), band_index))
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " APC section is not in initial file: " + FreqBand_To_Str(eFreqBand)
- );
- return false;
- }
- if (IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- if( FrequencyBand1900 == eFreqBand )
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < target < set Band1900 flag = 1"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- return false;
- }
- #ifdef _MYDEBUG_
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Sleep 100 " + AnsiString(__FILE__)
- );
- #endif
- Sleep( 100 ); // wait Agilent 8960 cell band setup ready!
- // if Agilent 8960 not read, target will get error power!
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- short bch_arfcn = ::Get_SeperateChannel( vi_Band, s_ARFCN );
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " +
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- if( ! m_rct_ctrl.RCT_TCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr( s_ARFCN )
- );
- return false;
- }
- }
- else
- {
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
- );
- return false;
- }
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr( s_ARFCN )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_ARFCN )
- );
- }
- if( ! m_rct_ctrl.RCT_ConfigTSC( m_pRct, m_cTSC ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TSC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 8= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- if (!m_rct_ctrl.RCT_Config_ExpectedTxPower(m_pRct, true, 0))
- {
- RestartTimerCal(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < config expected TX power to auto fail"
- );
- return false;
- }
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- if( ! m_rct_ctrl.RCT_confTXPower( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- }
- else
- {
- if( ! m_rct_ctrl.RCT_confMultiSlotTxPower( m_pRct, AGE1960_TX_POWER_MEASURE_COUNT, MOD_GMSK ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- }
- if( ! m_rct_ctrl.RCT_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // calibration from high power to low power
- // index from big to little.
- // PCL string in config file from right to left.
- int iRealRecursiveTimes = 0;
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- for ( int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ------------------------------------------------------------------ "
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " N = " + N
- );
- if (! getAnsiStrSubItem( as_tx_cal_pcl, N+1, DEFAULT_SEP_CHAR, as_sub_tx_cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl)."
- );
- return false;
- }
- for( iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes;
- iRealRecursiveTimes++) // marked by Andy Ueng for no iteration test
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " RecursiveTimes = " + IntToStr(iRealRecursiveTimes)
- );
- if( 0 == iRealRecursiveTimes )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_cal_pcl.ToInt()) + "," +
- " MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() ))
- );
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue[band_index][N] = " + IntToStr(m_usPCLDacValue[band_index][N])
- );
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_sub_tx_cal_pcl.ToInt(), m_iApcDcOffset ) )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Get APC DC offset " +
- " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
- " eFreqBand = " + IntToStr( eFreqBand ) +
- " pcl = " + as_sub_tx_cal_pcl
- );
- return false;
- }
- m_dV_set[band_index][N] = (m_iApcDcOffset + m_usPCLDacValue[band_index][N]) / 1024.0 * 2.8 * 15.0 / 25.0;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_dV_set[band_index][N] = " + Double_To_AnsiString(m_dV_set[band_index][N])
- );
- }
- // index start from 1
- if (! getAnsiStrSubItem( as_tx_pcl, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl 2)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_max_p, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_max_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p)."
- );
- return false;
- }
- if (! getAnsiStrSubItem( as_min_p, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_min_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_wanted_p, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_c, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_c) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(c)."
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_MSTXLevel( m_pRct, as_sub_tx_pcl.ToInt()) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : cmu200 > MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Agilent 8960< MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU200 < MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_RF_TX_LEVEL_FAIL );
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- MF_rf_tx_level_req->arfcn = s_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = as_sub_tx_pcl.ToInt();
- MF_rf_tx_level_req->frames = i_N_TX;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC; // NB burst
- if ( META_Rf_NB_TX_r( m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- MF_rf_tx_level_cb,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr( s_ARFCN ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- #ifdef _MYDEBUG_
- ":" + AnsiString( ms ) +
- #endif
- " Target< TX: ARFCN = " + IntToStr( s_ARFCN ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before suspend " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 7= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- RestartTimerCal( WM_MF_RF_TX_LEVEL_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after resume " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (! MF_rf_tx_level_cnf )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : ! MF_rf_tx_level_cnf"
- );
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- RestartTimerCal( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_ReadTxPower( m_pRct, m_virTX ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< read TX power 1."
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : CMU 200< read TX power 1."
- );
- }
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm[band_index][N] = m_virTX ;
- m_dPCL_power[band_index][N] = pow(10.0, m_dPCL_dBm[band_index][N]/10.0)/1000.0;
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Agilent 8960< read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU 200< read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- signed short ss1;
- double d1;
- if (iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( m_virTX > (atof(as_sub_wanted_p.c_str())+ m_dAPC_Delta) ||
- m_virTX < (atof(as_sub_wanted_p.c_str())- m_dAPC_Delta))
- {
- d1 = atof(as_sub_c.c_str()) * (atof(as_sub_wanted_p.c_str()) - m_virTX );
- // modified by Andy Ueng for always increment 1
- // ss1 = (signed short) (d1>0) ? floor(d1+0.5): ceil(d1-0.5); // to round up or down
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- if ((MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()) + ss1) <= 0 )
- {
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt(), 1 );
- }
- else if ((MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() ) + ss1) > MAX_APC_DAC)
- {
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt(), MAX_APC_DAC);
- }
- else
- {
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt(), MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()) + ss1 );
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_cal_pcl.ToInt()) + "," +
- " MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()))
- );
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue[band_index][N] = " + IntToStr(m_usPCLDacValue[band_index][N])
- );
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_sub_tx_cal_pcl.ToInt(), m_iApcDcOffset ) )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Get APC DC offset " +
- " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
- " eFreqBand = " + IntToStr( eFreqBand ) +
- " pcl = " + as_sub_tx_cal_pcl
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " MF_rf_apc_ptr->ApcDcOffset[band_index] = " + IntToStr(m_iApcDcOffset)
- );
- m_dV_set[band_index][N] = (m_iApcDcOffset + m_usPCLDacValue[band_index][N]) / 1024.0 * 2.8 * 15.0 / 25.0;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_dV_set[band_index][N] = " + Double_To_AnsiString(m_dV_set[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- IntToStr( MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- MF_rf_apc_ptr->ConfirmCallback = ::ccb_set_apc_level;
- MF_rf_apc_ptr->Req_Rf_SetRampApcLevel(eFreqBand, as_sub_tx_cal_pcl.ToInt(), MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() ) );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_SET_APC_DAC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 9= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {