T_IP2_MT6139.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:133k
- vi_Band = age1960_GSM850_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM850;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_EGSM_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_DCS1800_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_DCS;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_PCS1900_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_PCS;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ---------------------------------------------- "
- );
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Band = " + ViBand_To_Str( vi_Band )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 > Band = " + ViBand_To_Str( vi_Band )
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- if( ! m_rct_ctrl.RCT_ContModTran( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Set continuous tranmittion mode "
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200< Set continuous tranmittion mode "
- );
- }
- 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_PM_SELECT_BAND_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_PM_SELECT_BAND_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_BCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- i_IP2_AMCODEI[0]=i_IP2_AMCODEI1;
- i_IP2_AMCODEI[1]=i_IP2_AMCODEI2;
- i_IP2_AMCODEQ[0]=i_IP2_AMCODEQ1;
- i_IP2_AMCODEQ[1]=i_IP2_AMCODEQ2;
- for( int i=0; i<2; i++)
- {
- //===========================================================
- // 1.0 SS power off
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CAL_P_DL_OFF_MT ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- // if( frmFatcory->cbAFC->Checked || frmFatcory->cbRxPathLoss->Checked )
- // {
- // Sleep( 100 ); // wait Agilent 8960 ready!
- // }
- // else
- {
- Sleep( 200 ); // wait Agilent 8960 ready!
- }
- //-------------------------------------------------------------
- // 1.1 set AM, rxamcalmode=0
- uc_mt6139_coef.rx.coef[eFreqBand].amcodeI = i_IP2_AMCODEI[i];
- uc_mt6139_coef.rx.coef[eFreqBand].amcodeQ = i_IP2_AMCODEQ[i];
- uc_mt6139_coef.rx.rxamcalmode = RXAMCALMODE_MT6139C_READ_ACODE;
- MF_rf_pm_ptr->Set_ucMT6139Coef( uc_mt6139_coef );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Set amcodeI = " + IntToStr( i_IP2_AMCODEI[i] ) +
- ", amcodeQ = " + IntToStr( i_IP2_AMCODEQ[i] ) +
- ", rxamcalmode=0"
- );
- // write AM to NVRAM
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_IP2_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_pm_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RFSPECIALCOEF_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_IP2_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write amcodeI, amcodeQ, rxamcalmode=0 to NVRAM fail."
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write amcodeI, amcodeQ, rxamcalmode=0 to NVRAM."
- );
- //------------------------------------------------------------
- // 1.2 set gain
- // PM
- // if Agilent 8960 not read, target will get error power!
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- // EvalDC_I_sky[i] = MF_rf_pm_cnf->extra_info.iOffset;
- // EvalDC_Q_sky[i] = MF_rf_pm_cnf->extra_info.qOffset;
- //--------------------------------------------------------------
- // 1.3 read A code
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_GetAcodeFromReg;
- MF_rf_pm_ptr->Get_AcodeFromReg_Start( eFreqBand, uc_mt6139_coef, m_pCal->ui_rf_id );
- CHECK_TERMINATE_BY_USER
- RestartTimerCal( WM_MF_RF_IP2_GET_ACODE_FAIL );
- SUSPEND_CAL_THREAD
- // if (MF_rf_pm_ptr->ConfirmState != METAAPP_SUCCESS)
- if (MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_IP2_GET_ACODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target> get acode from register."
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target> get acode from register:" +
- " acodeI = " + IntToStr( uc_mt6139_coef.rx.coef[eFreqBand].acodeI ) +
- ", acodeQ = " + IntToStr( uc_mt6139_coef.rx.coef[eFreqBand].acodeQ )
- );
- //------------------------------------------------------------
- // 1.4 set stand-by mode(010)
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_SetMT6139CW2ToReg;
- MF_rf_pm_ptr->Set_MT6139CW2ToReg_Start( MODE_MT6139_CW2_STAND_BY, m_pCal->ui_rf_id );
- CHECK_TERMINATE_BY_USER
- RestartTimerCal( WM_MF_RF_IP2_SET_CW2_FAIL );
- SUSPEND_CAL_THREAD
- if (MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_IP2_SET_CW2_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set CW2 to register."
- );
- return false;
- }
- //===============================================================
- // 3.1 set rxamcalmode=1, set gain
- uc_mt6139_coef.rx.rxamcalmode = RXAMCALMODE_MT6139C_HOLD_BCCODE;
- MF_rf_pm_ptr->Set_ucMT6139Coef( uc_mt6139_coef );
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_IP2_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- state = MF_rf_pm_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RFSPECIALCOEF_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_IP2_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write rxamcalmode=1 to NVRAM fail."
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write rxamcalmode=1 to NVRAM."
- );
- // 3.2 get MDC1 from DSP
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- // if( !MF_rf_pm_cnf->ok || !MF_rf_pm_cnf->extra_info.valid )
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Fail: Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- EvalMDC1_I_mt6139[i] = MF_rf_pm_cnf->extra_info.iOffset;
- EvalMDC1_Q_mt6139[i] = MF_rf_pm_cnf->extra_info.qOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > " +
- ", MDC1_I = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", MDC1_Q = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset)
- );
- //================================================================
- // 4.0 SS power on
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CAL_P_DL_ON_MT ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_MT) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_MT) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_MT) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_ON_MT) ) + " dBm";
- }
- // if( frmFatcory->cbAFC->Checked || frmFatcory->cbRxPathLoss->Checked )
- // {
- // Sleep( 100 ); // wait Agilent 8960 ready!
- // }
- // else
- {
- Sleep( 200 ); // wait Agilent 8960 ready!
- }
- //--------------------------------------------------------
- // 4.1 get MDC2 from DSP
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok || !MF_rf_pm_cnf->extra_info.valid )
- {
- CalErrorHandler( WM_MF_RF_IP2_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- EvalMDC2_I_mt6139[i] = MF_rf_pm_cnf->extra_info.iOffset;
- EvalMDC2_Q_mt6139[i] = MF_rf_pm_cnf->extra_info.qOffset;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > " +
- ", MDC2_I = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", MDC2_Q = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset)
- );
-
- } // for
- //============================== Evaluate =======================
- // 1.0 SS power off
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CAL_P_DL_OFF_MT ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CAL_P_DL_OFF_MT) ) + " dBm";
- }
- int c0_I = i_IP2_AMCODEI[0];
- int c0_Q = i_IP2_AMCODEQ[0];
- int c1_I = i_IP2_AMCODEI[1];
- int c1_Q = i_IP2_AMCODEQ[1];
- int f0_I = EvalMDC2_I_mt6139[0]-EvalMDC1_I_mt6139[0];
- int f1_I = EvalMDC2_I_mt6139[1]-EvalMDC1_I_mt6139[1];
- int f0_Q = EvalMDC2_Q_mt6139[0]-EvalMDC1_Q_mt6139[0];
- int f1_Q = EvalMDC2_Q_mt6139[1]-EvalMDC1_Q_mt6139[1];
- unsigned char amcode_I;
- unsigned char amcode_Q;
- if( (c1_I - c0_I) == 0 && (c1_Q - c0_Q)==0 ) return false;
- // display evaluate error
- if( (c1_I - c0_I) != 0 )
- {
- float slope_I = 1.0*(f1_I - f0_I) / (c1_I - c0_I);
- float offset_I = f0_I - slope_I*c0_I;
- /// offset_I =
- if( slope_I != 0 )
- {
- if( (-1.0*offset_I/slope_I) < 0 )
- {
- amcode_I = 0;
- }
- else if( (-1.0*offset_I/slope_I) > 255 )
- {
- amcode_I = 255;
- }
- else
- {
- amcode_I = -1.0*offset_I/slope_I;
- }
- // amcode_I = c0_I - f0_I/slope_I;
- }
- }
- if( (c1_Q - c0_Q) != 0 )
- {
- float slope_Q = 1.0*(f1_Q - f0_Q) / (c1_Q - c0_Q);
- float offset_Q = f0_Q - slope_Q*c0_Q;
- if( slope_Q != 0 )
- {
- // amcode_Q = - offset_Q/slope_Q;
- if( (-1.0*offset_Q/slope_Q) < 0 )
- {
- amcode_Q = 0;
- }
- else if( ( -1.0*offset_Q/slope_Q) > 255 )
- {
- amcode_Q = 255;
- }
- else
- {
- amcode_Q = -1.0*offset_Q/slope_Q;
- }
- //amcode_Q = c0_Q - f0_Q/slope_Q;
- }
- }
- uc_mt6139_coef.rx.coef[eFreqBand].amcodeI = amcode_I;
- uc_mt6139_coef.rx.coef[eFreqBand].amcodeQ = amcode_Q;
- sprintf(tempbuf, "%8d", amcode_I);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- sprintf(tempbuf, "%8d", amcode_Q);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Evaluate: amcodeI = " + IntToStr(amcode_I) +
- ", amcodeQ = " + IntToStr(amcode_Q)
- );
- #if 0
- if( !MF_rf_pm_ptr->Set_ucMT6139Coef( uc_mt6139_coef ) )
- {
- CalErrorHandler( WM_MF_RF_IP2_SET_MT6139_COEF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 Set MT6139 coefficient fail."
- );
- return false;
- }
- // write IP2 register to NVRAM
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal( WM_MF_NVRAM_IP2_READ_FAIL );
- SUSPEND_CAL_THREAD
- if (MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_NVRAM_IP2_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write amcodeI, amcodeQ to NVRAM fail."
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write amcodeI, amcodeQ to NVRAM."
- );
- }
- #endif
- //------------------------------------------------------------
- // set rxamcalmode=0, gain
- uc_mt6139_coef.rx.rxamcalmode = RXAMCALMODE_MT6139C_READ_ACODE;
- MF_rf_pm_ptr->Set_ucMT6139Coef( uc_mt6139_coef );
- // write rxamcalmode=0 to NVRAM
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_IP2_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = MF_rf_pm_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RFSPECIALCOEF_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_IP2_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write amcodeI, amcodeQ, rxamcalmode=0 to NVRAM fail."
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write amcodeI, amcodeQ, rxamcalmode=0 to NVRAM."
- );
- // set gain, PM
- // if Agilent 8960 not read, target will get error power!
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr(c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- //--------------------------------------------------------------
- // read A code
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_GetAcodeFromReg;
- MF_rf_pm_ptr->Get_AcodeFromReg_Start( eFreqBand, uc_mt6139_coef, m_pCal->ui_rf_id );
- CHECK_TERMINATE_BY_USER
- RestartTimerCal( WM_MF_RF_IP2_GET_ACODE_FAIL );
- SUSPEND_CAL_THREAD
- // if (MF_rf_pm_ptr->ConfirmState != METAAPP_SUCCESS)
- if (MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_IP2_GET_ACODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target> get acode from register."
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target> get acode from register:" +
- " acodeI = " + IntToStr( uc_mt6139_coef.rx.coef[eFreqBand].acodeI ) +
- ", acodeQ = " + IntToStr( uc_mt6139_coef.rx.coef[eFreqBand].acodeQ )
- );
- sprintf( tempbuf, "%8d", uc_mt6139_coef.rx.coef[eFreqBand].acodeI );
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- sprintf( tempbuf, "%8d", uc_mt6139_coef.rx.coef[eFreqBand].acodeQ );
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- // write IP2 register to NVRAM
- uc_mt6139_coef.rx.rxamcalmode = RXAMCALMODE_MT6139C_NORMAL;
- MF_rf_pm_ptr->Set_ucMT6139Coef( uc_mt6139_coef );
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal(WM_MF_NVRAM_IP2_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- state = MF_rf_pm_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RFSPECIALCOEF_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RFSPECIALCOEF_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_IP2_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write rxamcalmode=2 to NVRAM fail."
- );
- }
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write rxamcalmode=2 to NVRAM."
- );
- }
- if (!WriteIP2CalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, m_pCal->ui_rf_id, eFreqBand ) )
- {
- CalErrorHandler(WM_MF_RF_AFC_WRITE_CAL_RESULT_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : write IP2 parameter to cal file "
- );
- return false;
- }
- //------------------------------------------------------------
- #if 0
- // set rxamcalmode=0, gain
- // uc_mt6139_coef.rx.rxamcalmode = RXAMCALMODE_READ_ACODE;
- MF_rf_pm_ptr->ConfirmCallback = ::ccb_SetMT6139CoefToReg;
- MF_rf_pm_ptr->Set_MT6139CoefToReg_Start(uc_mt6139_coef);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal( WM_MF_RF_IP2_SET_AMCALMODE_FAIL );
- SUSPEND_CAL_THREAD
- if (MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_IP2_SET_AMCALMODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set rxamcalmode=0 to register."
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set rxamcalmode=0 to register."
- );
- #endif
- eFreqBand++;
- } // while
- #if 0
- // write IP2 register to NVRAM
- uc_mt6139_coef.rx.rxamcalmode = RXAMCALMODE_MT6139C_NORMAL;
- if( !MF_rf_pm_ptr->Set_ucMT6139Coef( uc_mt6139_coef ) )
- {
- CalErrorHandler( WM_MF_RF_IP2_SET_MT6139_COEF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 Set rxamcalmode=2 fail."
- );
- return false;
- }
- MF_rf_pm_ptr->ConfirmCallback = ccb_write_ip2_to_nvram;
- MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM(m_pCal->ui_rf_id);
- CHECK_TERMINATE_BY_USER
- RestartTimerCal( WM_MF_NVRAM_IP2_READ_FAIL );
- SUSPEND_CAL_THREAD
- if (MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_NVRAM_IP2_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < write rxamcalmode=2 to NVRAM fail."
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < write rxamcalmode=2 to NVRAM."
- );
- }
- #endif
- if (!WriteIP2RxAmCalModeToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, m_pCal->ui_rf_id ) )
- {
- CalErrorHandler( WM_MF_RF_AFC_WRITE_CAL_RESULT_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : write IP2 parameter to cal file "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== IP2 calibration end ==================== n "
- );
- frmFatcory->DisableAllCalTimer();
- return true;
- }
- //-----------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::IP2Cal_mt6139_check( void )
- {
- int MDCI[2];
- int MDCQ[2];
- int DCI;
- int DCQ;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== IP2 check begin ==================== n "
- );
-
- short s_ARFCN;
- FrequencyBand eFreqBand = FrequencyBand850;
- int vi_Band;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_GSM850_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM850;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_EGSM_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_GSM;
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_DCS1800_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_DCS;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_PCS1900_BAND;
- s_ARFCN = m_sIP2_arfcn_C0_PCS;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Band = " + ViBand_To_Str( vi_Band )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 > Band = " + ViBand_To_Str( vi_Band )
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< band = " +
- FreqBand_To_Str( 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_PM_SELECT_BAND_FAIL );
- pt_calibration->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_PM_SELECT_BAND_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_ContModTran( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Set continuous tranmittion mode "
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200< Set continuous tranmittion mode "
- );
- }
- return false;
- }
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, s_ARFCN ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< BCH ARFCN = " +
- AnsiString(s_ARFCN)
- );
- }
- //----------------------------------------------------------------
- // cell power off
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CHECK_P_DL_OFF ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_OFF) ) + " dBm";
- }
- // if( frmFatcory->cbAFC->Checked || frmFatcory->cbRxPathLoss->Checked )
- // {
- // Sleep( 100 ); // wait Agilent 8960 ready!
- // }
- // else
- {
- Sleep( 200 ); // wait Agilent 8960 ready!
- }
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- #if 0
- int abs_iOffset = abs(MF_rf_pm_cnf->extra_info.iOffset);
- int abs_qOffset = abs(MF_rf_pm_cnf->extra_info.qOffset);
- if( abs_iOffset > i_IP2_MAX_IDC || abs_qOffset > i_IP2_MAX_QDC)
- {
- CalErrorHandler( WM_MF_RF_IP2_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Fail: IP2 check ." + " I_MDC_OFF = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_OFF = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", IP2_MAX_IDC = " + IntToStr( i_IP2_MAX_IDC ) +
- ", IP2_MAX_QDC = " + IntToStr( i_IP2_MAX_QDC )
- );
- return false;
- }
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " I_MDC_OFF = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_OFFF = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset)
- );
- MDCI[0] = MF_rf_pm_cnf->extra_info.iOffset;
- MDCQ[0] = MF_rf_pm_cnf->extra_info.qOffset;
- //----------------------------------------------------------------
- // cell power on
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_IP2_CHECK_P_DL_ON ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) ) + " dBm";
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_IP2_CHECK_P_DL_ON) ) + " dBm";
- }
- // if( frmFatcory->cbAFC->Checked || frmFatcory->cbRxPathLoss->Checked )
- // {
- // Sleep( 100 ); // wait Agilent 8960 ready!
- // }
- // else
- {
- Sleep( 200 ); // wait Agilent 8960 ready!
- }
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_cnf->extra_info.valid =0;
- MF_rf_pm_cnf->extra_info.iOffset=0;
- MF_rf_pm_cnf->extra_info.qOffset=0;
- MF_rf_pm_cnf->extra_info.validSamples =0;
- MF_rf_pm_req->arfcn = s_ARFCN-30;
- MF_rf_pm_req->sampleNoPerFrame = c_IP2_M_PM;
- MF_rf_pm_req->gain = d_IP2_GAIN *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = i_IP2_N_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- " sample per frame = " + IntToStr( c_IP2_M_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( i_IP2_N_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_ARFCN-30 ) +
- ", sample per frame = " + IntToStr( c_IP2_M_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( i_IP2_N_PM)
- );
- // Sleep(100);// delay for power measurement
- RestartTimerCal( WM_MF_RF_IP2_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- if( !MF_rf_pm_cnf->ok )
- {
- CalErrorHandler( WM_MF_RF_IP2_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < ok = " + IntToStr(MF_rf_pm_cnf->ok) +
- ", power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0) +
- ", deviation = " + Double_To_AnsiString(sqrt(MF_rf_pm_cnf->deviation)/8.0) +
- ", usedGain = " + Double_To_AnsiString(MF_rf_pm_cnf->usedGain/8.0) +
- ", valid = " + IntToStr(MF_rf_pm_cnf->extra_info.valid) +
- ", I_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_DC = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", valid sample = " + IntToStr(MF_rf_pm_cnf->extra_info.validSamples)
- );
- #if 0
- int abs_iOffset = abs(MF_rf_pm_cnf->extra_info.iOffset);
- int abs_qOffset = abs(MF_rf_pm_cnf->extra_info.qOffset);
- if( abs_iOffset > i_IP2_MAX_IDC || abs_qOffset > i_IP2_MAX_QDC)
- {
- CalErrorHandler( WM_MF_RF_IP2_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Fail: IP2 check ." + " I_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", IP2_MAX_IDC = " + IntToStr( i_IP2_MAX_IDC ) +
- ", IP2_MAX_QDC = " + IntToStr( i_IP2_MAX_QDC )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Pass: IP2 check ." + " I_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset) +
- ", IP2_MAX_IDC = " + IntToStr( i_IP2_MAX_IDC ) +
- ", IP2_MAX_QDC = " + IntToStr( i_IP2_MAX_QDC )
- );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " I_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.iOffset) +
- ", Q_MDC_ON = " + IntToStr(MF_rf_pm_cnf->extra_info.qOffset)
- );
- MDCI[1] = MF_rf_pm_cnf->extra_info.iOffset;
- MDCQ[1] = MF_rf_pm_cnf->extra_info.qOffset;
- DCI = MDCI[1] - MDCI[0];
- DCQ = MDCQ[1] - MDCQ[0];
- int ab_DCI = abs(DCI);
- int ab_QCQ = abs(DCQ);
- if( ab_DCI > m_iIP2_MAX_IDC_MT6139 || ab_QCQ > m_iIP2_MAX_QDC_MT6139)
- {
- CalErrorHandler( WM_MF_RF_IP2_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Fail: IP2 check ." + " I_DC = " + IntToStr(DCI) +
- ", Q_DC = " + IntToStr(DCQ) +
- ", IP2_MAX_IDC = " + IntToStr( m_iIP2_MAX_IDC_MT6139 ) +
- ", IP2_MAX_QDC = " + IntToStr( m_iIP2_MAX_QDC_MT6139 )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Pass: IP2 check ." + " I_DC = " + IntToStr(DCI) +
- ", Q_DC = " + IntToStr(DCQ) +
- ", IP2_MAX_IDC = " + IntToStr( m_iIP2_MAX_IDC_MT6139 ) +
- ", IP2_MAX_QDC = " + IntToStr( m_iIP2_MAX_QDC_MT6139 )
- );
- eFreqBand++;
- } // while
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== IP2 check end ==================== n "
- );
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_IP2_CALIBRATION_DONE,
- 0,
- 0
- );
- frmFatcory->DisableAllCalTimer();
- return true;
- }