T_RX_path_loss.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:30k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * T_RX_path_loss.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RX path loss calibration source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include <assert.h>
- #include <math.h>
- #pragma hdrstop
- #ifndef _T_META_FACTORY_CALIBRATION_H_
- #include "T_META_factory_calibration.H"
- #endif
- #ifndef _CAL_COMMON_H_
- #include "cal_common.h"
- #endif
- // callback
- #ifndef _META_FACTORY_RF_CB_H_
- #include "meta_factory_rf_cb.h"
- #endif
- #ifndef _META_FACTORY_NVRAM_CB_H_
- #include "meta_factory_nvram_cb.h"
- #endif
- // form
- #ifndef _META_FACTORY_H_
- #include "META_Factory.h"
- #endif
- #ifndef _FORM_MAIN_H_
- #include "form_main.h"
- #endif
- // equipment
- #ifndef _AGECOMMON_H_
- #include "agecommon.h"
- #endif
- #ifndef _AGE_MISC_H_
- #include "age_misc.h"
- #endif
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _MATH_UTILS_H_
- #include "math_utils.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- //----------------------------------------------------------------------------
- // RX path loss
- extern CRFAGC* MF_rf_agc_ptr;
- extern RfPm_Req *MF_rf_pm_req;
- extern RfPm_Cnf *MF_rf_pm_cnf;
- extern bool is_suspend_cal; // in T_META_factory_calibration.cpp
- //******************************************************************************
- // RX path loss calibration
- //******************************************************************************
- bool __fastcall T_META_factory_calibration::RxPathLossCal( void )
- {
- AnsiString as_all_arfcn, as_arfcn;
- char tempbuf[256];
-
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_PM_BEGIN,
- 0,
- 0
- );
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================== Path loss calibration begin ==================="
- );
- if(! m_rct_ctrl.RCT_operatingMode( m_pRct, OPERATING_MODE_GSM_BCH ))
- {
- CalErrorHandler( WM_MF_AGE8960_SET_OPERATION_MODE_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Operation mode = GSM BCH"
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = Operation mode = GSM BCH"
- );
- }
- return false;
- }
- FrequencyBand eFreqBand = FrequencyBand850;
- for (int J=0; J< FrequencyBandCount; J++)
- {
- for ( int K=0; K < PLTABLE_SIZE; K++)
- MF_rf_pm_power[J][K] = 0;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- l1cal_agcPathLoss_T* p_path_loss = MF_rf_agc_ptr->Get_PathLoss();
- l1cal_agcPathLoss_T path_loss = *p_path_loss;
- int vi_Band;
- while (eFreqBand < FrequencyBandCount)
- {
- switch (eFreqBand)
- {
- case FrequencyBand850:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_GSM850_BAND;
- }
- break;
- case FrequencyBand900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_EGSM_BAND;
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_DCS1800_BAND;
- }
- break;
- case FrequencyBand1900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- vi_Band = age1960_PCS1900_BAND;
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if (!MF_rf_agc_ptr->RxLossSectionExist(m_pCal->as_IniFile.c_str(), eFreqBand))
- {
- CalErrorHandler(WM_MF_RF_PM_INI_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " RX pathloss section is not in initial file: " + FreqBand_To_Str(eFreqBand)
- );
- return false;
- }
- if( ! m_rct_ctrl.RCT_cellBand( m_pRct, vi_Band ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Band = " + ViBand_To_Str( vi_Band )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = " + ViBand_To_Str( vi_Band )
- );
- }
- return false;
- }
- if( ! m_rct_ctrl.RCT_PowTranCont( m_pRct ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BAND_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960< Band = " + ViBand_To_Str( vi_Band )
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " cmu200 < Band = " + ViBand_To_Str( vi_Band )
- );
- }
- return false;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< band = " +
- FreqBand_To_Str( eFreqBand) );
- }
- if( ! m_rct_ctrl.RCT_cellPower( m_pRct, d_P_DL ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_POWER_FAIL );
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< Power = " +
- Double_To_AnsiString( d_P_DL) ) + " dBm";
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200< Power = " +
- Double_To_AnsiString( d_P_DL) ) + " dBm";
- }
- return false;
- }
-
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< Power = " +
- Double_To_AnsiString( d_P_DL) );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< Power = " +
- Double_To_AnsiString( d_P_DL) );
- }
- if (IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- if(eFreqBand == FrequencyBand1900)
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 1, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_PM_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 1 "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 1"
- );
- }
- else
- {
- if(META_Rf_SelectFrequencyBand1900_r( m_pCal->i_MainMETAHandle, 0, MF_SelectBand_cnf_cb, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- CalErrorHandler( WM_MF_RF_PM_SELECT_BAND_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < set Band1900 flag = 0 "
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < set Band1900 flag = 0"
- );
- }
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- }
- {
- for ( int I=0; I< PLTABLE_SIZE; I++)
- {
- short s_pm_arfcn = path_loss.agcPathLoss[eFreqBand][I].max_arfcn;
- if ( s_pm_arfcn != MF_RF_LAST_ELEMENT )
- {
- if ( s_pm_arfcn >=1024)
- s_pm_arfcn = 1023;
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if( ! m_rct_ctrl.RCT_BCHARFCN( m_pRct, s_pm_arfcn ) )
- {
- CalErrorHandler( WM_MF_AGE8960_SET_BCH_ARFCN_FAIL );
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960< BCH ARFCN = " +
- IntToStr(s_pm_arfcn)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < BCH ARFCN = " +
- IntToStr(s_pm_arfcn)
- );
- }
- return false;
- }
-
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- if ( frmFatcory->rbAgilent8960->Checked )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 8960< BCH ARFCN = " +
- AnsiString(s_pm_arfcn)
- );
- }
- else
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " CMU 200< BCH ARFCN = " +
- AnsiString(s_pm_arfcn)
- );
- }
-
- #ifdef _MYDEBUG
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Sleep 100 " + AnsiString(__FILE__)
- );
- #endif
- // if( frmFatcory->cbAFC->Checked )
- // {
- // Sleep( 100 ); // wait Agilent 8960 ready!
- // }
- // else
- {
- Sleep( 200 ); // wait Agilent 8960 ready!
- }
- // if Agilent 8960 not read, target will get error power!
- MF_rf_pm_cnf->deviation = 0;
- MF_rf_pm_cnf->power = 0;
- MF_rf_pm_cnf->usedGain = 0;
- MF_rf_pm_req->arfcn = s_pm_arfcn;
- MF_rf_pm_req->sampleNoPerFrame = cM_PM;
- MF_rf_pm_req->gain = (MF_RF_GAIN_TO_BE_SUB - d_P_DL) *AVG_POWER_PC_SIDE_MULTIPLY ;
- MF_rf_pm_req->frames = iN_PM;
- if( META_Rf_PM_r( m_pCal->i_MainMETAHandle, MF_rf_pm_req, MF_rf_pm_cnf_cb, &MF_rf_pm_token, NULL ) != META_SUCCESS )
- {
- CalErrorHandler( WM_MF_RF_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_pm_arfcn ) +
- " sample per frame = " + IntToStr( cM_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( iN_PM)
- );
- return false;
- } // if
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < PM : ARFCN = " + IntToStr( s_pm_arfcn) +
- ", sample per frame = " + IntToStr( cM_PM) +
- ", gain = " + IntToStr( MF_rf_pm_req->gain ) +
- ", frames = " + IntToStr( iN_PM)
- );
- // Sleep(100);// delay for power measurement
-
- RestartTimerCal( WM_MF_RF_PM_FAIL );
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- if ( this->Terminated )
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Terminate at line " + AnsiString(__FILE__) + " " + AnsiString(__LINE__)
- );
- this->OnTerminate = neByUser;
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target > power = " + Double_To_AnsiString(MF_rf_pm_cnf->power/8.0)
- );
- // (db)
- MF_rf_pm_power[eFreqBand][ I ] =
- (d_P_DL - (MF_rf_pm_cnf->power)/AVG_POWER_PC_SIDE_MULTIPLY );
- // gain_offset = MF_rf_agc_ptr->AgcPathLoss.agcPathLoss[eFreqBand][I].gain_offset + ( MF_rf_pm_power[eFreqBand][ I ]*GAIN_OFFSET_PC_MULTIPLY);
- float gain_offset = path_loss.agcPathLoss[eFreqBand][I].gain_offset + ( MF_rf_pm_power[eFreqBand][ I ]*GAIN_OFFSET_PC_MULTIPLY);
- if( gain_offset <= -128 || gain_offset >= 127)
- {
- CalErrorHandler( WM_MF_RF_PM_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: "+
- " Target < PM : ARFCN = " + IntToStr( s_pm_arfcn ) +
- " sample per frame = " + IntToStr( cM_PM) +
- " gain = " + IntToStr( MF_rf_pm_req->gain ) +
- " frames = " + IntToStr( iN_PM) +
- " path loss = " + Double_To_AnsiString( gain_offset / GAIN_OFFSET_PC_MULTIPLY )
- );
- return false;
- }
- path_loss.agcPathLoss[eFreqBand][I].gain_offset +=
- (signed char)( MF_rf_pm_power[eFreqBand][ I ]*GAIN_OFFSET_PC_MULTIPLY);
- //MF_rf_agc_ptr->AgcPathLoss.agcPathLoss[eFreqBand][I].gain_offset +=
- // (signed char)( MF_rf_pm_power[eFreqBand][ I ]*GAIN_OFFSET_PC_MULTIPLY);
- //sprintf(tempbuf, "%2.3f", MF_rf_agc_ptr->AgcPathLoss.agcPathLoss[eFreqBand][I].gain_offset/GAIN_OFFSET_PC_MULTIPLY);
- sprintf(tempbuf, "%2.3f", path_loss.agcPathLoss[eFreqBand][I].gain_offset/GAIN_OFFSET_PC_MULTIPLY);
- m_pCal->as_ResultBuf = m_pCal->as_ResultBuf + tempbuf + ", ";
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " delta L = " +
- IntToStr((signed char)( MF_rf_pm_power[eFreqBand][ I ]*GAIN_OFFSET_PC_MULTIPLY))+
- "n"
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- }
- else // if ( as_arfcn.ToInt() != MF_RF_LAST_ELEMENT )
- {
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- break;
- } // else
- } // for 1 Band
- } // if
- MF_rf_agc_ptr->Set_PathLoss(path_loss);
- WriteAGCCalResultToFile(as_ID+".cal",Application->ExeName, m_pCal->b_CalResultPath, eFreqBand );
- eFreqBand++;
- } // while ( eFreqBand <= 5 )
- //WriteAGCCalResultToFile(as_ID+".cal",Application->ExeName, frmFatcory->b_CalResultPath );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " =================== Path loss calibration end ==================== n "
- );
- // ---------------------------- RX path loss check begin --------------------------
- log->Add( "n" + DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================ Path loss calibration check begin =============== "
- );
- AnsiString as_max_rx_loss_p, as_min_rx_loss_p;
- AnsiString sub_max_rx_loss_p, sub_min_rx_loss_p;
- as_max_rx_loss_p = "";
- as_min_rx_loss_p = "";
- eFreqBand =FrequencyBand850;
- while (eFreqBand < FrequencyBandCount) // only for 850, 900, 1800, 1900
- {
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- //////
- switch ( eFreqBand )
- {
- case FrequencyBand850:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- cfg->getGSM850_MAX_RX_LOSS( as_max_rx_loss_p );
- cfg->getGSM850_MIN_RX_LOSS( as_min_rx_loss_p );
- }
- break;
- case FrequencyBand900:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- cfg->getGSM900_MAX_RX_LOSS( as_max_rx_loss_p );
- cfg->getGSM900_MIN_RX_LOSS( as_min_rx_loss_p );
- }
- break;
- case FrequencyBand1800:
- {
- if (! IsFreqBankSupported( m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- cfg->getDCS1800_MAX_RX_LOSS(as_max_rx_loss_p);
- cfg->getDCS1800_MIN_RX_LOSS(as_min_rx_loss_p);
- }
- break;
- case FrequencyBand1900:
- {
- if (! IsFreqBankSupported(m_asFreqBank, eFreqBand))
- {
- eFreqBand++;
- continue;
- }
- cfg->getPCS1900_MAX_RX_LOSS( as_max_rx_loss_p );
- cfg->getPCS1900_MIN_RX_LOSS( as_min_rx_loss_p );
- }
- break;
- default:
- assert(false);
- break;
- } // switch
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " -------------------------------------------------- "
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- FreqBand_To_Str(eFreqBand)
- );
- for ( int I=1; I< PLTABLE_SIZE; I++)
- {
- // if ( MF_rf_agc_ptr->AgcPathLoss.agcPathLoss[eFreqBand][I-1].max_arfcn == -1)
- if (-1 == path_loss.agcPathLoss[eFreqBand][I-1].max_arfcn)
- { break;
- }
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- sub_max_rx_loss_p ="0";
- if(! getAnsiStrSubItem( as_max_rx_loss_p, I, DEFAULT_SEP_CHAR, sub_max_rx_loss_p ))
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail.5"
- );
- return false;
- }
- sub_min_rx_loss_p ="0";
- if(! getAnsiStrSubItem( as_min_rx_loss_p, I, DEFAULT_SEP_CHAR, sub_min_rx_loss_p ))
- {
- CalErrorHandler( WM_MF_CFG_READ_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail.6"
- );
- return false;
- }
- if( sub_min_rx_loss_p != NULL && sub_max_rx_loss_p != NULL)
- {
- double d_min_rx_loss_p = atof(sub_min_rx_loss_p.c_str());
- // double d_rx_loss_p = MF_rf_agc_ptr->AgcPathLoss.agcPathLoss[eFreqBand][I-1].gain_offset / AVG_POWER_PC_SIDE_MULTIPLY;
- double d_rx_loss_p = path_loss.agcPathLoss[eFreqBand][I-1].gain_offset / AVG_POWER_PC_SIDE_MULTIPLY;
- double d_max_rx_loss_p = atof(sub_max_rx_loss_p.c_str());
- if( (d_min_rx_loss_p<=d_rx_loss_p) && (d_rx_loss_p<= d_max_rx_loss_p))
- {
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " PASS: RX path loss check -- " + "ARFCN = " + IntToStr(MF_rf_agc_ptr->AgcPathLoss.agcPathLoss[eFreqBand][I-1].max_arfcn) + "n" +
- " PASS: RX path loss check -- " + "ARFCN = " + IntToStr(path_loss.agcPathLoss[eFreqBand][I-1].max_arfcn) + "n" +
- " path loss = " + Double_To_AnsiString(d_rx_loss_p)+ "n" +
- " min rx path loss = " + Double_To_AnsiString(d_min_rx_loss_p) + "n" +
- " max rx path loss = " + Double_To_AnsiString(d_max_rx_loss_p) + "n"
- );
- }
- else
- {
- CalErrorHandler( WM_MF_RF_PM_CHECK_FAIL );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " Fail: RX path loss check -- " + "ARFCN = " + IntToStr(MF_rf_agc_ptr->AgcPathLoss.agcPathLoss[eFreqBand][I-1].max_arfcn) + "n" +
- " Fail: RX path loss check -- " + "ARFCN = " + IntToStr(path_loss.agcPathLoss[eFreqBand][I-1].max_arfcn) + "n" +
- " path loss = " + Double_To_AnsiString(d_rx_loss_p)+ "n" +
- " min rx path loss = " + Double_To_AnsiString(d_min_rx_loss_p) + "n" +
- " max rx path loss = " + Double_To_AnsiString(d_max_rx_loss_p) + "n"
- );
- return false;
- }
- }//if
- } // for
- eFreqBand++;
- } // while
- // ---------------------------- RX path loss check end ----------------------------
- //////////////// write to agc fdm
- MF_rf_agc_ptr->Set_PathLoss(path_loss);
- MF_rf_agc_ptr->ConfirmCallback = ccb_write_agc_to_nvram;
- MF_rf_agc_ptr->REQ_Write_To_NVRAM_Start();
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- // log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- // " TimerCal->Enabled -3= " + IntToStr((int)frmFatcory->TimerCal->Enabled)
- // );
- RestartTimerCal(WM_MF_NVRAM_PATH_LOSS_WRITE_FAIL);
- is_suspend_cal = true;
- this->Suspend();
- is_suspend_cal = false;
- E_METAAPP_RESULT_T state = MF_rf_agc_ptr->Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- if (METAAPP_NVRAM_LID_VER_NOT_SUPPORT == state)
- {
- CalErrorHandler(WM_MF_NVRAM_EF_L1_AGCPATHLOSS_LID_VERNO_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : NVRAM_EF_L1_AGCPATHLOSS_LID version is not support, please update META to latest version. "
- );
- }
- else
- {
- CalErrorHandler(WM_MF_NVRAM_PATH_LOSS_WRITE_FAIL);
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < Write path loss to NVRAM "
- );
- }
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " Target < Write path loss to NVRAM "
- );
- if ( this->Terminated )
- {
- this->OnTerminate = neByUser;
- return false;
- }
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_RF_PM_CALIBRATION_DONE,
- 0,
- 0
- );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " ================ Path loss calibration check end ================= n "
- );
- //// Path loss calibration end ///////////////////////////////////////////////
- frmFatcory->DisableAllCalTimer();
- return true;
- }