rf_txpcs_sweep.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:12k
- /*****************************************************************************
- * 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_txpcs_sweep.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF TX power channel sweep 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 <vcl.h>
- #pragma hdrstop
- #include "form_RFTool.h"
- #include "rf_txpcs_sweep.h"
- #include "meta_utils.h"
- //#include "Crystal_INIFileHandle.h"
- #include "man_dll.h"
- // equipment
- #include "ageCommon.h"
- #include "age1968A.h"
- #include "cmu200.h"
- #ifndef _RCT_COMMON_H_
- #include "rct_common.h"
- #endif
- #ifndef _RCT_CTRL_H_
- #include "rct_ctrl.h"
- #endif
- #ifndef _AGE_MISC_H_
- #include "age_misc.h"
- #endif
- // misc
- #ifndef _BAND_UTILS_H_
- #include "band_utils.h"
- #endif
- //---------------------------------------------------------------------------
- //#define ONE_SECOND 1
- //------------------------------------------------------------------------------
- //ViInt16 vi_Band_Crystal;
- //==============================================================================
- static void ConfirmCallback_TXPCS( void )
- { if(frmRFTool->pt_TXPCS_sweep != NULL )
- {
- frmRFTool->pt_TXPCS_sweep->Resume();
- }
- }
- //------------------------------------------------------------------------------
- static void cb_rf_stop_TXPCS()
- {
- if(frmRFTool->pt_TXPCS_sweep != NULL )
- {
- frmRFTool->pt_TXPCS_sweep->Resume();
- }
- }
- //==============================================================================
- void _fastcall CRF_TXPCS_SWEEP::ShowMsg()
- {
- ShowMessage( as_Msg );
- }
- //------------------------------------------------------------------------------
- void _fastcall CRF_TXPCS_SWEEP::SyncShowMsg(AnsiString as)
- {
- as_Msg = as;
- Synchronize( ShowMsg );
- }
- //=========================================================================================
- __fastcall CRF_TXPCS_SWEEP::CRF_TXPCS_SWEEP(
- bool CreateSuspended,
- sTXPCSSweep *p_txpcs_sweep
- // ViSession &vs_Age196x,
- // AnsiString &as_TaModel
- ): TThread(CreateSuspended)
- {
- txpcs_sweep = p_txpcs_sweep;
- // as_pAgeTaModel = &as_TaModel;
- // pvi = &vs_Age196x;
- }
- //---------------------------------------------------------------------------
- void __fastcall CRF_TXPCS_SWEEP::Execute()
- {
- char buf[40000], buf0[10000], buf1[10000], buf2[10000];
- AnsiString as_str;
- ViReal64 virTX;
- #if 0
- if( txpcs_sweep.device_type == AGILENT_8960 )
- {
- if((! txpcs_sweep.rf_cfg->getGSM400_CableLoss( rct.age.d400 )) ||
- (! txpcs_sweep.rf_cfg->getGSM850_CableLoss( rct.age.d850 )) ||
- (! txpcs_sweep.rf_cfg->getGSM900_CableLoss( rct.age.d900 )) ||
- (! txpcs_sweep.rf_cfg->getDCS1800_CableLoss( rct.age.d1800 )) ||
- (! txpcs_sweep.rf_cfg->getPCS1900_CableLoss( rct.age.d1900 ))
- )
- {
- SyncShowMsg( " Agilent 8960 read config file (cable loss) fail " );
- return;
- }
- if(! txpcs_sweep.rf_cfg->getTimeOut( rct.age.TMO ) )
- {
- SyncShowMsg( "Get Time Out from file fail" );
- return;
- }
- if(! txpcs_sweep.rf_cfg->getGPIB_Addr( rct.age.ADD ) )
- {
- SyncShowMsg( "Get GPIB address from file fail" );
- return;
- }
- }
- #endif
- if(! TXPCS_CfgRead() )
- {
- return;
- }
- rct.device_type = txpcs_sweep->e_device_type;
- if( ! rct_ctrl.RCT_Init( &rct, BandIdx_To_FreqBandString(txpcs_sweep->e_band) ) )
- {
- SyncShowMsg( "Initialize equipment fail" );
- return;
- }
- if( ! rct_ctrl.RCT_operatingMode( &rct, OPERATING_MODE_GSM_BCH ) )
- {
- SyncShowMsg( "Set equipment operation mode to BCH+TCH fail" );
- return;
- }
- if( ! rct_ctrl.RCT_cellBand( &rct, BandIdx_To_AgeBand(txpcs_sweep->e_band)) )
- {
- SyncShowMsg( "Set equipment e_band fail" );
- return;
- }
- if( ! rct_ctrl.RCT_MSTXLevel( &rct, txpcs_sweep->pcl ) )
- {
- SyncShowMsg( "Set equipment PCL fail" );
- return;
- }
- if( ! rct_ctrl.RCT_ConfigTSC( &rct, txpcs_sweep->tsc) )
- {
- SyncShowMsg( "Set equipment TSC fail" );
- return;
- }
- as_str = "Channel Power(dBm)";
- sprintf(buf, as_str.c_str());
- txpcs_sweep->st_Log->Add(buf);
- frmRFTool->write_TXPCS_log_file();
- for(int arfcn=txpcs_sweep->s_arfcn_start; arfcn<=txpcs_sweep->s_arfcn_stop; arfcn +=txpcs_sweep->s_arfcn_step )
- {
- if ( this->Terminated )
- {
- this->OnTerminate = txpcs_sweep->ne_onTermByUser;
- return;
- }
- if( txpcs_sweep->e_band == BANDSEL_GSM900 && arfcn>=125 && arfcn < 975)
- {
- arfcn = arfcn - 125 + 975;
- }
- if( ! rct_ctrl.RCT_TCHARFCN( &rct, arfcn ) )
- {
- SyncShowMsg( "Set equipment TCH ARFCN="+IntToStr(arfcn)+" fail" );
- return;
- }
- S_RFTX rf_tx;
- rf_tx.e_bandsel = txpcs_sweep->e_band;
- rf_tx.s_RfNbTxReq.arfcn = arfcn;
- rf_tx.s_RfNbTxReq.bsic = txpcs_sweep->tsc;
- rf_tx.s_RfNbTxReq.power = txpcs_sweep->pcl;
- rf_tx.s_RfNbTxReq.frames = txpcs_sweep->frames;
- rf_tx.s_RfNbTxReq.dacValue = txpcs_sweep->s_afc_dac;
- rf_tx.s_RfNbTxReq.burstTypeNB = txpcs_sweep->burst_type;
- RF_TX_Object.ConfirmCallback = ::ConfirmCallback_TXPCS;
- RF_TX_Object.REQ_Start(rf_tx);
- // RF_TX_Object.REQ_Start( txpcs_sweep->e_band, arfcn, txpcs_sweep->tsc, txpcs_sweep->pcl,
- // txpcs_sweep->frames, txpcs_sweep->s_afc_dac, txpcs_sweep->burst_type, -99, -99, -99, -99 );
- this->Suspend();
- if (RF_TX_Object.Get_ConfirmState() != METAAPP_SUCCESS )
- {
- SyncShowMsg( "NB TX fail" );
- return;
- }
- Sleep(50);
- if( ! rct_ctrl.RCT_confTXPower( &rct ) )
- {
- SyncShowMsg( "Equipment config TX power measurement function fail" );
- return;
- }
- if( ! rct_ctrl.RCT_initMeasFcn_TXPOWER( &rct ) )
- {
- SyncShowMsg( "Equipment initialize TX power measurement function fail" );
- return;
- }
- if( ! rct_ctrl.RCT_ReadTxPower( &rct, virTX ) )
- {
- SyncShowMsg( "Equipment read TX power measurement fail" );
- return;
- }
- sprintf( buf, "%4d %8.3f ", arfcn, virTX);
- txpcs_sweep->st_Log->Add(buf);
- frmRFTool->write_TXPCS_log_file();
- RF_STOP_Object.REQ_Start();
- }
- this->OnTerminate = txpcs_sweep->ne_onTermSuccess;
- }
- //---------------------------------------------------------------------------
- bool __fastcall CRF_TXPCS_SWEEP::TXPCS_CfgRead( void )
- {
- if (AGILENT_8960 == txpcs_sweep->e_device_type)
- {
- if((! txpcs_sweep->rf_cfg->getGSM400_CableLoss( rct.age.d400 )) ||
- (! txpcs_sweep->rf_cfg->getGSM850_CableLoss( rct.age.d850 )) ||
- (! txpcs_sweep->rf_cfg->getGSM900_CableLoss( rct.age.d900 )) ||
- (! txpcs_sweep->rf_cfg->getDCS1800_CableLoss( rct.age.d1800 )) ||
- (! txpcs_sweep->rf_cfg->getPCS1900_CableLoss( rct.age.d1900 ))
- )
- {
- SyncShowMsg( " Agilent 8960 read config file (cable loss) fail " );
- return false;
- }
- if(! txpcs_sweep->rf_cfg->getTimeOut( rct.age.TMO ) )
- {
- SyncShowMsg( "Get Time Out from file fail" );
- return false;
- }
- if(! txpcs_sweep->rf_cfg->getGPIB_Addr( rct.age.ADD ) )
- {
- SyncShowMsg( "Get GPIB address from file fail" );
- return false;
- }
- }
- else // CMU 200
- {
- if(
- (! txpcs_sweep->rf_cfg->getCMU200_INPUT_GSM850_CableLoss( rct.cmu.loss_gsm850_i )) ||
- (! txpcs_sweep->rf_cfg->getCMU200_INPUT_GSM900_CableLoss( rct.cmu.loss_gsm_i )) ||
- (! txpcs_sweep->rf_cfg->getCMU200_INPUT_DCS1800_CableLoss( rct.cmu.loss_dcs_i )) ||
- (! txpcs_sweep->rf_cfg->getCMU200_INPUT_PCS1900_CableLoss( rct.cmu.loss_pcs_i ))
- )
- {
- SyncShowMsg( " CMU200 read config file (input cable loss) fail " );
- return false;
- }
- //*************************************************************
- //************************************************************
- if(
- (! txpcs_sweep->rf_cfg->getCMU200_OUTPUT_GSM850_CableLoss( rct.cmu.loss_gsm850_o )) ||
- (! txpcs_sweep->rf_cfg->getCMU200_OUTPUT_GSM900_CableLoss( rct.cmu.loss_gsm_o )) ||
- (! txpcs_sweep->rf_cfg->getCMU200_OUTPUT_DCS1800_CableLoss( rct.cmu.loss_dcs_o )) ||
- (! txpcs_sweep->rf_cfg->getCMU200_OUTPUT_PCS1900_CableLoss( rct.cmu.loss_pcs_o ))
- )
- {
- SyncShowMsg( " CMU200 read config file (output cable loss) fail " );
- return false;
- }
- if(! txpcs_sweep->rf_cfg->getCMU200_TimeOut( rct.cmu.TMO ) )
- {
- SyncShowMsg( "Get Time Out from file fail" );
- return false;
- }
- if(! txpcs_sweep->rf_cfg->getCMU200_GPIB_Addr( rct.cmu.ADD ) )
- {
- SyncShowMsg( "Get GPIB address from file fail" );
- return false;
- }
- rct.cmu.ADD = rct.cmu.ADD.SubString(0, rct.cmu.ADD.Pos("::INSTR")-1);
- }
- return true;
- }