rf_rtc.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:
- * ---------
- * rf_rtc.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF RTC 32K colock 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 <IniFiles.hpp>
- #include <stdio.h>
- #pragma hdrstop
- // RF
- #ifndef _RF_COMMON_H_
- #include "rf_common.h"
- #endif
- #ifndef _RF_STOP_H_
- #include "rf_stop.h"
- #endif
- #ifndef _RF_RTC_H_
- #include "rf_rtc.h"
- #endif
- #ifndef _RF_AFC_H_
- #include "rf_afc.h"
- #endif
- #ifndef _RF_TX_H_
- #include "rf_tx.h"
- #endif
- #ifndef _META_CONST_H_
- #include "meta_const.h"
- #endif
- // message
- #ifndef _META_LAB_MSG_H_
- #include "meta_lab_msg.h"
- #endif
- // equipment
- #ifndef _RCT_CTRL_H_
- #include "rct_ctrl.h"
- #endif
- #ifndef _AGECOMMON_H_
- #include "AgeCommon.h"
- #endif
- // misc
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _MATH_UTILS_H_
- #include "math_utils.h"
- #endif
- CRFRTC* g_rf_rtc_ptr;
- //==============================================================================
- static void CNF_ReadFromNVRAM(void)
- {
- g_rf_rtc_ptr->CNF_ReadFromNVRAM();
- }
- //------------------------------------------------------------------------------
- static void CNF_RF_STOP(void)
- {
- g_rf_rtc_ptr->CNF_RF_STOP();
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_SelectPcs1900(const unsigned char cnf, const short token, void *usrData)
- {
- g_rf_rtc_ptr->CNF_SelectPcs1900(cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_RfAfc(const RfAfc_Cnf *cnf, const short token, void *usrData)
- {
- g_rf_rtc_ptr->CNF_RfAfc(cnf, token, usrData);
- }
- //------------------------------------------------------------------------------
- static void __stdcall CNF_RfNbTx(const unsigned char cnf, const short token, void *usrData)
- {
- g_rf_rtc_ptr->CNF_RfNbTx(cnf, token, usrData);
- }
- //==============================================================================
- void CRFRTC::CNF_ReadFromNVRAM(void)
- {
- this->Resume();
- }
- //-----------------------------------------------------------------------------
- void CRFRTC::CNF_RF_STOP(void)
- {
- this->Resume();
- }
- //-----------------------------------------------------------------------------
- void __stdcall CRFRTC::CNF_SelectPcs1900(const unsigned char cnf, const short token, void *usrData)
- {
- m_ucSelectPcsCnf = cnf;
- this->Resume();
- }
- //-----------------------------------------------------------------------------
- void __stdcall CRFRTC::CNF_RfAfc(const RfAfc_Cnf *cnf, const short token, void *usrData)
- {
- m_sRfAfcCnf = *cnf;
- this->Resume();
- }
- //-----------------------------------------------------------------------------
- void __stdcall CRFRTC::CNF_RfNbTx(const unsigned char cnf, const short token, void *usrData)
- {
- m_ucNbTxCnf = cnf;
- this->Resume();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void _fastcall CRFRTC::ShowMsg()
- {
- ShowMessage(m_asMsg);
- }
- //------------------------------------------------------------------------------
- void _fastcall CRFRTC::SyncShowMsg(AnsiString as)
- {
- m_asMsg = as;
- Synchronize(ShowMsg);
- }
- //=========================================================================================
- __fastcall CRFRTC::CRFRTC(bool CreateSuspended, S_RF_RTC_T* p_rf_rtc, S_RCT* p_rct): TThread(CreateSuspended)
- {
- m_psRfRtc = p_rf_rtc;
- m_psRct = p_rct;
- }
- //---------------------------------------------------------------------------
- void __fastcall CRFRTC::Execute()
- {
- g_rf_rtc_ptr = this;
- read_cfg_file();
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_Init(m_psRct, m_psRfRtc->as_FreqBand))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_INIT_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_psRct->as_RCT + " < Initialize"
- );
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_Init(m_psRct, m_psRfRtc->as_FreqBand))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_INIT_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_psRct->as_RCT + " < Initialize"
- );
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- if (!m_rct_ctrl.RCT_operatingMode(m_psRct, OPERATING_MODE_GSM_BCH_TCH))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_OPERATION_MODE_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_psRct->as_RCT + " < Operation mode = GSM BCH+TCH"
- );
- return;
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- int vi_Band = BandIdx_To_AgeBand(m_psRfRtc->e_band);
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_cellBand(m_psRct, vi_Band))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_BAND_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " Agilent 8960 < Band = " + ViBand_To_Str( vi_Band )
- );
- write_log_file();
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_cellBand(m_psRct, vi_Band))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_BAND_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- " CMU 200 < Band = " + ViBand_To_Str(vi_Band)
- );
- write_log_file();
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_cellPower(m_psRct, m_psRfRtc->d_P_DL))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_DOWNLINK_POWER_FAIL,
- 0,
- 0);
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: " + m_psRct->as_RCT + " < Power = " +
- Double_To_AnsiString(m_psRfRtc->d_P_DL) + " dBm" );
- write_log_file();
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_cellPower(m_psRct, m_psRfRtc->d_P_DL))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_DOWNLINK_POWER_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: " + m_psRct->as_RCT + " < Power = " +
- Double_To_AnsiString(m_psRfRtc->d_P_DL) + " dBm");
- write_log_file();
- return;
- }
- if (!m_rct_ctrl.RCT_sig_TCHLevel(m_psRct, -70.0))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_TCH_LEVEL_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: cmu200 < Power = " +
- Double_To_AnsiString(-70.0) + " dBm");
- write_log_file();
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_BCHARFCN(m_psRct, m_psRfRtc->s_arfcn))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_BCH_ARFCN_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : "+
- m_psRct->as_RCT + " < BCH ARFCN = " + IntToStr( m_psRfRtc->s_arfcn )
- );
- write_log_file();
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_BCHARFCN(m_psRct, m_psRfRtc->s_arfcn))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_BCH_ARFCN_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_psRct->as_RCT + " < BCH ARFCN = " + IntToStr(m_psRfRtc->s_arfcn )
- );
- write_log_file();
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_TCHARFCN(m_psRct, m_psRfRtc->s_arfcn))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_TCH_ARFCN_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_psRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_psRfRtc->s_arfcn)
- );
- write_log_file();
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_TCHARFCN(m_psRct, m_psRfRtc->s_arfcn))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_TCH_ARFCN_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_psRct->as_RCT + " < TCH ARFCN = " + IntToStr(m_psRfRtc->s_arfcn)
- );
- write_log_file();
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_TCHTimeslot(m_psRct, TIMESLOT_3))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_TCH_TIMESLOT_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_psRct->as_RCT + " < timeslot = " + IntToStr( TIMESLOT_3 )
- );
- write_log_file();
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_TCHTimeslot(m_psRct, TIMESLOT_3))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_TCH_TIMESLOT_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL :"+
- m_psRct->as_RCT + " < timeslot = " + IntToStr(TIMESLOT_3)
- );
- write_log_file();
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_ConfigTSC(m_psRct, m_psRfRtc->c_tsc))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_TSC_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- "FAIL : " + m_psRct->as_RCT + " < set TSC fail."
- );
- write_log_file();
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_ConfigTSC(m_psRct, 0))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_TSC_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_psRct->as_RCT + " < TSC = " + IntToStr( 0 )
- );
- write_log_file();
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- // FB detection
- unsigned char selectPCS1900;
- if (BANDSEL_PCS1900 == m_psRfRtc->e_band)
- {
- selectPCS1900 = 1;
- }
- else
- {
- selectPCS1900 = 0;
- }
- short MF_SelectBand_token;
- if (META_Rf_SelectFrequencyBand1900_r(m_META_HANDLE_Obj.Get_MainHandle(), selectPCS1900, ::CNF_SelectPcs1900, &MF_SelectBand_token, NULL) != META_SUCCESS)
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_SELECT_BAND_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = " + IntToStr(selectPCS1900)
- );
- return;
- }
- this->Suspend();
- if (!m_ucSelectPcsCnf)
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_SELECT_BAND_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set Band1900 flag = " + IntToStr(selectPCS1900) +
- " CNF"
- );
- return;
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- Sleep(100);
- short dacValue[2];
- dacValue[0] = 3800;
- dacValue[1] = 4200;
- int freqOffset[2];
- for (int i=0; i<2; i++)
- {
- RfAfc_Req afc_req;
- afc_req.dacValue = dacValue[i];
- afc_req.arfcn = m_psRfRtc->s_arfcn;
- afc_req.gain = (MF_RF_GAIN_TO_BE_SUB - m_psRfRtc->d_P_DL) * GAIN_REQUEST_PC_SIDE_MULTIPLY;
- afc_req.testNumber = 10;
- short MF_rf_afc_token;
- if (META_Rf_AFC_r(m_META_HANDLE_Obj.Get_MainHandle(), &afc_req, ::CNF_RfAfc, &MF_rf_afc_token, NULL) != META_SUCCESS)
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_AFC_CONTROL_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < AFC: ARFCN = "+ IntToStr(afc_req.arfcn) +
- ", dac value = "+ IntToStr(afc_req.dacValue) +
- ", gain = " + Double_To_AnsiString(afc_req.gain/RF_RX_GAIN_SCALE) + " dB" +
- ", testing number = " + IntToStr(10)
- );
- return;
- }
- this->Suspend();
- if ((STATUS_AFC_OK != (E_AFC_STATUS_T)m_sRfAfcCnf.ok) ||
- (m_sRfAfcCnf.fcb_ok_number <= 0)
- )
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_AFC_CONTROL_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target > AFC CNF: fcb_ok_number = "+ IntToStr(m_sRfAfcCnf.fcb_ok_number) +
- ", freqOffset = "+ IntToStr(m_sRfAfcCnf.freqOffset) +
- ", deviation = " + IntToStr(m_sRfAfcCnf.deviation) +
- ", ok = " + IntToStr(m_sRfAfcCnf.ok)
- );
- return;
- }
- freqOffset[i] = m_sRfAfcCnf.freqOffset;
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- CRFAFC RF_AFC_Obj;
- // float Afc_Slope_factor = RF_AFC_Obj.Get_Afc_Slope_factor(m_psRfRtc->e_band);
- double d_Slope = (double)(freqOffset[0] - freqOffset[1])/(double)(dacValue[1] - dacValue[0]);
- short sDefault_value = (unsigned short) ((freqOffset[0]/d_Slope)+ dacValue[0]);
- if (AGILENT_8960 == m_psRct->device_type)
- {
- if (!m_rct_ctrl.RCT_MSTXLevel(m_psRct, m_psRfRtc->s_pcl))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_MS_TX_LEVEL_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_psRct->as_RCT + " < MS TX level = " + IntToStr(m_psRfRtc->s_pcl)
- );
- write_log_file();
- return;
- }
- }
- else
- {
- if (!m_rct_ctrl.RCT_sig_MSTXLevel(m_psRct, m_psRfRtc->s_pcl))
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RCT_SET_MS_TX_LEVEL_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : " + m_psRct->as_RCT + " < MS TX level = " + IntToStr( m_psRfRtc->s_pcl )
- );
- write_log_file();
- return;
- }
- }
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- // TX NB
- CRFSTOP rf_stop_obj;
- if (!rf_stop_obj.REQ_Start())
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_STOP_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return;
- }
- Sleep(50);
- short s_token;
- RfNbtx_Req req;
- req.arfcn = m_psRfRtc->s_arfcn;
- if (AGILENT_8960 == m_psRct->device_type)
- {
- req.bsic = m_psRfRtc->c_tsc;
- }
- else
- {
- req.bsic = 0;
- }
- req.power = m_psRfRtc->s_pcl;
- req.frames = -99;
- req.dacValue = sDefault_value | MASK_AFC_TRACKING;
- req.burstTypeNB = NB_TX_RANDOM_WITH_TSC;
- if (META_Rf_NB_TX_r(m_META_HANDLE_Obj.Get_MainHandle(),
- &req,
- ::CNF_RfNbTx,
- &s_token,
- NULL
- ) != META_SUCCESS)
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_TX_LEVEL_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target< ARFCN = " + IntToStr(m_psRfRtc->s_arfcn) +
- ", TSC = " + IntToStr(req.bsic) +
- ", power = " + IntToStr(m_psRfRtc->s_pcl) +
- ", frames = " + IntToStr(req.frames) +
- ", dac value = " + IntToStr(sDefault_value)
- );
- return;
- }
- this->Suspend();
- if (!m_ucNbTxCnf)
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_TX_LEVEL_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX level confirm."
- );
- return;
- }
- char buf[256];
- AnsiString as_str;
- as_str = "RTC clock(Hz) clock/32768";
- sprintf(buf, as_str.c_str());
- m_psRfRtc->p_stLog->Add(buf);
- write_log_file();
- // config euqipment
- for (unsigned int i=0; i<m_psRfRtc->ui_test_count; i++)
- {
- if (this->Terminated)
- {
- this->OnTerminate = m_psRfRtc->ne_onTermByUser;
- return;
- }
- int iResult;
- META_RESULT MetaResult = META_Rf_32kCalibration_r(m_META_HANDLE_Obj.Get_MainHandle(), 3000, &iResult);
- if (MetaResult != META_SUCCESS)
- {
- return;
- }
- double d_rtc_clock = (13000000.0*8192.0*2.0)/iResult;
- double d_norm_rtc_clock = d_rtc_clock / 32768.0;
- sprintf(buf, "%.2f %f", d_rtc_clock, d_norm_rtc_clock);
- m_psRfRtc->p_stLog->Add(buf);
- write_log_file();
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RTC_PRINT_MSG,
- (int) d_rtc_clock *100,
- 0
- );
- if (Abs_double(d_norm_rtc_clock-1) > 0.0004)
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RTC_CLOCK_OUT_OF_RANGE_MSG,
- (int) d_rtc_clock *100,
- 0
- );
- return;
- }
- Sleep(m_psRfRtc->ui_period);
- }
- if (!rf_stop_obj.REQ_Start())
- {
- PostMessage(m_psRfRtc->hPostMsgDestHandle,
- WM_ML_RF_STOP_FAIL,
- 0,
- 0
- );
- m_psRfRtc->p_stLog->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Target < stop RF fail."
- );
- return;
- }
- this->OnTerminate = m_psRfRtc->ne_onTermSuccess;
- }
- //---------------------------------------------------------------------------
- void CRFRTC::read_cfg_file(void)
- {
- // Agilent 8960
- m_psRfRtc->p_cfg->getGSM400_CableLoss(m_psRct->age.d400);
- m_psRfRtc->p_cfg->getGSM850_CableLoss(m_psRct->age.d850);
- m_psRfRtc->p_cfg->getGSM900_CableLoss(m_psRct->age.d900);
- m_psRfRtc->p_cfg->getDCS1800_CableLoss(m_psRct->age.d1800);
- m_psRfRtc->p_cfg->getPCS1900_CableLoss(m_psRct->age.d1900);
- m_psRfRtc->p_cfg->getTimeOut(m_psRct->age.TMO);
- m_psRfRtc->p_cfg->getGPIB_Addr(m_psRct->age.ADD);
- // CMU 200
- m_psRfRtc->p_cfg->getCMU200_INPUT_GSM850_CableLoss(m_psRct->cmu.loss_gsm850_i);
- m_psRfRtc->p_cfg->getCMU200_INPUT_GSM900_CableLoss(m_psRct->cmu.loss_gsm_i);
- m_psRfRtc->p_cfg->getCMU200_INPUT_DCS1800_CableLoss(m_psRct->cmu.loss_dcs_i);
- m_psRfRtc->p_cfg->getCMU200_INPUT_PCS1900_CableLoss(m_psRct->cmu.loss_pcs_i);
- m_psRfRtc->p_cfg->getCMU200_OUTPUT_GSM850_CableLoss(m_psRct->cmu.loss_gsm850_o);
- m_psRfRtc->p_cfg->getCMU200_OUTPUT_GSM900_CableLoss(m_psRct->cmu.loss_gsm_o);
- m_psRfRtc->p_cfg->getCMU200_OUTPUT_DCS1800_CableLoss(m_psRct->cmu.loss_dcs_o);
- m_psRfRtc->p_cfg->getCMU200_OUTPUT_PCS1900_CableLoss(m_psRct->cmu.loss_pcs_o);
- m_psRfRtc->p_cfg->getCMU200_TimeOut(m_psRct->cmu.TMO);
- m_psRfRtc->p_cfg->getCMU200_GPIB_Addr(m_psRct->cmu.ADD);
- m_psRct->cmu.ADD = m_psRct->cmu.ADD.SubString(0, m_psRct->cmu.ADD.Pos("::INSTR")-1);
- }
- //---------------------------------------------------------------------------
- void CRFRTC::write_log_file(void)
- {
- FILE *pf;
- try
- {
- if (m_psRfRtc->as_LogFile.AnsiCompareIC("") != 0)
- {
- if ((pf = fopen(m_psRfRtc->as_LogFile.c_str() ,"at+"))== NULL)
- {
- AnsiString as_warring_msg;
- as_warring_msg = "Cannot open output file: " + m_psRfRtc->as_LogFile;
- Application->MessageBox(as_warring_msg.c_str() , "Warning", MB_OK);
- return;
- }
- for (int I=0; I<m_psRfRtc->p_stLog->Count; I++)
- {
- fprintf(pf, AnsiString(m_psRfRtc->p_stLog->Strings[I] + "n").c_str());
- } // for
- fclose(pf);
- m_psRfRtc->p_stLog->Clear();
- } // if
- } // try
- catch(...)
- {
- AnsiString as_warning_msg;
- as_warning_msg = " write log file error " + m_psRfRtc->as_LogFile;
- Application->MessageBox(as_warning_msg.c_str(), "Warning", MB_OK);
- }
- }