T_TXPCL_EPSK_common.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:180k
源码类别:
MTK
开发平台:
C++ Builder
- " FAIL: Get APC DC offset " +
- " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
- " eFreqBand = " + IntToStr( eFreqBand ) +
- " pcl = " + as_epsk_sub_tx_cal_pcl
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " MF_rf_apc_ptr->ApcDcOffset[band_index] = " + IntToStr(m_iApcDcOffset)
- );
- m_dV_set_EPSK[band_index][N] = (m_iApcDcOffset + m_usPCLDacValue_EPSK[band_index][N]) / 1024.0 * 2.8 * 15.0 / 25.0;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_dV_set_EPSK[band_index][N] = " + Double_To_AnsiString(m_dV_set_EPSK[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- IntToStr( MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- RfSetRampApcLevel_Req RfSetApcDac;
- RfSetApcDac.rf_band = eFreqBand;
- RfSetApcDac.power_level = as_epsk_sub_tx_cal_pcl.ToInt();
- RfSetApcDac.apc_dac = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() );
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_set_apc_level;
- MF_rf_apc_8psk_ptr->REQ_EPSK_SetRampApcLevel_Start( &RfSetApcDac );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_SET_APC_DAC_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_SET_APC_DAC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_epsk_sub_tx_cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() ) ) + "n"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_epsk_sub_tx_cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_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
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- } // for N
- } // single slot TX
- else // multi-slot TX
- {
- }
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " =========== EPSK TX power control level calibration end =========== n "
- );
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- return true;
- }
- //=========================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_4cal(void)
- {
- AnsiString as_epsk_tx_pcl;
- AnsiString as_epsk_tx_cal_pcl;
- AnsiString as_epsk_max_p;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_min_p;
- AnsiString as_epsk_c;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_tx_cal_pcl;
- AnsiString as_epsk_sub_max_p;
- AnsiString as_epsk_sub_wanted_p;
- AnsiString as_epsk_sub_min_p;
- AnsiString as_epsk_sub_c;
- int FIRST_PCL=0;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ========== EPSK TX power control level calibration begin ========== n "
- );
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = EGPRS BCH+PDTCH"
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_Config_EPSK_CodingScheme( m_pRct, MCS5 ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_CODING_SCHEME_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Coding scheme = MCS5"
- );
- return false;
- }
- short s_arfcn;
- E_BANDSEL band_index;
- int vi_Band;
- FrequencyBand eFreqBand = FrequencyBand850;
- i_N_TX = -99; // TX frames
- //---------------------------------------------------------------------------
- while ( eFreqBand < FrequencyBandCount )
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if(! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM850_FIRST_PCL;
- vi_Band = age1960_GSM850_BAND;
- band_index = BANDSEL_GSM850;
- s_arfcn = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_gsm850_epsk_tx_4cal_pcl;
- as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm850_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm850_epsk_min_p;
- as_epsk_c = m_as_gsm850_epsk_c;
- }
- break;
- case FrequencyBand900:
- {
- if(! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = GSM900_FIRST_PCL;
- vi_Band = age1960_EGSM_BAND;
- band_index = BANDSEL_GSM900;
- s_arfcn = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_gsm900_epsk_tx_4cal_pcl;
- as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm900_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm900_epsk_min_p;
- as_epsk_c = m_as_gsm900_epsk_c;
- }
- break;
- case FrequencyBand1800:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = DCS1800_FIRST_PCL;
- vi_Band = age1960_DCS1800_BAND;
- band_index = BANDSEL_DCS1800;
- s_arfcn = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_dcs1800_epsk_tx_4cal_pcl;
- as_epsk_tx_pcl = m_as_dcs1800_epsk_tx_pcl;
- as_epsk_max_p = m_as_dcs1800_epsk_max_p;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_min_p = m_as_dcs1800_epsk_min_p;
- as_epsk_c = m_as_dcs1800_epsk_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- FIRST_PCL = PCS1900_FIRST_PCL;
- vi_Band = age1960_PCS1900_BAND;
- band_index = BANDSEL_PCS1900;
- s_arfcn = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_TX_LEVEL_4_CAL_COUNT;
- as_epsk_tx_cal_pcl = m_as_pcs1900_epsk_tx_4cal_pcl;
- as_epsk_tx_pcl = m_as_pcs1900_epsk_tx_pcl;
- as_epsk_max_p = m_as_pcs1900_epsk_max_p;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_min_p = m_as_pcs1900_epsk_min_p;
- as_epsk_c = m_as_pcs1900_epsk_c;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
- );
- if (!MF_rf_apc_8psk_ptr->ApcSectionExist(m_pCal->as_IniFile.c_str(), band_index))
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " APC section is not in initial file: " + FreqBand_To_Str(eFreqBand)
- );
- return false;
- }
- if (IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- if(eFreqBand == FrequencyBand1900)
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < target < set Band1900 flag = 1"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- return false;
- }
- #ifdef _MYDEBUG_
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Sleep 100 " + AnsiString(__FILE__)
- );
- #endif
- Sleep( 100 ); // wait Agilent 8960 cell band setup ready!
- // if Agilent 8960 not read, target will get error power!
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- short bch_arfcn = ::Get_SeperateChannel( vi_Band, s_arfcn );
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_arfcn ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_arfcn )
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_arfcn )
- );
- if( ! m_rct_ctrl.RCT_ConfigTSC( m_pRct, m_cTSC ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TSC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if( ! m_rct_ctrl.RCT_EPSK_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 8= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_confTXPower_EPSK( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- // calibration from high power to low power
- // index from big to little.
- // PCL string in config file from right to left.
- int iRealRecursiveTimes = 0;
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- for ( int N=0; N<i_TX_level_count; N++) // DCS,PCS:16~1 or GSM:15~1
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ------------------------------------------------------------------ "
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " N = " + N
- );
- if(! getAnsiStrSubItem( as_epsk_tx_cal_pcl, N+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_cal_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(epsk_sub_tx_cal_pcl)."
- );
- return false;
- }
- for( iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes;
- iRealRecursiveTimes++) // marked by Andy Ueng for no iteration test
- {
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " RecursiveTimes = " + IntToStr(iRealRecursiveTimes)
- );
- if( iRealRecursiveTimes == 0)
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + "," +
- " MF_rf_apc_8psk_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() ))
- );
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue_EPSK[band_index][N] = " + IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_epsk_sub_tx_cal_pcl.ToInt(), m_iApcDcOffset ) )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Get APC DC offset " +
- " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
- " eFreqBand = " + IntToStr( eFreqBand ) +
- " pcl = " + as_epsk_sub_tx_cal_pcl
- );
- return false;
- }
- m_dV_set_EPSK[band_index][N] = (m_iApcDcOffset + m_usPCLDacValue_EPSK[band_index][N]) / 1024.0 * 2.8 * 15.0 / 25.0;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_dV_set_EPSK[band_index][N] = " + Double_To_AnsiString(m_dV_set_EPSK[band_index][N])
- );
- }
- if(! getAnsiStrSubItem( as_epsk_tx_pcl, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_sub_tx_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_cal_pcl 2)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_max_p, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_sub_max_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_min_p, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_sub_min_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_wanted_p, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_c, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()+1, DEFAULT_SEP_CHAR, as_epsk_sub_c) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(c)."
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHMSTxLevel( m_pRct, as_epsk_sub_tx_pcl.ToInt()) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_pcl.ToInt())
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_pcl.ToInt())
- );
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = as_epsk_sub_tx_pcl.ToInt();
- pcl[1] = as_epsk_sub_tx_pcl.ToInt();
- pcl[2] = as_epsk_sub_tx_pcl.ToInt();
- pcl[3] = as_epsk_sub_tx_pcl.ToInt();
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = s_arfcn;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = NB_TX_RANDOM_WITH_TSC;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- #ifdef _MYDEBUG_
- ":" + AnsiString( ms ) +
- #endif
- " Target< TX: ARFCN = " + IntToStr( s_arfcn ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_epsk_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before suspend " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- //log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 7= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_RF_TX_LEVEL_FAIL );
- SUSPEND_CAL_THREAD
- if( RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after resume " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- RestartTimerCal( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_ReadTxPower_EPSK( m_pRct, m_virTX ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < read TX power 1."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- m_dPCL_dBm_EPSK[band_index][N] = m_virTX ;
- m_dPCL_power_EPSK[band_index][N] = pow(10.0, m_dPCL_dBm_EPSK[band_index][N]/10.0)/1000.0;
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- signed short ss1;
- double d1;
- if(iRealRecursiveTimes != i_TXlevelRecusiveTimes-1) //iteration
- {
- if ( m_virTX > (atof(as_epsk_sub_wanted_p.c_str()) + m_dAPC_Delta) ||
- m_virTX < (atof(as_epsk_sub_wanted_p.c_str()) - m_dAPC_Delta))
- {
- d1 = atof(as_epsk_sub_c.c_str()) * (atof(as_epsk_sub_wanted_p.c_str()) - m_virTX );
- // modified by Andy Ueng for always increment 1
- // ss1 = (signed short) (d1>0) ? floor(d1+0.5): ceil(d1-0.5); // to round up or down
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- // end of modified
- // MF_rf_level_ramp_struct.rampData[eFreqBand].power[N] += ss1;
- // MF_rf_apc_ptr->ApcProfile[band_index].rampData[0].power[N] += ss1;
- // if( MF_rf_apc_ptr->ApcProfile[band_index].rampData.power[FIRST_PCL-as_sub_tx_cal_pcl.ToInt()] + ss1 <= 0 )
- if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + ss1) <= 0 )
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt(), 1 );
- }
- else if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + ss1) > MAX_APC_DAC)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt(), MAX_APC_DAC);
- }
- else
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt(), MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + ss1 );
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " power_index = " + IntToStr(FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()) + "," +
- " MF_rf_apc_8psk_ptr->ApcProfile[band_index].rampData.power[power_index] = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt()))
- );
- m_usPCLDacValue_EPSK[band_index][N] = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_usPCLDacValue_EPSK[band_index][N] = " + IntToStr(m_usPCLDacValue_EPSK[band_index][N])
- );
- if( ! MF_rf_apc_ptr->Get_RealApcDcOffset( m_pCal->b_TADOSupport, band_index, as_epsk_sub_tx_cal_pcl.ToInt(), m_iApcDcOffset ) )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Get APC DC offset " +
- " TADO support = " + IntToStr( m_pCal->b_TADOSupport ) +
- " eFreqBand = " + IntToStr( eFreqBand ) +
- " pcl = " + as_epsk_sub_tx_cal_pcl
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " MF_rf_apc_ptr->ApcDcOffset[band_index] = " + IntToStr(m_iApcDcOffset)
- );
- m_dV_set_EPSK[band_index][N] = (m_iApcDcOffset + m_usPCLDacValue_EPSK[band_index][N]) / 1024.0 * 2.8 * 15.0 / 25.0;
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " band_index = " + IntToStr(band_index) + "," +
- " N = " + IntToStr(N) + "," +
- " m_dV_set_EPSK[band_index][N] = " + Double_To_AnsiString(m_dV_set_EPSK[band_index][N])
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = "+
- IntToStr( MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- RfSetRampApcLevel_Req RfSetApcDac;
- RfSetApcDac.rf_band = eFreqBand;
- RfSetApcDac.power_level = as_epsk_sub_tx_cal_pcl.ToInt();
- RfSetApcDac.apc_dac = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() );
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_set_apc_level;
- MF_rf_apc_8psk_ptr->REQ_EPSK_SetRampApcLevel_Start( &RfSetApcDac );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal( WM_MF_SET_APC_DAC_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_SET_APC_DAC_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_epsk_sub_tx_cal_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_sub_tx_cal_pcl.ToInt() ) ) + "n"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_epsk_sub_tx_cal_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, FIRST_PCL-as_epsk_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
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- } // for N
- } // single slot TX
- else // multi-slot TX
- {
- }
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " =========== EPSK TX power control level calibration end =========== n "
- );
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- return true;
- }
- //=========================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_check( void )
- {
- char tempbuf[256];
- AnsiString as_epsk_tx_pcl;
- AnsiString as_epsk_max_p;
- AnsiString as_epsk_min_p;
- AnsiString as_epsk_tx_check_pcl;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_max_p;
- AnsiString as_epsk_sub_min_p;
- AnsiString as_epsk_sub_tx_check_pcl;
- log->Add( "n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== EPSK TX power testing begin =================== n "
- );
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = EGPRS BCH+PDTCH"
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_Config_EPSK_CodingScheme( m_pRct, MCS5 ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_CODING_SCHEME_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Coding scheme = MCS5"
- );
- return false;
- }
- //== test TX level calibration result =========================================
- bool TX_PCL_OUT_OF_RANGE_FLAG = false; // set initial value
- int vi_Band;
- E_BANDSEL band_index;
- FrequencyBand eFreqBand = FrequencyBand850;
- short s_arfcn;
- while (eFreqBand < FrequencyBandCount)
- {
- 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_RAMP_TABLE_TX_LEVEL_COUNT-1;
- as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm850_epsk_max_p;
- as_epsk_tx_check_pcl = m_as_gsm850_epsk_tx_check_pcl;
- as_epsk_min_p = m_as_gsm850_epsk_min_p;
- }
- 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_RAMP_TABLE_TX_LEVEL_COUNT-1;
- as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm900_epsk_max_p;
- as_epsk_tx_check_pcl = m_as_gsm900_epsk_tx_check_pcl;
- as_epsk_min_p = m_as_gsm900_epsk_min_p;
- }
- 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_RAMP_TABLE_TX_LEVEL_COUNT;
- as_epsk_tx_pcl = m_as_dcs1800_epsk_tx_pcl;
- as_epsk_max_p = m_as_dcs1800_epsk_max_p;
- as_epsk_tx_check_pcl = m_as_dcs1800_epsk_tx_check_pcl;
- as_epsk_min_p = m_as_dcs1800_epsk_min_p;
- }
- 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_RAMP_TABLE_TX_LEVEL_COUNT;
- as_epsk_tx_pcl = m_as_pcs1900_epsk_tx_pcl;
- as_epsk_max_p = m_as_pcs1900_epsk_max_p;
- as_epsk_tx_check_pcl = m_as_pcs1900_epsk_tx_check_pcl;
- as_epsk_min_p = m_as_pcs1900_epsk_min_p;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- ///////
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( IsFreqBankSupported( m_asFreqBank, eFreqBand) )
- {
- if( FrequencyBand1900 == eFreqBand )
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 1"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- return false;
- }
- #ifdef _MYDEBUG_
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Sleep 100 " + AnsiString(__FILE__)
- );
- #endif
- Sleep( 100 ); // wait Agilent 8960 ready!
- // if Agilent 8960 not read, target will get error power!
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- short bch_arfcn = ::Get_SeperateChannel( vi_Band, s_arfcn );
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_arfcn ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_arfcn )
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_arfcn )
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( ! m_rct_ctrl.RCT_ConfigTSC( m_pRct, m_cTSC ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TSC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if( ! m_rct_ctrl.RCT_EPSK_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled -5= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_confTXPower_EPSK( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- // calibration from high power to low power
- // index from big to little.
- // PCL string in config file from right to left.
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- for ( int N=1; N<=i_TX_level_count; N++)
- {
- if (! getAnsiStrSubItem( as_epsk_tx_check_pcl, N, DEFAULT_SEP_CHAR, as_epsk_sub_tx_check_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_check_pcl 5)."
- );
- return false;
- }
- if( (as_epsk_sub_tx_check_pcl.ToInt()) == -1) // all check PCL done
- {
- break;
- }
- CheckIndex = cfg->getTXCheckIndex(eFreqBand, as_epsk_tx_pcl, as_epsk_sub_tx_check_pcl);
- if( CheckIndex == -1 ) // not found
- {
- CalErrorHandler( WM_MF_CFG_CHECK_PCL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: CHECK_PCL has problem in CFG file "
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_max_p, CheckIndex, DEFAULT_SEP_CHAR, as_epsk_sub_max_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p 5)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_min_p, CheckIndex, DEFAULT_SEP_CHAR, as_epsk_sub_min_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p 5)."
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHMSTxLevel( m_pRct, as_epsk_sub_tx_check_pcl.ToInt() ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_check_pcl.ToInt())
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( " n" + DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_check_pcl.ToInt())
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = as_epsk_sub_tx_check_pcl.ToInt();
- pcl[1] = as_epsk_sub_tx_check_pcl.ToInt();
- pcl[2] = as_epsk_sub_tx_check_pcl.ToInt();
- pcl[3] = as_epsk_sub_tx_check_pcl.ToInt();
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = s_arfcn;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = NB_TX_RANDOM_WITH_TSC;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< TX: ARFCN = " + IntToStr( s_arfcn ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_epsk_sub_tx_check_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- if( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " TimerCal->Enabled 17= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- );
- RestartTimerCal( WM_MF_RF_TX_LEVEL_FAIL );
- SUSPEND_CAL_THREAD
- if( RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- RestartTimerCal( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_ReadTxPower_EPSK( m_pRct, m_virTX ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- 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;
- }
- m_dPCL_dBm_EPSK[band_index][N] = m_virTX ;
- sprintf(tempbuf, "%2.1f", m_virTX);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- TxdBmStr = TxdBmStr + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, N-1 ) ) + ", ";
- frmFatcory->DisableAllCalTimer();
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( m_virTX > atof(as_epsk_sub_max_p.c_str()) || m_virTX < atof(as_epsk_sub_min_p.c_str()))
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Out of Range ), min TX power = " + as_epsk_sub_min_p + ", max TX power = " + as_epsk_sub_max_p
- );
- TX_PCL_OUT_OF_RANGE_FLAG = true;
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT+ " > read TX power = "+ Double_To_AnsiString( m_virTX ) +
- " ( Pass ), min TX power = " + as_epsk_sub_min_p + ", max TX power = " + as_epsk_sub_max_p
- );
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for N
- } // single slot TX
- else // multi slot TX
- {
- }
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + TxdBmStr;
- Sleep(50);
- if( TX_PCL_OUT_OF_RANGE_FLAG )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : TX level check " + "n"
- );
- frmFatcory->DisableAllCalTimer();
- 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;
- }
- return false;
- }
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- return true;
- } // end of TX level calibration
- //===========================================================================
- bool __fastcall T_META_factory_calibration::TXPCLCal_EPSK_FullCal( void )
- {
- char tempbuf[256];
- int i_Remain_TX_level_count;
- AnsiString as_epsk_tx_pcl;
- AnsiString as_epsk_max_p;
- AnsiString as_epsk_wanted_p;
- AnsiString as_epsk_min_p;
- AnsiString as_epsk_c;
- AnsiString as_epsk_sub_tx_pcl;
- AnsiString as_epsk_sub_max_p;
- AnsiString as_epsk_sub_wanted_p;
- AnsiString as_epsk_sub_min_p;
- AnsiString as_epsk_sub_c;
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ========== EPSK TX power control level calibration begin ========== n "
- );
- if( ! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_EGPRS_BCH_PDTCH ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Operation mode = EGPRS BCH+TCH"
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_Config_EPSK_CodingScheme( m_pRct, MCS5 ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_CODING_SCHEME_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Coding scheme = MCS5"
- );
- return false;
- }
- short s_arfcn;
- FrequencyBand eFreqBand = FrequencyBand850;
- i_N_TX = -99;// TX frames
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- //---------------------------------------------------------------------------
- E_BANDSEL band_index;
- int vi_Band;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM850;
- vi_Band = age1960_GSM850_BAND;
- s_arfcn = m_sARFCN_C0_GSM850;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT-4;
- i_Remain_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT-1;
- as_epsk_tx_pcl = m_as_gsm850_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm850_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm850_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm850_epsk_min_p;
- as_epsk_c = m_as_gsm850_epsk_c;
- }
- break;
- case FrequencyBand900:
- {
- if(! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_GSM900;
- vi_Band = age1960_EGSM_BAND;
- s_arfcn = m_sARFCN_C0_GSM;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT-4;
- i_Remain_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT-1;
- as_epsk_tx_pcl = m_as_gsm900_epsk_tx_pcl;
- as_epsk_max_p = m_as_gsm900_epsk_max_p;
- as_epsk_wanted_p = m_as_gsm900_epsk_wanted_p;
- as_epsk_min_p = m_as_gsm900_epsk_min_p;
- as_epsk_c = m_as_gsm900_epsk_c;
- }
- break;
- case FrequencyBand1800:
- {
- if(! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_DCS1800;
- vi_Band = age1960_DCS1800_BAND;
- s_arfcn = m_sARFCN_C0_DCS;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT-2;
- i_Remain_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT;
- as_epsk_tx_pcl = m_as_dcs1800_epsk_tx_pcl;
- as_epsk_max_p = m_as_dcs1800_epsk_max_p;
- as_epsk_wanted_p = m_as_dcs1800_epsk_wanted_p;
- as_epsk_min_p = m_as_dcs1800_epsk_min_p;
- as_epsk_c = m_as_dcs1800_epsk_c;
- }
- break;
- case FrequencyBand1900:
- {
- if (!IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- band_index = BANDSEL_PCS1900;
- vi_Band = age1960_PCS1900_BAND;
- s_arfcn = m_sARFCN_C0_PCS;
- i_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT-2;
- i_Remain_TX_level_count = RF_RAMP_TABLE_TX_LEVEL_COUNT;
- as_epsk_tx_pcl = m_as_pcs1900_epsk_tx_pcl;
- as_epsk_max_p = m_as_pcs1900_epsk_max_p;
- as_epsk_wanted_p = m_as_pcs1900_epsk_wanted_p;
- as_epsk_min_p = m_as_pcs1900_epsk_min_p;
- as_epsk_c = m_as_pcs1900_epsk_c;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (!MF_rf_apc_8psk_ptr->ApcSectionExist(m_pCal->as_IniFile.c_str(), band_index))
- {
- CalErrorHandler(WM_MF_RF_TX_LEVEL_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " APC section is not in initial file: " + FreqBand_To_Str(eFreqBand)
- );
- return false;
- }
- if (IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- if( FrequencyBand1900 == eFreqBand )
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 1"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = 0"
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- return false;
- }
- #ifdef _MYDEBUG_
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Sleep 100 " + AnsiString(__FILE__)
- );
- #endif
- Sleep( 100 ); // wait Agilent 8960 cell band setup ready!
- // if Agilent 8960 not read, target will get error power!
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < Band = " + ViBand_To_Str( vi_Band )
- );
- short bch_arfcn = ::Get_SeperateChannel( vi_Band, s_arfcn );
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, bch_arfcn) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < BCH ARFCN = " + IntToStr( bch_arfcn )
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHARFCN( m_pRct, s_arfcn ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_PDTCH_ARFCN_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_arfcn )
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < PDTCH ARFCN = " + IntToStr( s_arfcn )
- );
- if( ! m_rct_ctrl.RCT_ConfigTSC( m_pRct, m_cTSC ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TSC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL: " + m_pRct->as_RCT + " < set TSC fail."
- );
- return false;
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < TSC = " + IntToStr( m_cTSC)
- );
- if( ! m_rct_ctrl.RCT_EPSK_TXPowerContOff( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_TX_POWER_CONT_OFF_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < set TX power continuous OFF "
- );
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 12= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_confTXPower_EPSK( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_CONFIG_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < config TX power 1."
- );
- return false;
- }
- // calibration from high power to low power
- // index from big to little.
- // PCL string in config file from right to left.
- if( TX_SLOT_SINGLE == m_pCal->e_tx_slot )
- {
- for ( int N=i_TX_level_count; N>0; N--) // DCS,PCS:16~1 or GSM:15~1
- {
- if(! getAnsiStrSubItem( as_epsk_tx_pcl, N, DEFAULT_SEP_CHAR, as_epsk_sub_tx_pcl) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_tx_pcl 3)."
- );
- return false;
- }
- sprintf(tempbuf, "%3d", as_epsk_sub_tx_pcl.ToInt());
- if (! getAnsiStrSubItem( as_epsk_max_p, N, DEFAULT_SEP_CHAR, as_epsk_sub_max_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_max_p 3)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_min_p, N, DEFAULT_SEP_CHAR, as_epsk_sub_min_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_min_p 3)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_wanted_p, N, DEFAULT_SEP_CHAR, as_epsk_sub_wanted_p) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_wanted_p 3)."
- );
- return false;
- }
- if(! getAnsiStrSubItem( as_epsk_c, N, DEFAULT_SEP_CHAR, as_epsk_sub_c) )
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail(sub_c 3)."
- );
- return false;
- }
- for( int iRealRecursiveTimes=0; iRealRecursiveTimes<i_TXlevelRecusiveTimes;
- iRealRecursiveTimes++)
- {
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( ! m_rct_ctrl.RCT_PDTCHMSTxLevel( m_pRct, as_epsk_sub_tx_pcl.ToInt() ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_MS_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_pcl.ToInt())
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < MS TX level = " + IntToStr( as_epsk_sub_tx_pcl.ToInt())
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- int pcl[4];
- CodingScheme cs[4];
- cs[0] = CodingSchemeMCS5;
- cs[1] = CodingSchemeMCS5;
- cs[2] = CodingSchemeMCS5;
- cs[3] = CodingSchemeMCS5;
- pcl[0] = as_epsk_sub_tx_pcl.ToInt();
- pcl[1] = as_epsk_sub_tx_pcl.ToInt();
- pcl[2] = as_epsk_sub_tx_pcl.ToInt();
- pcl[3] = as_epsk_sub_tx_pcl.ToInt();
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_pCal->b_MultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = band_index;
- multi_slot_tx.req.arfcn = s_arfcn;
- multi_slot_tx.req.bsic = m_cTSC;
- multi_slot_tx.req.timeSlotmask = 0x01;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = pcl[i];
- multi_slot_tx.req.cs[i] = cs[i];
- }
- multi_slot_tx.req.ta = 0;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sDefault_value;
- multi_slot_tx.req.pattern = NB_TX_RANDOM_WITH_TSC;
- multi_slot_tx.req.pattern_data = 0;
- RF_MULTI_SLOT_TX_Obj.ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj.REQ_Start(multi_slot_tx);
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- #endif
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- #ifdef _MYDEBUG_
- ":" + AnsiString( ms ) +
- #endif
- " Target< TX: ARFCN = " + IntToStr( s_arfcn ) +
- ", TSC = " + IntToStr( m_cTSC ) +
- ", power = " + as_epsk_sub_tx_pcl +
- ", frames = " + IntToStr(i_N_TX) +
- ", dac value = " + IntToStr( m_sDefault_value )
- );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before suspend " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 11= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_RF_TX_LEVEL_FAIL );
- SUSPEND_CAL_THREAD
- if( RF_MULTI_SLOT_TX_Obj.Get_ConfirmState() != METAAPP_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_TX_LEVEL_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < multislot TX fail."
- );
- return false;
- }
- #ifdef _MYDEBUG_
- // TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- // log->Add( " after resume " + DateToStr(Date()) + " " + CurrentTimeStr() +
- // ":" + AnsiString( ms )
- // );
- #endif
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " before read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- RestartTimerCal( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- if( ! m_rct_ctrl.RCT_ReadTxPower_EPSK( m_pRct, m_virTX ) )
- {
- CalErrorHandler( WM_MF_AGE8960_READ_TX_POWER_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_pRct->as_RCT + " > read TX power."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- #ifdef _MYDEBUG_
- TDateTime::CurrentTime().DecodeTime(&hr, &min, &sec, &ms );
- log->Add( " after read TX power Q " + DateToStr(Date()) + " " + CurrentTimeStr() +
- ":" + AnsiString( ms )
- );
- #endif
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " " +
- m_pRct->as_RCT + " < read TX power = "+ Double_To_AnsiString( m_virTX )
- );
- signed short ss1;
- double d1;
- if( m_virTX > (atof(as_epsk_sub_wanted_p.c_str()) + m_dAPC_Delta) ||
- m_virTX < (atof(as_epsk_sub_wanted_p.c_str()) - m_dAPC_Delta))
- {
- d1 = atof(as_epsk_sub_c.c_str()) * (atof(as_epsk_sub_wanted_p.c_str()) - m_virTX );
- // ss1 = (signed short) (d1>0) ? floor(d1+0.5): ceil(d1-0.5); // to round up or down
- ss1 = (signed short) (d1>0) ? floor(d1+1.0): ceil(d1-1.0);
- if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, N-1) + ss1) <= 0)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, N-1, 1);
- }
- else if ((MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index, N-1) + ss1) > MAX_APC_DAC)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower(band_index, N-1, MAX_APC_DAC);
- }
- else
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, N-1, MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index,N-1) + ss1 );
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = " +
- IntToStr( MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, N-1 ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = "+
- AnsiString( ss1 )
- );
- RfSetRampApcLevel_Req RfSetApcDac;
- RfSetApcDac.rf_band = eFreqBand;
- RfSetApcDac.power_level = as_epsk_sub_tx_pcl.ToInt();
- RfSetApcDac.apc_dac = MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, N-1 );
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_set_apc_level;
- MF_rf_apc_8psk_ptr->REQ_EPSK_SetRampApcLevel_Start( &RfSetApcDac );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- RestartTimerCal ( WM_MF_SET_APC_DAC_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_apc_8psk_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler( WM_MF_SET_APC_DAC_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target< set APC level fail. PCL = "+ as_epsk_sub_tx_pcl +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, N-1 ) ) + "n"
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target< set APC level ok. PCL = "+ as_epsk_sub_tx_pcl + "," +
- " APC DAC = " + IntToStr(MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, N-1 ) ) + "n"
- );
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " new S = " +
- IntToStr( MF_rf_apc_8psk_ptr->Get_ApcProfilePower( band_index, N-1 ) )
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta s = 0n"
- );
- break; // for iRealRecursiveTimes
- }
- if( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // for iRealRecursiveTimes
- sprintf(tempbuf, "%2.1f", m_virTX);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- } // for N
- } // single slot TX
- else
- {
- }
- for( int N=i_Remain_TX_level_count; N>i_TX_level_count; N--)
- {
- MF_rf_apc_8psk_ptr->Set_ApcProfilePower( band_index, N-1, MF_rf_apc_8psk_ptr->Get_ApcProfilePower(band_index,i_TX_level_count-1) );
- }
- // write full calibration result to NVRAM
- MF_rf_apc_8psk_ptr->ConfirmCallback = ::ccb_write_apc_to_nvram;
- MF_rf_apc_8psk_ptr->REQ_Write_APC_To_NVRAM_Single_Band_Start(m_pCal->ui_rf_id, band_index);
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled 14= " + IntToStr((int)Form_META_Factory->TimerCal->Enabled)
- // );
- RestartTimerCal( WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- WriteEpskAPCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, FreqBand_To_BandIdx(eFreqBand) );
- eFreqBand++;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- } // while
- RestartTimerCal(WM_MF_RF_STOP_FAIL);
- if (!MF_rf_stop.REQ_Start())
- {
- CalErrorHandler(WM_MF_RF_STOP_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return false;
- }
- frmFatcory->DisableAllCalTimer();
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " =========== EPSK TX power control level calibration end =========== n "
- );
- return true;
- } // full PCL calibration end