WFT_ctrl.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:10k
- /*****************************************************************************
- * 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:
- * ---------
- * WFC_ctrl.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * WiFi Tester control function 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>
- //#ifndef age1960_INCLUDE
- //#include "age1960.h"
- //#endif
- #include "AgN4010WSOAPI.h"
- #pragma hdrstop
- #ifndef _WFT_CTRL_H_
- #include "wft_ctrl.h"
- #endif
- #ifndef _WFT_COMMON_H_
- #include "wft_common.h"
- #endif
- //===========================================================================
- CWFTCTRL::CWFTCTRL( void )
- {
- }
- //---------------------------------------------------------------------------
- CWFTCTRL::~CWFTCTRL()
- {
- }
- //=============================================================================
- ///////////////////////////// initialization/terminate /////////////////////
- //=============================================================================
- bool CWFTCTRL::WFT_Init( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- IQV_init();
- }
- else if( N4010A == p_wft->device_type )
- {
- char str[1024];
- strcpy( str, p_wft->s_age_n4010a.as_VISA_Alias_Name.c_str() );
- if( 0 > AgN4010_Init( str ) )
- return false;
- }
- return true;
- }
- //--------------------------------------------------------------------------
- bool CWFTCTRL::WFT_Terminate( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- IQV_term();
- }
- else if( N4010A == p_wft->device_type )
- {
- AgN4010_Close();
- }
- return true;
- }
- //=============================================================================
- /////////////////////////// Connection control ////////////////////////////
- //=============================================================================
- bool CWFTCTRL::WFT_ConOpen( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- p_wft->iqv.p_handle = IQV_con_open(&(p_wft->iqv.ip_addr));
- if( NULL == p_wft->iqv.p_handle )
- {
- //int err = IQV_err();
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CWFTCTRL::WFT_ConClose( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( NULL != p_wft->iqv.p_handle )
- {
- if( IQV_ERR_OK != IQV_con_close(p_wft->iqv.p_handle) )
- return false;
- p_wft->iqv.p_handle = NULL;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CWFTCTRL::WFT_ConCalUpdate( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( IQV_ERR_OK != IQV_con_cal_update(p_wft->iqv.p_handle) )
- return false;
- }
- return true;
- }
- //============================================================================
- ////////////////////////// Test setup handling ////////////////////////////
- //============================================================================
- bool CWFTCTRL::WFT_SetDefault( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( IQV_ERR_OK != IQV_set_default( p_wft->iqv.p_handle ) )
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CWFTCTRL::WFT_ApplyChange( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( IQV_ERR_OK != IQV_set_status ( p_wft->iqv.p_handle, 0) )
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CWFTCTRL::WFT_SetFrameCount( S_WFT *p_wft, unsigned int frame_count )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( IQV_ERR_OK != IQV_set_frame_cnt ( p_wft->iqv.p_handle, frame_count ) )
- {
- return false;
- }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CWFTCTRL::WFT_SetTriggerStyle( S_WFT *p_wft )
- {
- if( N4010A == p_wft->device_type )
- {
- if( 0 >= AgN4010_SetProperty( "TriggerStyle", enumTriggerStyle_MagLevel ) )
- {
- return false;
- }
- if( 0 >= AgN4010_SetProperty( "TriggerLevel_mV", 20 ) )
- {
- return false;
- }
- if( 0 >= AgN4010_SetProperty( "TriggerDelay_s", 0.000002 ) )
- {
- return false;
- }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CWFTCTRL::WFT_SetPowerRange( S_WFT *p_wft, double power_range )
- {
- if( N4010A == p_wft->device_type )
- {
- if( 0 >= AgN4010_SetProperty( "PowerRange", power_range ) )
- {
- return false;
- }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CWFTCTRL::WFT_SetCentralFreq( S_WFT *p_wft, double MHz )
- {
- if( IQVIEW == p_wft->device_type )
- {
- p_wft->iqv.p_handle->rx.freq = MHz*1000000.0;
- if( ! WFT_ApplyChange( p_wft ) )
- return false;
- }
- else if( N4010A == p_wft->device_type )
- {
- if( 0 >= AgN4010_SetProperty( "CenterFrequency_MHz", MHz ) )
- {
- return false;
- }
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CWFTCTRL::WFT_SetPacketLength( S_WFT *p_wft, double s )
- {
- if( N4010A == p_wft->device_type )
- {
- if( 0 >= AgN4010_SetProperty( "MaxPacketLength_s", s ) ) // suggest : 100 us
- {
- return false;
- }
- }
- return true;
- }
- //============================================================================
- ////////////////////////// Data capture and signal analysis ///////////////
- //============================================================================
- bool CWFTCTRL::WFT_DataCapture( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( IQV_ERR_OK != IQV_data_capture ( p_wft->iqv.p_handle, 0, IQV_DC_ARM_NEW ) )
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CWFTCTRL::WFT_PowerAnalyze( S_WFT *p_wft )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( IQV_ERR_OK != IQV_data_analyze( p_wft->iqv.p_handle, 0, IQV_GROUP_POWER_ANALYSIS ) )
- {
- return false;
- }
- }
- return true;
- }
- //============================================================================
- ////////////////////////// Result Handling ////////////////////////////////
- //============================================================================
- bool CWFTCTRL::WFT_ReadPower( S_WFT *p_wft, double &power )
- {
- if( IQVIEW == p_wft->device_type )
- {
- if( ! IQV_result_exist_valid( p_wft->iqv.p_handle, 0, IQV_RES_RMS_DB_NO_GAP ) )
- {
- return false;
- }
- power = IQV_result_real( p_wft->iqv.p_handle, 0, IQV_RES_RMS_DB_NO_GAP );
- }
- else if( N4010A == p_wft->device_type )
- {
- if( 0 > AgN4010_Measure_AveragePower( &power ) )
- {
- return false;
- }
- }
- return true;
- }