T_TXPCL_A60111A.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:28k
- /*****************************************************************************
- * 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_A60111A.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * TX PCL calibration for A60111A transceiver 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
- #ifndef _MATH_UTILS_H_
- #include "math_utils.h"
- #endif
- #define MAX_APC_DAC_A60111A 127
- #define APC_DAC_A60111A_1DB_END 29
- //----------------------------------------------------------------------------
- extern CRFAPC* MF_rf_apc_ptr;
- extern CRFAPC8PSK* MF_rf_apc_8psk_ptr;
- //============================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_FullCal_A60111A(void)
- {
- AnsiString as_epsk_tx_pcl;
- short s_pcl_num;
- AnsiString as_epsk_max_p;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_min_p;
- AnsiString as_epsk_c;
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ========== EPSK TX power control level calibration begin ========== n "
- );
- if (m_sMAX_APC_DAC > MAX_APC_DAC_A60111A)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : MAX_APC_DAC is out of range (range: 0~127)"
- );
- return false;
- }
- 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;
- }
- int FIRST_PCL;
- int LAST_PCL;
- 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;
- LAST_PCL = GSM850_LAST_PCL;
- vi_Band = age1960_GSM850_BAND;
- band_index = BANDSEL_GSM850;
- s_arfcn = m_sARFCN_C0_GSM850;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm850_epsk_min_p;
- s_pcl_num = TOTAL_GSM850_PCL_NUM;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- LAST_PCL = GSM900_LAST_PCL;
- vi_Band = age1960_EGSM_BAND;
- band_index = BANDSEL_GSM900;
- s_arfcn = m_sARFCN_C0_GSM;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm900_epsk_min_p;
- s_pcl_num = TOTAL_GSM_PCL_NUM;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- LAST_PCL = DCS1800_LAST_PCL;
- vi_Band = age1960_DCS1800_BAND;
- band_index = BANDSEL_DCS1800;
- s_arfcn = m_sARFCN_C0_DCS;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_min_p = m_as_dcs1800_epsk_min_p;
- s_pcl_num = TOTAL_DCS_PCL_NUM;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- LAST_PCL = PCS1900_LAST_PCL;
- vi_Band = age1960_PCS1900_BAND;
- band_index = BANDSEL_PCS1900;
- s_arfcn = m_sARFCN_C0_PCS;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_min_p = m_as_pcs1900_epsk_min_p;
- s_pcl_num = TOTAL_PCS_PCL_NUM;
- }
- 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;
- }
- unsigned char uc_selectPCS1900 = (FrequencyBand1900 == eFreqBand) ? 1:0;
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, uc_selectPCS1900, 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 = " + IntToStr(uc_selectPCS1900)
- );
- return false;
- }
- 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);
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_Band)
- );
- short s_bch_arfcn = ::Get_SeperateChannel(vi_Band, s_arfcn);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, s_bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(s_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;
- }
- 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 "
- );
- return false;
- }
- double d_wanted_p[TOTAL_PCS_PCL_NUM];
- double d_min_p[TOTAL_PCS_PCL_NUM];
- String_To_Array_double(as_epsk_wanted_p.c_str(), d_wanted_p, s_pcl_num);
- String_To_Array_double(as_epsk_min_p.c_str(), d_min_p, s_pcl_num);
- short s_equ_pcl = LAST_PCL;
- double d_TxPwr[MAX_APC_DAC_A60111A+1];
- double d_target_pwr = 0.0;
- for (int i = m_sMAX_APC_DAC; i>= APC_DAC_A60111A_1DB_END ; i--)
- {
- if (AGILENT_8960 == m_pRct->device_type)
- {
- if (!m_rct_ctrl.RCT_PDTCHMSTargetPower(m_pRct, d_target_pwr))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(s_equ_pcl)
- );
- return false;
- }
- }
- else
- {
- if (i <= 40)
- {
- s_equ_pcl = FIRST_PCL;
- }
- else
- {
- for (int pcl_idx = 0; pcl_idx <= s_pcl_num-1 ; pcl_idx++)
- {
- if (i == m_sMAX_APC_DAC)
- {
- s_equ_pcl = LAST_PCL;
- break;
- }
- //else if (d_TxPwr[i+1] < d_min_p[pcl_idx])
- else if (d_TxPwr[i+1] < d_wanted_p[pcl_idx])
- {
- s_equ_pcl = FIRST_PCL - pcl_idx;
- break;
- }
- }
- }
- if (s_equ_pcl > FIRST_PCL)
- {
- s_equ_pcl = FIRST_PCL;
- }
- if (!m_rct_ctrl.RCT_PDTCHMSTxLevel(m_pRct, s_equ_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_equ_pcl)
- );
- return false;
- }
- }
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- RfSetRampApcLevel_Req RfSetApcDac;
- RfSetApcDac.rf_band = eFreqBand;
- RfSetApcDac.power_level = FIRST_PCL;
- RfSetApcDac.apc_dac = i;
- 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 ok. PCL = " + IntToStr(FIRST_PCL) + "," +
- " APC DAC = " + IntToStr(i)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level, PCL = " + IntToStr(FIRST_PCL) + "," +
- " APC DAC = " + IntToStr(i)
- );
- Sleep(50);
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = FIRST_PCL;
- pcl[1] = pcl[0];
- pcl[2] = pcl[0];
- pcl[3] = pcl[0];
- 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;
- }
- log->Add (DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< TX: ARFCN = " + IntToStr(s_arfcn) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", PCL = " + IntToStr(pcl[0]) +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- 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 (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal(WM_MF_AGE8960_READ_TX_POWER_FAIL);
- if (!m_rct_ctrl.RCT_ReadTxPower_EPSK(m_pRct, d_TxPwr[i]))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL: " + m_pRct->as_RCT + " > read TX power"
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- m_pRct->as_RCT + " > read TX power = " + Double_To_AnsiString(d_TxPwr[i]) + "n"
- );
- d_target_pwr = d_TxPwr[i];
- }
- for (short pcl_idx = 0; pcl_idx < s_pcl_num; pcl_idx++)
- {
- for (int i = APC_DAC_A60111A_1DB_END; i <= m_sMAX_APC_DAC; i++)
- {
- if (m_sMAX_APC_DAC == i)
- {
- if (d_TxPwr[i] <= d_wanted_p[pcl_idx])
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, pcl_idx, i);
- break;
- }
- }
- else if ((d_TxPwr[i] <= d_wanted_p[pcl_idx]) && (d_wanted_p[pcl_idx] <= d_TxPwr[i+1]))
- {
- double d_diff1 = Abs_double(d_TxPwr[i] - d_wanted_p[pcl_idx]);
- double d_diff2 = Abs_double(d_TxPwr[i+1] - d_wanted_p[pcl_idx]);
- if (d_diff1 < d_diff2)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, pcl_idx, i);
- }
- else
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, pcl_idx, i+1);
- }
- break;
- }
- }
- }
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Write to NVRAM band_index = " + IntToStr(band_index)
- );
- RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- CHECK_TERMINATE_BY_USER
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< write EPSK APC to NVRAM "
- );
- }
- return false;
- }
- WriteEpskAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand));
- eFreqBand++;
- } // 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_EvalDac_A60111A_EPSK(void)
- {
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_correction;
- short s_pcl_num;
- E_BANDSEL band_index;
- FrequencyBand eFreqBand = FrequencyBand850;
- i_N_TX = -99; // TX frames
- //---------------------------------------------------------------------------
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM850;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_correction = m_as_gsm850_epsk_correction;
- s_pcl_num = TOTAL_GSM850_PCL_NUM;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM900;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_correction = m_as_gsm900_epsk_correction;
- s_pcl_num = TOTAL_GSM_PCL_NUM;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_DCS1800;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_correction = m_as_dcs1800_epsk_correction;
- s_pcl_num = TOTAL_DCS_PCL_NUM;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_PCS1900;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_correction = m_as_dcs1800_epsk_correction;
- s_pcl_num = TOTAL_PCS_PCL_NUM;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- double d_wanted_p[TOTAL_PCS_PCL_NUM];
- double d_correction[TOTAL_PCS_PCL_NUM];
- String_To_Array_double(as_epsk_wanted_p.c_str(), d_wanted_p, s_pcl_num);
- String_To_Array_double(as_epsk_correction.c_str(), d_correction, s_pcl_num);
- double d_gain_db[MAX_APC_DAC_A60111A+1] =
- {
- 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, // 0~9
- 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, // 10~19
- 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, // 20~29
- 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, // 30~39
- 7.0, 7.0, 8.0, 8.0, 9.0, 9.0, 10.0, 10.0, 11.0, 11.0, // 40~49
- 12.0, 12.0, 13.0, 13.5, 14.0, 14.5, 15.0, 15.5, 16.0, 16.5, // 50~59
- 17.0, 17.5, 18.0, 18.5, 19.0, 19.0, 20.0, 20.5, 21.0, 21.5, // 60~69
- 22.0, 22.5, 23.0, 23.5, 24.0, 24.5, 25.0, 25.5, 26.0, 26.5, // 70~79
- 27.0, 27.5, 28.0, 28.5, 29.0, 29.5, 30.0, 30.5, 31.0, 31.5, // 80~89
- 32.0, 32.5, 33.0, 33.5, 34.0, 34.5, 35.0, 35.5, 36.0, 36.5, // 90~99
- 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, // 100~109
- 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, // 110~119
- 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0, 37.0 // 120~127
- };
- for (short pcl_idx = 0; pcl_idx < s_pcl_num-1; pcl_idx++)
- {
- double d_p_diff = m_dPCL_dBm_EPSK[band_index][0] - (d_wanted_p[pcl_idx] + d_correction[pcl_idx]);
- //d_p_diff += (d_p_diff>=0) ? 0.5 : -0.5 ;
- // short s_p_diff = (short) d_p_diff;
- for (short i = m_usPCLDacValue_EPSK[band_index][0]; i >= 29; i--)
- {
- if (Abs_double(d_gain_db[m_usPCLDacValue_EPSK[band_index][0]] - d_gain_db[i] - d_p_diff) <= 0.5)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, pcl_idx, i);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PCLDacValue_EPSK[" + IntToStr(band_index) + "][" + IntToStr(pcl_idx) + "] = " + IntToStr(i)
- );
- break;
- }
- }
- //short s_eval_dac = m_usPCLDacValue_EPSK[band_index][0] + s_p_diff;
- }
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Write to NVRAM band_index = " + IntToStr(band_index)
- );
- RestartTimerCal(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- CHECK_TERMINATE_BY_USER
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_EPSK_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< write EPSK APC to NVRAM "
- );
- }
- return false;
- }
- WriteEpskAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand));
- eFreqBand++;
- } // while(eFreqBand)
- return true;
- }