T_TXPCL_common.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:268k
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_SET_APC_DAC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_sub_tx_cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() ) ) + "n"
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_sub_tx_cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_cal_pcl.ToInt() ) ) + "n"
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0 "
- );
- break; // for iRealRecursiveTimes
- }
- } // if no iteration
- else if( iRealRecursiveTimes == i_TXlevelRecusiveTimes-1 )
- {
- double d_max_p = atof(as_sub_max_p.c_str());
- double d_min_p = atof(as_sub_min_p.c_str());
- if ( m_virTX > d_max_p || m_virTX < d_min_p )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Out of Range ), min TX power = " + Double_To_AnsiString( d_min_p ) + ", max TX power = " + Double_To_AnsiString( d_max_p )
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Pass ), min TX power = " + Double_To_AnsiString( d_min_p ) + ", max TX power = " + Double_To_AnsiString( d_max_p )
- );
- }
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- } // for N
- } // single slot TX
- else // multislot TX
- {
- unsigned int ui_tx_3cal_pcl[RF_TX_LEVEL_3_CAL_COUNT];
- double d_max_p[RF_TX_LEVEL_3_CAL_COUNT];
- double d_min_p[RF_TX_LEVEL_3_CAL_COUNT];
- double d_wanted_p[RF_TX_LEVEL_3_CAL_COUNT];
- S_MULTISLOT_BURST_POWER virTX_p;
- unsigned int ui_c[RF_TX_LEVEL_3_CAL_COUNT];
- unsigned short us_apc_dac[RF_TX_LEVEL_3_CAL_COUNT];
- for( int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- if (! getAnsiStrSubItem( as_tx_cal_pcl, N+1, DEFAULT_SEP_CHAR, as_sub_tx_cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_3cal_pcl)."
- );
- return false;
- }
- ui_tx_3cal_pcl[N] = as_sub_tx_cal_pcl.ToInt();
- if (! getAnsiStrSubItem( as_max_p, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_max_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p)."
- );
- return false;
- }
- d_max_p[N] = atof(as_sub_max_p.c_str());
- if (! getAnsiStrSubItem( as_min_p, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_min_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p)."
- );
- return false;
- }
- d_min_p[N] = atof(as_sub_min_p.c_str());
- if (! getAnsiStrSubItem( as_wanted_p, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- d_wanted_p[N] = atof(as_sub_wanted_p.c_str());
- if (! getAnsiStrSubItem( as_c, FIRST_PCL-as_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_c) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(c)."
- );
- return false;
- }
- ui_c[N] = as_sub_c.ToInt();
- } // for(N)
- for( iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes;
- iRealRecursiveTimes++) // marked by Andy Ueng for no iteration test
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " RecursiveTimes = " + IntToStr(iRealRecursiveTimes)
- );
- if( 0 == iRealRecursiveTimes )
- {
- m_usPCLDacValue[band_index][0] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[0] );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" +IntToStr(band_index) + "][" + IntToStr(0) + "] = " +
- IntToStr(m_usPCLDacValue[band_index][0])
- );
- }
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- pcl[0] = ui_tx_3cal_pcl[0];
- pcl[1] = ui_tx_3cal_pcl[1];
- pcl[2] = ui_tx_3cal_pcl[2];
- 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 = 0x07;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = NB_TX_RANDOM_WITH_TSC;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- SUSPEND_CAL_THREAD
- if( RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_readMultiSlotAverageTxPower( m_pRct, &virTX_p ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < read multislot TX power ."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- for ( int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- m_dPCL_dBm[band_index][N] = virTX_p.d_burstpower[N] ;
- m_dPCL_power[band_index][N] = pow(10.0, m_dPCL_dBm[band_index][N]/10.0)/1000.0;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read slot " + IntToStr(N) + " TX power = " + Double_To_AnsiString( virTX_p.d_burstpower[N] )
- );
- signed short ss1;
- double d1;
- if (iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( virTX_p.d_burstpower[N] > (d_wanted_p[N]+ m_dAPC_Delta) ||
- virTX_p.d_burstpower[N] < (d_wanted_p[N]- m_dAPC_Delta))
- {
- d1 = ui_c[N] * ( d_wanted_p[N] - virTX_p.d_burstpower[N] );
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- if ((MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-ui_tx_3cal_pcl[N]) + ss1) <= 0 )
- {
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N], 1);
- }
- else if ((MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-ui_tx_3cal_pcl[N]) + ss1) > MAX_APC_DAC)
- {
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N], MAX_APC_DAC);
- }
- else
- {
- MF_rf_apc_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N], MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N] )+ss1 );
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-ui_tx_3cal_pcl[N]) + "," +
- " MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N] ) )
- );
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N] );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" + IntToStr(band_index) +"][" + IntToStr(N) +"] = " +
- IntToStr(m_usPCLDacValue[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- AnsiString( MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N] ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- MF_rf_apc_ptr->ConfirmCallback = ccb_set_apc_level;
- MF_rf_apc_ptr->Req_Rf_SetRampApcLevel(eFreqBand, ui_tx_3cal_pcl[N], MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N] ));
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_SET_APC_DAC_FAIL );
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 9= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler( WM_MF_SET_APC_DAC_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_sub_tx_cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N] )) + "n"
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_sub_tx_cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_3cal_pcl[N] )) + "n"
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0 "
- );
- break; // for iRealRecursiveTimes
- }
- } // if no iteration
- else if( iRealRecursiveTimes == i_TXlevelRecusiveTimes-1 )
- {
- if( virTX_p.d_burstpower[N] > d_max_p[N] || virTX_p.d_burstpower[N] < d_min_p[N] )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " > read TX power = "+ Double_To_AnsiString( virTX_p.d_burstpower[N] ) +
- " ( Out of Range ), min TX power = " + Double_To_AnsiString( d_min_p[N] ) + ", max TX power = " + Double_To_AnsiString( d_max_p[N] )
- );
- return false;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " > read TX power = "+ Double_To_AnsiString( virTX_p.d_burstpower[N] ) +
- " ( Pass ), min TX power = " + Double_To_AnsiString( d_min_p[N] ) + ", max TX power = " + Double_To_AnsiString( d_max_p[N] )
- );
- }
- }
- } // for(N)
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for(iRealRecursiveTimes)
- }
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- if( ! m_rct_ctrl.RCT_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< set continuous TX power OFF "
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : cmu200 < set continuous TX power OFF "
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal(WM_MF_RF_TX_LEVEL_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- // WriteAPCCalResultToFile(IntToStr(i_ID)+".cal",Application->ExeName );
- // WriteAPCCalResultToFile(as_ID+".cal",Application->ExeName, frmFatcory->b_CalResultPath );
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============= GMSK TX power control level calibration end ============= n "
- );
- if( m_asAPC_Check.AnsiCompareIC("yes") != 0 )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_LEVEL_CALIBRATION_DONE_NO_CHECK,
- 0,
- 0
- );
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " "+ CurrentTimeStr() +
- " TX PCL calibration done (without TX PCL check procedure)! n"
- );
- }
-
- return true;
- }
- //============================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_4cal(void)
- {
- int FIRST_PCL=0;
- AnsiString as_tx_pcl;
- AnsiString as_tx_4cal_pcl;
- AnsiString as_sub_tx_4cal_pcl;
- AnsiString as_max_p;
- AnsiString as_wanted_p;
- AnsiString as_min_p;
- AnsiString as_c;
- AnsiString as_sub_tx_pcl;
- AnsiString as_sub_max_p;
- AnsiString as_sub_wanted_p;
- AnsiString as_sub_min_p;
- AnsiString as_sub_c;
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============ GMSK TX power control level calibration begin ============ n "
- );
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- if (!m_rct_ctrl.RCT_operatingMode(m_pRct, OPERATING_MODE_GSM_BCH_TCH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GSM BCH+TCH"
- );
- return false;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_operatingMode(m_pRct, OPERATING_MODE_GPRS_BCH_PDTCH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GPRS BCH+PDTCH"
- );
- return false;
- }
- }
- short s_ARFCN;
- FrequencyBand eFreqBand = FrequencyBand850;
- i_N_TX = 2000; // TX frames
- //---------------------------------------------------------------------------
- while (eFreqBand < FrequencyBandCount)
- {
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM850_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_tx_4cal_pcl = m_as_gsm850_tx_4cal_pcl;
- as_tx_pcl = m_as_gsm850_tx_pcl;
- as_max_p = m_as_gsm850_max_p;
- as_wanted_p = m_as_gsm850_wanted_p;
- as_min_p = m_as_gsm850_min_p;
- as_c = m_as_gsm850_c;
- }
- break;
- case FrequencyBand900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_tx_4cal_pcl = m_as_gsm900_tx_4cal_pcl;
- as_tx_pcl = m_as_gsm900_tx_pcl;
- as_max_p = m_as_gsm900_max_p;
- as_wanted_p = m_as_gsm900_wanted_p;
- as_min_p = m_as_gsm900_min_p;
- as_c = m_as_gsm900_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_tx_4cal_pcl = m_as_dcs1800_tx_4cal_pcl;
- as_tx_pcl = m_as_dcs1800_tx_pcl;
- as_max_p = m_as_dcs1800_max_p;
- as_wanted_p = m_as_dcs1800_wanted_p;
- as_min_p = m_as_dcs1800_min_p;
- as_c = m_as_dcs1800_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- s_ARFCN = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_tx_4cal_pcl = m_as_pcs1900_tx_4cal_pcl;
- as_tx_pcl = m_as_pcs1900_tx_pcl;
- as_max_p = m_as_pcs1900_max_p;
- as_wanted_p = m_as_pcs1900_wanted_p;
- as_min_p = m_as_pcs1900_min_p;
- as_c = m_as_pcs1900_c;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- E_BANDSEL band_index = FreqBand_To_BandIdx(eFreqBand);
- int vi_Band = FreqBand_To_AgeBand(eFreqBand);
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_ptr->ApcSectionExist(m_pCal->as_IniFile.c_str(), band_index))
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " APC section is not in initial file: " + FreqBand_To_Str(eFreqBand)
- );
- return false;
- }
-
- if (IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- if(eFreqBand == FrequencyBand1900)
- {
- if(META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 1"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 1"
- );
- }
- else
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, vi_Band))
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_Band)
- );
- return false;
- }
- Sleep(100); // wait Agilent 8960 cell band setup ready!
- // if Agilent 8960 not read, target will get error power!
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_Band)
- );
- short bch_arfcn = ::Get_SeperateChannel(vi_Band, s_ARFCN);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- return false;
- }
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- if (!m_rct_ctrl.RCT_TCHARFCN(m_pRct, s_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(s_ARFCN)
- );
- return false;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_PDTCHARFCN(m_pRct, s_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr(s_ARFCN)
- );
- return false;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(s_ARFCN)
- );
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr(s_ARFCN)
- );
- }
- // ----------------------- set Agilent 8960 < TSC -------------------------
- if (!m_rct_ctrl.RCT_ConfigTSC(m_pRct, m_cTSC))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TSC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- RestartTimerCal(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- if (!m_rct_ctrl.RCT_Config_ExpectedTxPower(m_pRct, true, 0))
- {
- RestartTimerCal(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < config expected TX power to auto fail"
- );
- return false;
- }
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- if (!m_rct_ctrl.RCT_confTXPower(m_pRct))
- {
- CalErrorHandler(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power ."
- );
- return false;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_confMultiSlotTxPower(m_pRct, AGE1960_TX_POWER_MEASURE_COUNT, MOD_GMSK))
- {
- CalErrorHandler(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- }
- if( ! m_rct_ctrl.RCT_TXPowerContOff(m_pRct))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // calibration from high power to low power
- // index from big to little.
- // PCL string in config file from right to left.
- int iRealRecursiveTimes = 0;
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- for (int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ------------------------------------------------------------------ "
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " N = " + N
- );
- if (!getAnsiStrSubItem(as_tx_4cal_pcl, N+1, DEFAULT_SEP_CHAR, as_sub_tx_4cal_pcl) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl)."
- );
- return false;
- }
- for (iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes;
- iRealRecursiveTimes++) // marked by Andy Ueng for no iteration test
- {
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " RecursiveTimes = " + IntToStr(iRealRecursiveTimes)
- );
- if (0 == iRealRecursiveTimes)
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " MF_rf_apc_ptr->ApcProfile[" + IntToStr(band_index) + "].rampData.power[" +
- IntToStr(FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()) + "] = " +
- IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()))
- );
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt());
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" +IntToStr(band_index) + "][" + IntToStr(N) + "] = " +
- IntToStr(m_usPCLDacValue[band_index][N])
- );
- }
- // index start from 1
- if (!getAnsiStrSubItem(as_tx_pcl, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_tx_pcl))
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl 2)."
- );
- return false;
- }
- if (!getAnsiStrSubItem(as_max_p, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_max_p))
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p)."
- );
- return false;
- }
- if (!getAnsiStrSubItem(as_min_p, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_min_p) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p)."
- );
- return false;
- }
- if (!getAnsiStrSubItem(as_wanted_p, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_wanted_p))
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- if (!getAnsiStrSubItem(as_c, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_c) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(c)."
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (!m_rct_ctrl.RCT_MSTXLevel(m_pRct, as_sub_tx_pcl.ToInt()))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : cmu200 > MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (frmFatcory->rbAgilent8960->Checked)
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Agilent 8960< MS TX level = " + IntToStr(as_sub_tx_pcl.ToInt())
- );
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU200 < MS TX level = " + IntToStr( as_sub_tx_pcl.ToInt())
- );
- }
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- MF_rf_tx_level_req->arfcn = s_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = as_sub_tx_pcl.ToInt();
- MF_rf_tx_level_req->frames = i_N_TX;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC; // NB burst
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- MF_rf_tx_level_cb,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(s_ARFCN) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + as_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- #ifdef _MYDEBUG_
- ":" + AnsiString( ms ) +
- #endif
- " Target< TX: ARFCN = " + IntToStr( s_ARFCN ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before suspend " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 7= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- RestartTimerCal(WM_MF_RF_TX_LEVEL_FAIL);
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add(" after resume " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (!MF_rf_tx_level_cnf)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : ! MF_rf_tx_level_cnf"
- );
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- RestartTimerCal(WM_MF_AGE8960_READ_TX_POWER_FAIL);
- if (!m_rct_ctrl.RCT_ReadTxPower(m_pRct, m_virTX))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_TX_POWER_FAIL);
- if (frmFatcory->rbAgilent8960->Checked)
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< read TX power 1."
- );
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : CMU 200< read TX power 1."
- );
- }
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm[band_index][N] = m_virTX ;
- m_dPCL_power[band_index][N] = pow(10.0, m_dPCL_dBm[band_index][N]/10.0)/1000.0;
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (frmFatcory->rbAgilent8960->Checked)
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Agilent 8960< read TX power = "+ Double_To_AnsiString(m_virTX)
- );
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " CMU 200< read TX power = "+ Double_To_AnsiString(m_virTX)
- );
- }
- signed short ss1;
- double d1;
- if (iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if (m_virTX > (atof(as_sub_wanted_p.c_str())+ m_dAPC_Delta) ||
- m_virTX < (atof(as_sub_wanted_p.c_str())- m_dAPC_Delta))
- {
- d1 = atof(as_sub_c.c_str()) * (atof(as_sub_wanted_p.c_str()) - m_virTX );
- // modified by Andy Ueng for always increment 1
- // ss1 = (signed short) (d1>0) ? floor(d1+0.5): ceil(d1-0.5); // to round up or down
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- unsigned short us_org_apc_dac = MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt());
- unsigned short us_new_apc_dac;
- if ((us_org_apc_dac + ss1) <= MIN_APC_DAC )
- {
- us_new_apc_dac = 1;
- }
- else if ((us_org_apc_dac + ss1) > MAX_APC_DAC)
- {
- us_new_apc_dac = MAX_APC_DAC;
- }
- else
- {
- us_new_apc_dac = us_org_apc_dac + ss1;
- }
- MF_rf_apc_ptr->Set_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt(), us_new_apc_dac );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()) + "," +
- " MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(us_new_apc_dac )
- );
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt());
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" + IntToStr(band_index) +"][" + IntToStr(N) +"] = " +
- IntToStr(m_usPCLDacValue[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- AnsiString( MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt() ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- MF_rf_apc_ptr->ConfirmCallback = ccb_set_apc_level;
- MF_rf_apc_ptr->Req_Rf_SetRampApcLevel(eFreqBand, as_sub_tx_4cal_pcl.ToInt(), MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt() ));
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal(WM_MF_SET_APC_DAC_FAIL);
- //log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 9= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_SET_APC_DAC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_sub_tx_4cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt() )) + "n"
- );
- return false;
- }
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_sub_tx_4cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt() )) + "n"
- );
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0 "
- );
- break; // for iRealRecursiveTimes
- }
- } // if no iteration
- else if (iRealRecursiveTimes == i_TXlevelRecusiveTimes-1)
- {
- double d_max_p = atof(as_sub_max_p.c_str());
- double d_min_p = atof(as_sub_min_p.c_str());
- if (m_virTX > d_max_p || m_virTX < d_min_p)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Out of Range ), min TX power = " + Double_To_AnsiString( d_min_p ) + ", max TX power = " + Double_To_AnsiString( d_max_p )
- );
- return false;
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Pass ), min TX power = " + Double_To_AnsiString( d_min_p ) + ", max TX power = " + Double_To_AnsiString( d_max_p )
- );
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- } // for N
- } // single slot
- else // multi-slot
- {
- unsigned int ui_tx_4cal_pcl[RF_TX_LEVEL_4_CAL_COUNT];
- double d_max_p[RF_TX_LEVEL_4_CAL_COUNT];
- double d_min_p[RF_TX_LEVEL_4_CAL_COUNT];
- double d_wanted_p[RF_TX_LEVEL_4_CAL_COUNT];
- S_MULTISLOT_BURST_POWER virTX_p;
- unsigned int ui_c[RF_TX_LEVEL_4_CAL_COUNT];
- unsigned short us_apc_dac[RF_TX_LEVEL_4_CAL_COUNT];
- for (int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- if (!getAnsiStrSubItem(as_tx_4cal_pcl, N+1, DEFAULT_SEP_CHAR, as_sub_tx_4cal_pcl))
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl)."
- );
- return false;
- }
- ui_tx_4cal_pcl[N] = as_sub_tx_4cal_pcl.ToInt();
- if (!getAnsiStrSubItem(as_max_p, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_max_p))
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p)."
- );
- return false;
- }
- d_max_p[N] = atof(as_sub_max_p.c_str());
- if (!getAnsiStrSubItem(as_min_p, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_min_p))
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p)."
- );
- return false;
- }
- d_min_p[N] = atof(as_sub_min_p.c_str());
- if (!getAnsiStrSubItem(as_wanted_p, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_wanted_p) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- d_wanted_p[N] = atof(as_sub_wanted_p.c_str());
- if (! getAnsiStrSubItem(as_c, FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_sub_c) )
- {
- CalErrorHandler(WM_MF_CFG_READ_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(c)."
- );
- return false;
- }
- ui_c[N] = as_sub_c.ToInt();
- } // for(N)
- for (iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes; iRealRecursiveTimes++)
- {
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " RecursiveTimes = " + IntToStr(iRealRecursiveTimes)
- );
- if (0 == iRealRecursiveTimes)
- {
- m_usPCLDacValue[band_index][0] = MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-ui_tx_4cal_pcl[0]);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" +IntToStr(band_index) + "][" + IntToStr(0) + "] = " +
- IntToStr(m_usPCLDacValue[band_index][0])
- );
- }
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = ui_tx_4cal_pcl[0];
- pcl[1] = ui_tx_4cal_pcl[1];
- pcl[2] = ui_tx_4cal_pcl[2];
- pcl[3] = ui_tx_4cal_pcl[3];
- 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 = 0x0F;
- 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);
- //RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- //RF_MULTI_SLOT_TX_Obj.REQ_Start(band_index, s_ARFCN, m_cTSC, cs, pcl, -99, m_sDefault_value, 0x0F, 0, true, NB_TX_RANDOM_WITH_TSC, 0);
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal(WM_MF_RF_TX_LEVEL_FAIL);
- SUSPEND_CAL_THREAD
- if (RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- if (!m_rct_ctrl.RCT_readMultiSlotAverageTxPower(m_pRct, &virTX_p))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < read multislot TX power ."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- for (int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- m_dPCL_dBm[band_index][N] = virTX_p.d_burstpower[N] ;
- m_dPCL_power[band_index][N] = pow(10.0, m_dPCL_dBm[band_index][N]/10.0)/1000.0;
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read slot " + IntToStr(N) + " TX power = " + Double_To_AnsiString( virTX_p.d_burstpower[N] )
- );
- signed short ss1;
- double d1;
- if (iRealRecursiveTimes != i_TXlevelRecusiveTimes-1)
- {
- if (virTX_p.d_burstpower[N] > (d_wanted_p[N]+ m_dAPC_Delta) ||
- virTX_p.d_burstpower[N] < (d_wanted_p[N]- m_dAPC_Delta))
- {
- d1 = ui_c[N] * (d_wanted_p[N] - virTX_p.d_burstpower[N]);
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- unsigned short us_org_apc_dac = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_4cal_pcl[N] );
- unsigned short us_new_apc_dac;
- if ((us_org_apc_dac + ss1) <= 0)
- {
- us_new_apc_dac = 1;
- }
- else if ((us_org_apc_dac + ss1) > MAX_APC_DAC)
- {
- us_new_apc_dac = MAX_APC_DAC;
- }
- else
- {
- us_new_apc_dac = us_org_apc_dac + ss1;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_sub_tx_4cal_pcl.ToInt()) + "," +
- " MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr( us_new_apc_dac )
- );
- m_usPCLDacValue[band_index][N] = MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_4cal_pcl[N] );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " m_usPCLDacValue[" + IntToStr(band_index) +"][" + IntToStr(N) +"] = " +
- IntToStr(m_usPCLDacValue[band_index][N])
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- AnsiString(MF_rf_apc_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-ui_tx_4cal_pcl[N]))
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString(ss1)
- );
- MF_rf_apc_ptr->ConfirmCallback = ::ccb_set_apc_level;
- MF_rf_apc_ptr->Req_Rf_SetRampApcLevel(eFreqBand, ui_tx_4cal_pcl[N], MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_4cal_pcl[N] ));
- 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_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_RAMPTABLE_xxx_LID_VERNO_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_SET_APC_DAC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_sub_tx_4cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_4cal_pcl[N] )) + "n"
- );
- }
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_sub_tx_4cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-ui_tx_4cal_pcl[N] )) + "n"
- );
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0 "
- );
- break; // for iRealRecursiveTimes
- }
- } // if no iteration
- else if (iRealRecursiveTimes == i_TXlevelRecusiveTimes-1)
- {
- if (virTX_p.d_burstpower[N] > d_max_p[N] || virTX_p.d_burstpower[N] < d_min_p[N])
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " > read TX power = "+ Double_To_AnsiString( virTX_p.d_burstpower[N] ) +
- " ( Out of Range ), min TX power = " + Double_To_AnsiString( d_min_p[N] ) + ", max TX power = " + Double_To_AnsiString( d_max_p[N] )
- );
- return false;
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " > read TX power = "+ Double_To_AnsiString( virTX_p.d_burstpower[N] ) +
- " ( Pass ), min TX power = " + Double_To_AnsiString( d_min_p[N] ) + ", max TX power = " + Double_To_AnsiString( d_max_p[N] )
- );
- }
- }
- } // for(N)
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for(iRealRecursiveTimes)
- } // multi-slot
- eFreqBand++;
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- if (!m_rct_ctrl.RCT_TXPowerContOff(m_pRct))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL);
- if (frmFatcory->rbAgilent8960->Checked)
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Agilent 8960< set continuous TX power OFF "
- );
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : cmu200 < set continuous TX power OFF "
- );
- }
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============= TX power control level calibration end ============= n "
- );
- RestartTimerCal(WM_MF_RF_TX_LEVEL_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler( WM_MF_RF_STOP_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============= GMSK TX power control level calibration end ============= n "
- );
- if( m_asAPC_Check.AnsiCompareIC("yes") != 0 )
- {
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_TX_LEVEL_CALIBRATION_DONE_NO_CHECK,
- 0,
- 0
- );
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " "+ CurrentTimeStr() +
- " TX PCL calibration done (without TX PCL check procedure)! n"
- );
- }
- return true;
- }
- //============================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_6cal_DAC(void)
- {
- //int FIRST_PCL=0;
- AnsiString as_tx_6cal_pcl;
- AnsiString as_tx_6cal_dac;
- //AnsiString as_sub_tx_6cal_dac;
- //AnsiString as_max_p;
- //AnsiString as_wanted_p;
- //AnsiString as_min_p;
- //AnsiString as_c;
- //AnsiString as_sub_tx_pcl;
- //AnsiString as_sub_max_p;
- //AnsiString as_sub_wanted_p;
- //AnsiString as_sub_min_p;
- //AnsiString as_sub_c;
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ============ GMSK TX power control level calibration begin ============ n "
- );
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- if (!m_rct_ctrl.RCT_operatingMode(m_pRct, OPERATING_MODE_GSM_BCH_TCH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GSM BCH+TCH"
- );
- return false;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_operatingMode(m_pRct, OPERATING_MODE_GPRS_BCH_PDTCH))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_OPERATION_MODE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = GPRS BCH+PDTCH"
- );
- return false;
- }
- }
- short s_ARFCN;
- FrequencyBand eFreqBand = FrequencyBand850;
- i_N_TX = -99; // TX frames
- //---------------------------------------------------------------------------
- while (eFreqBand < FrequencyBandCount)
- {
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- E_BANDSEL band_index;
- int vi_Band;
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_GSM850_BAND;
- band_index = BANDSEL_GSM850;
- s_ARFCN = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_6_CAL_COUNT;
- as_tx_6cal_pcl = m_as_gsm850_tx_6cal_pcl;
- as_tx_6cal_dac = m_as_gsm850_tx_6cal_dac;
- }
- break;
- case FrequencyBand900:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_EGSM_BAND;
- band_index = BANDSEL_GSM900;
- s_ARFCN = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_6_CAL_COUNT;
- as_tx_6cal_pcl = m_as_gsm900_tx_6cal_pcl;
- as_tx_6cal_dac = m_as_gsm900_tx_6cal_dac;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_DCS1800_BAND;
- band_index = BANDSEL_DCS1800;
- s_ARFCN = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_6_CAL_COUNT;
- as_tx_6cal_pcl = m_as_dcs1800_tx_6cal_pcl;
- as_tx_6cal_dac = m_as_dcs1800_tx_6cal_dac;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_PCS1900_BAND;
- band_index = BANDSEL_PCS1900;
- s_ARFCN = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_6_CAL_COUNT;
- as_tx_6cal_pcl = m_as_pcs1900_tx_6cal_pcl;
- as_tx_6cal_dac = m_as_pcs1900_tx_6cal_dac;
- }
- break;
- default:
- {
- assert(false);
- }
- break;
- } // switch
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_ptr->ApcSectionExist(m_pCal->as_IniFile.c_str(), band_index))
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : APC section is not in initial file: " + FreqBand_To_Str(eFreqBand)
- );
- return false;
- }
- if (IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- if (eFreqBand == FrequencyBand1900)
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 1"
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 1"
- );
- }
- else
- {
- if (META_Rf_SelectFrequencyBand1900_r(m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if (!m_rct_ctrl.RCT_cellBand(m_pRct, vi_Band))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_BAND_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_Band)
- );
- return false;
- }
- Sleep(100); // wait Agilent 8960 cell band setup ready!
- // if Agilent 8960 not read, target will get error power!
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str(vi_Band)
- );
- short bch_arfcn = ::Get_SeperateChannel(vi_Band, s_ARFCN);
- if (!m_rct_ctrl.RCT_BCHARFCN(m_pRct, bch_arfcn))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr(bch_arfcn)
- );
- return false;
- }
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- if (!m_rct_ctrl.RCT_TCHARFCN(m_pRct, s_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(s_ARFCN)
- );
- return false;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_PDTCHARFCN(m_pRct, s_ARFCN))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TCH_ARFCN_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr(s_ARFCN)
- );
- return false;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TCH ARFCN = " + IntToStr(s_ARFCN)
- );
- }
- else
- {
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr(s_ARFCN)
- );
- }
- // ----------------------- set Agilent 8960 < TSC -------------------------
- if (!m_rct_ctrl.RCT_ConfigTSC(m_pRct, m_cTSC))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TSC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- RestartTimerCal(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- if (!m_rct_ctrl.RCT_Config_ExpectedTxPower(m_pRct, true, 0))
- {
- RestartTimerCal(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < config expected TX power to auto fail"
- );
- return false;
- }
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- if (!m_rct_ctrl.RCT_confTXPower(m_pRct))
- {
- CalErrorHandler(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power ."
- );
- return false;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_confMultiSlotTxPower(m_pRct, AGE1960_TX_POWER_MEASURE_COUNT, MOD_GMSK))
- {
- CalErrorHandler(WM_MF_AGE8960_CONFIG_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- }
- if (!m_rct_ctrl.RCT_TXPowerContOff(m_pRct))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- short s_pcl[RF_TX_LEVEL_6_CAL_COUNT];
- String_To_Array_short(as_tx_6cal_pcl.c_str(), s_pcl, RF_TX_LEVEL_6_CAL_COUNT);
- String_To_Array_UnsignedShort(as_tx_6cal_dac.c_str(), m_usPCLDacValue[band_index], RF_TX_LEVEL_6_CAL_COUNT);
- if (TX_SLOT_SINGLE == m_pCal->e_tx_slot)
- {
- for (int N=0; N<i_TX_level_count; N++)
- {
- log->Add("n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ------------------------------------------------------------------ "
- );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " N = " + N
- );
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (!m_rct_ctrl.RCT_MSTXLevel(m_pRct, s_pcl[N]))
- {
- CalErrorHandler(WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(s_pcl[N])
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " " + m_pRct->as_RCT + " < MS TX level = " + IntToStr(s_pcl[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;
- }
- MF_rf_tx_level_req->arfcn = s_ARFCN;
- MF_rf_tx_level_req->bsic = m_cTSC;
- MF_rf_tx_level_req->power = s_pcl[N];
- MF_rf_tx_level_req->frames = i_N_TX;
- MF_rf_tx_level_req->dacValue = m_sDefault_value;
- MF_rf_tx_level_req->burstTypeNB = NB_TX_RANDOM_WITH_TSC; // NB burst
- if (META_Rf_NB_TX_r(m_pCal->i_MainMETAHandle,
- MF_rf_tx_level_req,
- MF_rf_tx_level_cb,
- &MF_rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(s_ARFCN) +
- ", TSC = " + IntToStr(m_cTSC) +
- ", power = " + IntToStr(s_pcl[N]) +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr(m_sDefault_value)
- );
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< TX: ARFCN = " + IntToStr( s_ARFCN ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + IntToStr(s_pcl[N]) +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- RestartTimerCal(WM_MF_RF_TX_LEVEL_FAIL);
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (!MF_rf_tx_level_cnf)
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : ! MF_rf_tx_level_cnf"
- );
- return false;
- }
- RestartTimerCal(WM_MF_AGE8960_READ_TX_POWER_FAIL);
- if (!m_rct_ctrl.RCT_ReadTxPower(m_pRct, m_virTX))
- {
- CalErrorHandler(WM_MF_AGE8960_READ_TX_POWER_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_pRct->as_RCT + " < read TX power 1."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm[band_index][N] = m_virTX ;
- m_dPCL_power[band_index][N] = pow(10.0, m_dPCL_dBm[band_index][N]/10.0)/1000.0;
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Agilent 8960< read TX power = "+ Double_To_AnsiString(m_virTX)
- );