T_TXPCL_EPSK_common.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:180k
源码类别:
MTK
开发平台:
C++ Builder
- /*****************************************************************************
- * 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) 2001
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * T_TXPCL_EPSK_common.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * TX PCL EPSK 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 CRFAPC8PSK* MF_rf_apc_8psk_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_EPSK_1cal(void)
- {
- int FIRST_PCL;
- AnsiString as_epsk_tx_pcl;
- short s_epsk_tx_1cal_pcl;
- AnsiString as_epsk_max_p;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_min_p;
- AnsiString as_epsk_c;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_max_p;
- AnsiString as_epsk_sub_wanted_p;
- AnsiString as_epsk_sub_min_p;
- AnsiString as_epsk_sub_c;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ========== EPSK TX power control level calibration begin ========== n "
- );
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < Operation mode = EGPRS BCH+PDTCH"
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_Config_EPSK_CodingScheme( m_pRct, MCS5 ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_CODING_SCHEME_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Coding scheme = MCS5"
- );
- return false;
- }
- short s_arfcn;
- E_BANDSEL band_index;
- int vi_Band;
- 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;
- vi_Band = age1960_GSM850_BAND;
- band_index = BANDSEL_GSM850;
- s_arfcn = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_1_CAL_COUNT;
- s_epsk_tx_1cal_pcl = m_s_gsm850_epsk_tx_1cal_pcl;
- as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm850_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm850_epsk_min_p;
- as_epsk_c = m_as_gsm850_epsk_c;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- vi_Band = age1960_EGSM_BAND;
- band_index = BANDSEL_GSM900;
- s_arfcn = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_1_CAL_COUNT;
- s_epsk_tx_1cal_pcl = m_s_gsm900_epsk_tx_1cal_pcl;
- as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm900_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm900_epsk_min_p;
- as_epsk_c = m_as_gsm900_epsk_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- vi_Band = age1960_DCS1800_BAND;
- band_index = BANDSEL_DCS1800;
- s_arfcn = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_1_CAL_COUNT;
- s_epsk_tx_1cal_pcl = m_s_dcs1800_epsk_tx_1cal_pcl;
- as_epsk_tx_pcl = m_as_dcs1800_epsk_tx_pcl;
- as_epsk_max_p = m_as_dcs1800_epsk_max_p;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_min_p = m_as_dcs1800_epsk_min_p;
- as_epsk_c = m_as_dcs1800_epsk_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- vi_Band = age1960_PCS1900_BAND;
- band_index = BANDSEL_PCS1900;
- s_arfcn = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_1_CAL_COUNT;
- s_epsk_tx_1cal_pcl = m_s_pcs1900_epsk_tx_1cal_pcl;
- as_epsk_tx_pcl = m_as_pcs1900_epsk_tx_pcl;
- as_epsk_max_p = m_as_pcs1900_epsk_max_p;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_min_p = m_as_pcs1900_epsk_min_p;
- as_epsk_c = m_as_pcs1900_epsk_c;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_8psk_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 < 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_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_arfcn ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_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;
- }
- 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;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if( ! m_rct_ctrl.RCT_EPSK_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;
- }
- //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_confTXPower_EPSK( 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;
- }
- // 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
- );
- 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( iRealRecursiveTimes == 0)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " MF_rf_apc_8psk_ptr->ApcProfile[" + IntToStr(band_index) + "].rampData.power[" +
- IntToStr(FIRST_PCL-s_epsk_tx_1cal_pcl) + "] = " +
- IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-s_epsk_tx_1cal_pcl) )
- );
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-s_epsk_tx_1cal_pcl);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue_EPSK[" +IntToStr(band_index) + "][" + IntToStr(N) + "] = " +
- IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- }
- if(! getAnsiStrSubItem( as_epsk_max_p, FIRST_PCL-s_epsk_tx_1cal_pcl+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_min_p, FIRST_PCL-s_epsk_tx_1cal_pcl+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_wanted_p, FIRST_PCL-s_epsk_tx_1cal_pcl+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_c, FIRST_PCL-s_epsk_tx_1cal_pcl+1, DEFAULT_SEP_CHAR, as_epsk_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_PDTCHMSTxLevel(m_pRct, s_epsk_tx_1cal_pcl))
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(s_epsk_tx_1cal_pcl)
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr(s_epsk_tx_1cal_pcl)
- );
- 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;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = s_epsk_tx_1cal_pcl;
- pcl[1] = s_epsk_tx_1cal_pcl;
- pcl[2] = s_epsk_tx_1cal_pcl;
- pcl[3] = s_epsk_tx_1cal_pcl;
- 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 = 0x01;
- 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;
- }
- #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_epsk_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 );
- 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;
- }
- #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;
- }
- #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_EPSK( m_pRct, m_virTX) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < read TX power 1."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm_EPSK[band_index][N] = m_virTX ;
- m_dPCL_power_EPSK[band_index][N] = pow(10.0, m_dPCL_dBm_EPSK[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;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- signed short ss1;
- double d1;
- if(iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( m_virTX > (atof(as_epsk_sub_wanted_p.c_str()) + m_dAPC_Delta) ||
- m_virTX < (atof(as_epsk_sub_wanted_p.c_str()) - m_dAPC_Delta))
- {
- d1 = atof(as_epsk_sub_c.c_str()) * (atof(as_epsk_sub_wanted_p.c_str()) - m_virTX );
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl) + ss1) <= 0 )
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl, 1);
- }
- else if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl) + ss1) > MAX_APC_DAC)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl, MAX_APC_DAC);
- }
- else
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, FIRST_PCL - s_epsk_tx_1cal_pcl, MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl) + ss1);
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL - s_epsk_tx_1cal_pcl) + "," +
- " MF_rf_apc_8psk_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl))
- );
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue_EPSK[" + IntToStr(band_index) +"][" + IntToStr(N) +"] = " +
- IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = " +
- AnsiString( MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl))
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- RfSetRampApcLevel_Req RfSetApcDac;
- RfSetApcDac.rf_band = eFreqBand;
- RfSetApcDac.power_level = s_epsk_tx_1cal_pcl;
- RfSetApcDac.apc_dac = MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl);
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_set_apc_level;
- MF_rf_apc_8psk_ptr->REQ_EPSK_SetRampApcLevel_Start( &RfSetApcDac );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal(WM_MF_SET_APC_DAC_FAIL);
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_SET_APC_DAC_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = " + IntToStr(s_epsk_tx_1cal_pcl) +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl)) + "n"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ IntToStr(s_epsk_tx_1cal_pcl) + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL - s_epsk_tx_1cal_pcl)) + "n"
- );
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0 "
- );
- break; // for iRealRecursiveTimes
- }
- } // if no iteration
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- } // for N
- } // single slot TX
- else // multi-slot TX
- {
- }
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " =========== EPSK TX power control level calibration end =========== n "
- );
- 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;
- }
- frmFatcory->DisableAllCalTimer();
- return true;
- }
- //============================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_2cal(void)
- {
- int FIRST_PCL=0;
- AnsiString as_epsk_tx_pcl;
- AnsiString as_epsk_tx_2cal_pcl;
- AnsiString as_epsk_sub_tx_2cal_pcl;
- AnsiString as_epsk_max_p;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_min_p;
- AnsiString as_epsk_c;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_max_p;
- AnsiString as_epsk_sub_wanted_p;
- AnsiString as_epsk_sub_min_p;
- AnsiString as_epsk_sub_c;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ========== EPSK TX power control level calibration begin ========== n "
- );
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_pRct->as_RCT + " < Operation mode = EGPRS BCH+PDTCH"
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_Config_EPSK_CodingScheme( m_pRct, MCS5 ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_CODING_SCHEME_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Coding scheme = MCS5"
- );
- return false;
- }
- short s_arfcn;
- E_BANDSEL band_index;
- int vi_Band;
- 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;
- vi_Band = age1960_GSM850_BAND;
- band_index = BANDSEL_GSM850;
- s_arfcn = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_epsk_tx_2cal_pcl = m_as_gsm850_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm850_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm850_epsk_min_p;
- as_epsk_c = m_as_gsm850_epsk_c;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- vi_Band = age1960_EGSM_BAND;
- band_index = BANDSEL_GSM900;
- s_arfcn = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_epsk_tx_2cal_pcl = m_as_gsm900_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm900_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm900_epsk_min_p;
- as_epsk_c = m_as_gsm900_epsk_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- vi_Band = age1960_DCS1800_BAND;
- band_index = BANDSEL_DCS1800;
- s_arfcn = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_epsk_tx_2cal_pcl = m_as_dcs1800_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_dcs1800_epsk_tx_pcl;
- as_epsk_max_p = m_as_dcs1800_epsk_max_p;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_min_p = m_as_dcs1800_epsk_min_p;
- as_epsk_c = m_as_dcs1800_epsk_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- vi_Band = age1960_PCS1900_BAND;
- band_index = BANDSEL_PCS1900;
- s_arfcn = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_2_CAL_COUNT;
- as_epsk_tx_2cal_pcl = m_as_pcs1900_epsk_tx_2cal_pcl;
- as_epsk_tx_pcl = m_as_pcs1900_epsk_tx_pcl;
- as_epsk_max_p = m_as_pcs1900_epsk_max_p;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_min_p = m_as_pcs1900_epsk_min_p;
- as_epsk_c = m_as_pcs1900_epsk_c;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_8psk_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 < 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_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_arfcn ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_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;
- }
- 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;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if( ! m_rct_ctrl.RCT_EPSK_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;
- }
- //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_confTXPower_EPSK( 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;
- }
- // 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_epsk_tx_2cal_pcl, N+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_2cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(epsk_sub_tx_2cal_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( iRealRecursiveTimes == 0)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " band_index = " + IntToStr(band_index) + "," +
- // " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()) + "," +
- " MF_rf_apc_8psk_ptr->ApcProfile[" + IntToStr(band_index) + "].rampData.power[" +
- IntToStr(FIRST_PCL-as_epsk_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_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() ) )
- );
- // not support GSM400
- // PCLDacValue[band_index][N] = MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_2cal_pcl.ToInt()];
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " band_index = " + IntToStr(band_index) + "," +
- // " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue_EPSK[" +IntToStr(band_index) + "][" + IntToStr(N) + "] = " +
- IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- }
- // index start from 1
- if(! getAnsiStrSubItem( as_epsk_tx_pcl, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_max_p, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_min_p, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_wanted_p, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_c, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_PDTCHMSTxLevel( m_pRct, as_epsk_sub_tx_pcl.ToInt()) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_pcl.ToInt())
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_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;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = as_epsk_sub_tx_pcl.ToInt();
- pcl[1] = as_epsk_sub_tx_pcl.ToInt();
- pcl[2] = as_epsk_sub_tx_pcl.ToInt();
- pcl[3] = as_epsk_sub_tx_pcl.ToInt();
- 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 = 0x01;
- 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;
- }
- #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_epsk_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 );
- 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;
- }
- #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;
- }
- #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_EPSK( m_pRct, m_virTX) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < read TX power 1."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm_EPSK[band_index][N] = m_virTX ;
- m_dPCL_power_EPSK[band_index][N] = pow(10.0, m_dPCL_dBm_EPSK[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;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- signed short ss1;
- double d1;
- if(iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( m_virTX > (atof(as_epsk_sub_wanted_p.c_str()) + m_dAPC_Delta) ||
- m_virTX < (atof(as_epsk_sub_wanted_p.c_str()) - m_dAPC_Delta))
- {
- d1 = atof(as_epsk_sub_c.c_str()) * (atof(as_epsk_sub_wanted_p.c_str()) - m_virTX );
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() ) + ss1) <= 0 )
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt(), 1);
- }
- else if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt()) + ss1) > MAX_APC_DAC)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt(), MAX_APC_DAC);
- }
- else
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt(), MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() )+ss1 );
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt()) + "," +
- " MF_rf_apc_8psk_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() ) )
- );
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue_EPSK[" + IntToStr(band_index) +"][" + IntToStr(N) +"] = " +
- IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = " +
- AnsiString( MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- RfSetRampApcLevel_Req RfSetApcDac;
- RfSetApcDac.rf_band = eFreqBand;
- RfSetApcDac.power_level = as_epsk_sub_tx_2cal_pcl.ToInt();
- RfSetApcDac.apc_dac = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() );
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_set_apc_level;
- MF_rf_apc_8psk_ptr->REQ_EPSK_SetRampApcLevel_Start( &RfSetApcDac );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_SET_APC_DAC_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_SET_APC_DAC_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_epsk_sub_tx_2cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_2cal_pcl.ToInt() )) + "n"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_epsk_sub_tx_2cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_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
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- } // for N
- } // single slot TX
- else // multi-slot TX
- {
- }
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " =========== EPSK TX power control level calibration end =========== n "
- );
- 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;
- }
- frmFatcory->DisableAllCalTimer();
- return true;
- }
- //=========================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_3cal(void)
- {
- AnsiString as_epsk_tx_pcl;
- AnsiString as_epsk_tx_cal_pcl;
- AnsiString as_epsk_max_p;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_min_p;
- AnsiString as_epsk_c;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_tx_cal_pcl;
- AnsiString as_epsk_sub_max_p;
- AnsiString as_epsk_sub_wanted_p;
- AnsiString as_epsk_sub_min_p;
- AnsiString as_epsk_sub_c;
- int FIRST_PCL=0;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ========== EPSK TX power control level calibration begin ========== n "
- );
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = EGPRS BCH+PDTCH"
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_Config_EPSK_CodingScheme( m_pRct, MCS5 ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_CODING_SCHEME_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Coding scheme = MCS5"
- );
- return false;
- }
- short s_arfcn;
- E_BANDSEL band_index;
- int vi_Band;
- 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;
- vi_Band = age1960_GSM850_BAND;
- band_index = BANDSEL_GSM850;
- s_arfcn = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_gsm850_epsk_tx_cal_pcl;
- as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm850_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm850_epsk_min_p;
- as_epsk_c = m_as_gsm850_epsk_c;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- vi_Band = age1960_EGSM_BAND;
- band_index = BANDSEL_GSM900;
- s_arfcn = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_gsm900_epsk_tx_cal_pcl;
- as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm900_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm900_epsk_min_p;
- as_epsk_c = m_as_gsm900_epsk_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- vi_Band = age1960_DCS1800_BAND;
- band_index = BANDSEL_DCS1800;
- s_arfcn = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_dcs1800_epsk_tx_cal_pcl;
- as_epsk_tx_pcl = m_as_dcs1800_epsk_tx_pcl;
- as_epsk_max_p = m_as_dcs1800_epsk_max_p;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_min_p = m_as_dcs1800_epsk_min_p;
- as_epsk_c = m_as_dcs1800_epsk_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- vi_Band = age1960_PCS1900_BAND;
- band_index = BANDSEL_PCS1900;
- s_arfcn = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_3_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_pcs1900_epsk_tx_cal_pcl;
- as_epsk_tx_pcl = m_as_pcs1900_epsk_tx_pcl;
- as_epsk_max_p = m_as_pcs1900_epsk_max_p;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_min_p = m_as_pcs1900_epsk_min_p;
- as_epsk_c = m_as_pcs1900_epsk_c;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_8psk_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 < 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_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_arfcn ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_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;
- }
- 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;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if( ! m_rct_ctrl.RCT_EPSK_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;
- }
- // 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_confTXPower_EPSK( 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;
- }
- // 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_epsk_tx_cal_pcl, N+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(epsk_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( iRealRecursiveTimes == 0)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + "," +
- " MF_rf_apc_8psk_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() ))
- );
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue_EPSK[band_index][N] = " + IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_epsk_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_epsk_sub_tx_cal_pcl
- );
- return false;
- }
- m_dV_set_EPSK[band_index][N] = (m_iApcDcOffset + m_usPCLDacValue_EPSK[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_EPSK[band_index][N] = " + Double_To_AnsiString(m_dV_set_EPSK[band_index][N])
- );
- }
- if(! getAnsiStrSubItem( as_epsk_tx_pcl, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_max_p, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_min_p, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_wanted_p, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_epsk_c, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_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_PDTCHMSTxLevel( m_pRct, as_epsk_sub_tx_pcl.ToInt()) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_pcl.ToInt())
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_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;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = as_epsk_sub_tx_pcl.ToInt();
- pcl[1] = as_epsk_sub_tx_pcl.ToInt();
- pcl[2] = as_epsk_sub_tx_pcl.ToInt();
- pcl[3] = as_epsk_sub_tx_pcl.ToInt();
- 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 = 0x01;
- 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;
- }
- #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_epsk_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #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 );
- 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;
- }
- #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;
- }
- #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_EPSK( m_pRct, m_virTX ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < read TX power 1."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm_EPSK[band_index][N] = m_virTX ;
- m_dPCL_power_EPSK[band_index][N] = pow(10.0, m_dPCL_dBm_EPSK[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;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- signed short ss1;
- double d1;
- if(iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( m_virTX > (atof(as_epsk_sub_wanted_p.c_str()) + m_dAPC_Delta) ||
- m_virTX < (atof(as_epsk_sub_wanted_p.c_str()) - m_dAPC_Delta))
- {
- d1 = atof(as_epsk_sub_c.c_str()) * (atof(as_epsk_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);
- // end of modified
- // MF_rf_level_ramp_struct.rampData[eFreqBand].power[N] += ss1;
- // MF_rf_apc_ptr->ApcProfile[band_index].rampData[0].power[N] += ss1;
- // if( MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_cal_pcl.ToInt()] + ss1 <= 0 )
- if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + ss1) <= 0)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt(), 1 );
- }
- else if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + ss1) > MAX_APC_DAC)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt(), MAX_APC_DAC);
- }
- else
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt(), MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + ss1 );
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + "," +
- " MF_rf_apc_8psk_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()))
- );
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue_EPSK[band_index][N] = " + IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_epsk_sub_tx_cal_pcl.ToInt(), m_iApcDcOffset ) )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +