rf_offset_iq_Sweep_Init_Age8960.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:70k
源码类别:
MTK
开发平台:
C++ Builder
- /*****************************************************************************
- * 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_offset_iq_sweep_Init_Age8960.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF offset IQ sweep Initalize Agilent 8960 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_offset_iq_Sweep_Init_Age8960.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
- //---------------------------------------------------------------------------
- //#define ONE_SECOND 1
- //------------------------------------------------------------------------------
- CMU_VAR cmu;
- static ViInt16 vi_Band_Crystal;
- static T_TXIQ_SWEEP* g_txiq_sweep_ptr;
- //==============================================================================
- static void CNF_TXIQ_Sweep(void)
- {
- g_txiq_sweep_ptr->CNF_TXIQ_Sweep();
- }
- //----------------------------------------------------------------------------
- static void cb_read_CrystalAFC_from_nvram_TrOff()
- {
- if(frmRFTool->m_pt_TXIQ_sweep != NULL )
- {
- frmRFTool->m_pt_TXIQ_sweep->Resume();
- }
- }
- //------------------------------------------------------------------------------
- static void cb_write_CrystalAFC_to_nvram_TrOff()
- {
- if(frmRFTool->m_pt_TXIQ_sweep != NULL )
- {
- frmRFTool->m_pt_TXIQ_sweep->Resume();
- }
- }
- //------------------------------------------------------------------------------
- void __stdcall cb_rf_setbbtx_cfg_TrOff(const unsigned char cnf, const short token, void *usrData)
- {
- if(frmRFTool->m_pt_TXIQ_sweep != NULL )
- {
- frmRFTool->m_pt_TXIQ_sweep->Resume();
- }
- }
- //------------------------------------------------------------------------------
- void __stdcall cb_rf_tx_level_TrOff(const unsigned char cnf, const short token, void *usrData)
- {
- if(frmRFTool->m_pt_TXIQ_sweep != NULL )
- {
- frmRFTool->m_pt_TXIQ_sweep->Resume();
- }
- }
- //------------------------------------------------------------------------------
- static void cb_rf_stop_TrOff()
- {
- if(frmRFTool->m_pt_TXIQ_sweep != NULL )
- {
- frmRFTool->m_pt_TXIQ_sweep->Resume();
- }
- }
- //==============================================================================
- void _fastcall T_TXIQ_SWEEP::ShowMsg()
- {
- ShowMessage( as_Msg );
- }
- //------------------------------------------------------------------------------
- void _fastcall T_TXIQ_SWEEP::SyncShowMsg(AnsiString as)
- {
- as_Msg = as;
- Synchronize( ShowMsg );
- }
- //=========================================================================================
- __fastcall T_TXIQ_SWEEP::T_TXIQ_SWEEP(bool CreateSuspended,
- S_TXIQ_SWEEP_T *p_txiq_sweep,
- ViSession &vs_Age196x,
- AnsiString &as_TaModel
- ): TThread(CreateSuspended)
- {
- g_txiq_sweep_ptr = this;
- m_pTxIqSweep = p_txiq_sweep;
- as_pAgeTaModel = &as_TaModel;
- pvi = &vs_Age196x;
- }
- //---------------------------------------------------------------------------
- void __fastcall T_TXIQ_SWEEP::Execute()
- {
- Initialize_Equipment();
- // get BBTXCfg from target
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
- m_cTXIQ_RUN_Obj.REQ_GetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver);
- this->Suspend();
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- SyncShowMsg("Get BBTXCfg parameter from target fail");
- return;
- }
- RfBBTXCfg4* p_bbtxcfg = m_cTXIQ_RUN_Obj.Get_BbTxCfg();
- m_sBbTxCfg = *p_bbtxcfg;
- switch (m_pTxIqSweep->e_sweep_type)
- {
- case TXIQ_SWEEP_TYPE_TRIM_IQ:
- {
- if (!Trim_IQ_Sweep())
- {
- return;
- }
- }
- break;
- case TXIQ_SWEEP_TYPE_OFFSET_IQ:
- {
- if (!Offset_IQ_Sweep())
- {
- return;
- }
- }
- break;
- case TXIQ_SWEEP_TYPE_PHASESEL:
- {
- if (!Phasesel_Sweep())
- {
- return;
- }
- }
- break;
- }
- this->OnTerminate = m_pTxIqSweep->ne_onTermSuccess;
- }
- //======================================================================
- bool __fastcall T_TXIQ_SWEEP::Initialize_Equipment(void)
- {
- if (m_pTxIqSweep->e_device_type == AGILENT_8960)
- {
- if ((vistat = age1960_init(m_pTxIqSweep->as_ADDR.c_str(), 0, 0, &vi)) != VI_SUCCESS)
- {
- Application->MessageBox(" Initialize Agilent 8960 fail 2", "Fail", MB_OK);
- return false;
- }
- //////////////////////////////////////////////////////////////////////////////
- if ((vistat = age_QueryTaModel(vi, as_pAgeTaModel)) != VI_SUCCESS)
- {
- Application->MessageBox(" Query Agilent 8960 TA Model fail ", "Fail", MB_OK);
- return false;
- }
- //////////////////////////////////////////////////////////////////////////////
- Sleep(50);
- if (vi != VI_NULL)
- {
- if (age1960_dcl(vi)!= VI_SUCCESS)
- {
- Application->MessageBox(" Agilent 8960 DCL fail ", "Fail", MB_OK);
- return false;
- }
- }
- //////////////////////////////////////////////////////////////////////////////
- Sleep(50);
- if (vi != VI_NULL)
- {
- vistat = age1960_reset(vi);
- if (vistat != VI_SUCCESS)
- {
- Application->MessageBox(" Reset Agilent 8960 fail ", "Fail", MB_OK);
- return false;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- if(! m_pTxIqSweep->rf_cfg->getTimeOut(i_AGE8960_TimeOut))
- {
- Application->MessageBox( "Execution Failure : Get Time Out from file fail", "FAILURE", MB_OK );
- return false;
- }
- if ((vistat = age1960_timeOut (vi,i_AGE8960_TimeOut)) != VI_SUCCESS)
- {
- Application->MessageBox( " Agilent 8960 set timeout fail ", "Fail", MB_OK );
- return false;
- }
- /////////////////////////////////////////////////////////////////////////////
- if((! m_pTxIqSweep->rf_cfg->getGSM400_CableLoss(d400)) ||
- (! m_pTxIqSweep->rf_cfg->getGSM850_CableLoss(d850)) ||
- (! m_pTxIqSweep->rf_cfg->getGSM900_CableLoss(d900)) ||
- (! m_pTxIqSweep->rf_cfg->getDCS1800_CableLoss(d1800)) ||
- (! m_pTxIqSweep->rf_cfg->getPCS1900_CableLoss(d1900))
- )
- {
- Application->MessageBox( " Agilent 8960 read config file (cable loss) fail ", "Fail", MB_OK );
- return false;
- }
- const AMP_OFFSET_ITEMS = 10;
- ViReal64 freqArray[AMP_OFFSET_ITEMS] = { 400000000.0,
- 641000000.0,
- 641100000.0,
- 876000000.0,
- 876100000.0,
- 1312000000.0,
- 1312100000.0,
- 1880000000.0,
- 1881000000.0,
- 2000000000.0 };
- ViReal64 offsetArray[AMP_OFFSET_ITEMS] = { d400,
- d400,
- d850,
- d850,
- d900,
- d900,
- d1800,
- d1800,
- d1900,
- d1900
- };
- if ((vistat = age1960_amplitudeOffset (
- vi,
- freqArray,
- offsetArray,
- AMP_OFFSET_ITEMS
- )) != VI_SUCCESS)
- {
- Application->MessageBox( " Agilent 8960 set cable loss fail ", "Fail", MB_OK );
- return false;
- }
- /////////////////////////////////////////////////////////////////////////////
- if(as_pAgeTaModel->AnsiCompareIC("E1968A") == 0 ||
- as_pAgeTaModel->AnsiCompareIC("E6701C") == 0 ||
- as_pAgeTaModel->AnsiCompareIC("E6701D") == 0 ||
- as_pAgeTaModel->AnsiCompareIC("E6701E") == 0
- )
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- vistat = age1968A_operatingMode(vi, OPERATING_MODE_GSM_BCH_TCH);
- if (vistat!= VI_SUCCESS)
- {
- Application->MessageBox(" Agilent 8960 set operation mode fail ", "Fail", MB_OK );
- return false;
- }
- }
- else // EPSK
- {
- vistat = age1968A_operatingMode(vi, OPERATING_MODE_EGPRS_BCH_PDTCH);
- if (vistat != VI_SUCCESS)
- {
- Application->MessageBox(" Agilent 8960 set operation mode fail ", "Fail", MB_OK );
- return false;
- }
- }
- }
- else // Agilent 1960A
- {
- if ((vistat = age1960_operatingMode(
- vi,
- (ViInt16) age1960_TEST_MODE
- ))!= VI_SUCCESS)
- {
- Application->MessageBox( " Agilent 8960 set operation mode fail ", "Fail", MB_OK );
- return false;
- }
- }
- }
- else //--------------To Do CMU200 Functions------------------
- {
- // double d900,Out900,d400,Out400,d850,Out850,d1800,Out1800,d1900,Out1900;
- AnsiString as_CMU_ADDR;
- int as_CMU_TimeOut;
- AnsiString CMU_GSM_INP,CMU_GSM_OUT;
- AnsiString as_RF_Equipment_ADDR;
- //************************************************************
- if((! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_GSM400_CableLoss( d400 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_GSM850_CableLoss( d850 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_GSM900_CableLoss( d900 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_DCS1800_CableLoss( d1800 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_PCS1900_CableLoss( d1900 ))
- )
- {
- Application->MessageBox( " CMU200 read config file (cable loss) fail ", "Fail", MB_OK );
- return false;
- }
- //*************************************************************
- //************************************************************
- if((! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_GSM400_CableLoss( Out400 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_GSM850_CableLoss( Out850 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_GSM900_CableLoss( Out900 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_DCS1800_CableLoss( Out1800 )) ||
- (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_PCS1900_CableLoss( Out1900 ))
- )
- {
- Application->MessageBox( " CMU200 read config file (cable loss) fail ", "Fail", MB_OK );
- return false;
- }
- //*************************************************************
- m_pTxIqSweep->rf_cfg->getCMU200_GPIB_Addr( as_RF_Equipment_ADDR );
- m_pTxIqSweep->rf_cfg->getCMU200_TimeOut(as_CMU_TimeOut);
- cmu.loss_gsm850_i=d850;
- cmu.loss_gsm850_o=Out850;
- cmu.loss_gsm_i=d900;
- cmu.loss_gsm_o=Out900;
- cmu.loss_dcs_i=d1800;
- cmu.loss_dcs_o=Out1800;
- cmu.loss_pcs_i=d1900;
- cmu.loss_pcs_o=Out1900;
- //cmu.ADD=as_CMU_ADDR;
- cmu.ADD=as_RF_Equipment_ADDR.SubString(0, as_RF_Equipment_ADDR.Pos("::INSTR")-1);
- cmu.TMO= StrToInt(as_CMU_TimeOut);
- cmu.BAND="GSM";
- if( !cmu_init_TX_FreqErr(&cmu) )
- {
- Application->MessageBox( "Initial CMU200 fail", "Fail", MB_OK );
- return false;
- }
- Sleep(1500);
- }
- /////////////////////////////////////////////////////////////////////////////
- switch (m_pTxIqSweep->e_band)
- {
- case 0:
- vi_Band = age1960_EGSM_BAND;
- cmu.BAND="GSM";
- vi_Band_Crystal=1;
- break;
- case 1:
- vi_Band = age1960_DCS1800_BAND;
- cmu.BAND="DCS";
- vi_Band_Crystal=3;
- break;
- case 2:
- vi_Band = age1960_PCS1900_BAND;
- cmu.BAND="PCS";
- vi_Band_Crystal=4;
- break;
- case 3:
- vi_Band = age1960_GSM850_BAND;
- cmu.BAND="GSM850";
- vi_Band_Crystal=CMU_GSM850_BAND;
- break;
- } // switch
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if ( age1960_cellBand(
- vi,
- age1960_CELL_1,
- vi_Band
- ) != VI_SUCCESS )
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 set cell band fail ", "Fail", MB_OK );
- return false;
- }
- }
- else
- {
- if( !cmu_cellband(vi_Band_Crystal, &cmu) )
- {
- Application->MessageBox( " CMU200 set cell band fail ", "Fail", MB_OK );
- return false;
- } // if
- }
- /////////////////////////////////////////////////////////////////////////////
- d_P_DL = -60;
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if ( age1960_cellPower(
- vi,
- age1960_CELL_1,
- d_P_DL,
- 0
- ) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 set cell power fail ", "Fail", MB_OK );
- return false;
- }
- }
- else
- {
- if( !cmu_cellpower(d_P_DL, &cmu) )
- {
- Application->MessageBox( " CMU200 set cell power fail ", "Fail", MB_OK );
- return false;
- } // if
- }
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if ( age1960_TCHARFCN(
- vi,
- m_pTxIqSweep->s_arfcn,
- (short) 0, // current band
- VI_TRUE
- )!= VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 set TCH ARFCN fail ", "Fail", MB_OK );
- return false;
- }
- }
- else
- {
- if( !cmu_tcharfcn(m_pTxIqSweep->s_arfcn, &cmu) )
- {
- Application->MessageBox( " CMU200 set TCH ARFCN fail ", "Fail", MB_OK );
- return false;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- //*****************************************************************
- if(m_pTxIqSweep->e_device_type == AGILENT_8960)
- {
- if( age1968A_ConfigTSC(vi, m_pTxIqSweep->tsc) != VI_SUCCESS )
- {
- Application->MessageBox( " Agilent 8960 config TSC fail ", "Fail", MB_OK );
- return false;
- }
- }
- else
- {
- if( !cmu_tsc(m_pTxIqSweep->tsc, &cmu) )
- {
- Application->MessageBox( " CMU200 config TSC fail ", "Fail", MB_OK );
- return false;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- if(m_pTxIqSweep->e_device_type == AGILENT_8960)
- {
- if ( age1960_MSTXLevel(
- vi,
- m_pTxIqSweep->pcl,
- (short) 0, // current band
- VI_TRUE
- )!= VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 MS TX level fail ", "Fail", MB_OK );
- return false;
- }
- }
- else
- {
- if( !cmu_mxtxlevel(m_pTxIqSweep->pcl, &cmu) )
- {
- Application->MessageBox( " CMU200 MS TX level fail ", "Fail", MB_OK );
- return false;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- switch( m_pTxIqSweep->e_output_data_type )
- {
- case TXIQ_OUTPUT_DATA_TYPE_PHERR:
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_confPFER(vi,
- m_pTxIqSweep->i_measure_count,
- age1960_TRIG_AUTO,
- AGE1960_PFER_TRIGGER_DELAY,
- AGE1960_PFER_TRIGGER_QUALIFIER_ON,
- age1960_BSYNC_MID,
- AGE1960_READ_PFER_TIMEOUT)!= VI_SUCCESS)
- {
- Application->MessageBox( " Agilent 8960 config PFER fail ", "Fail", MB_OK );
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Config_EPSK_ModACcuracy(vi,
- m_pTxIqSweep->i_measure_count,
- age1960_TRIG_AUTO,
- AGE1960_PFER_TRIGGER_DELAY,
- AGE1960_READ_PFER_TIMEOUT) != VI_SUCCESS)
- {
- Application->MessageBox(" Agilent 8960 config PFER fail ", "Fail", MB_OK );
- return false;
- }
- }
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_OOS:
- case TXIQ_OUTPUT_DATA_TYPE_SBS:
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_confIQTuning(vi,
- m_pTxIqSweep->i_measure_count,
- age1960_TRIG_RF_RISE,
- AGE1960_IQ_TUNNING_TRIGGER_DELAY,
- age1960_IQ_REF_AUTO,
- AGE1960_IQ_TUNNING_TRIGGER_QUALIFIER_OFF,
- AGE1960_IQ_TUNNING_SPUR_FREQ,
- AGE1960_READ_IQ_TUNNING_TIMEOUT) != VI_SUCCESS)
- {
- Application->MessageBox( " Agilent 8960 config IQ tunning fail ", "Fail", MB_OK );
- return false;
- }
- }
- else
- {
- if (age1968A_Config_EPSK_ModACcuracy(vi,
- m_pTxIqSweep->i_measure_count,
- age1960_TRIG_AUTO,
- AGE1960_IQ_TUNNING_TRIGGER_DELAY,
- AGE1960_READ_IQ_TUNNING_TIMEOUT) != VI_SUCCESS)
- {
- Application->MessageBox( " Agilent 8960 config IQ tunning fail ", "Fail", MB_OK );
- return false;
- }
- }
- }
- break;
- }
- }
- else
- {
- switch( m_pTxIqSweep->e_output_data_type )
- {
- case TXIQ_OUTPUT_DATA_TYPE_PHERR:
- {
- if( ! cmu_mod_config_control_mode( &cmu, m_pTxIqSweep->i_measure_count ) )
- {
- Application->MessageBox( " CMU200 config PFER fail ", "Fail", MB_OK );
- return false;
- }
- if( ! cmu_mod_config_control_repetition( &cmu, m_pTxIqSweep->i_measure_count ) )
- {
- Application->MessageBox( " CMU200 config PFER fail ", "Fail", MB_OK );
- return false;
- }
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_OOS:
- case TXIQ_OUTPUT_DATA_TYPE_SBS:
- {
- if( ! cmu_mod_xper_config_control_mode( &cmu, m_pTxIqSweep->i_measure_count ) )
- {
- Application->MessageBox( " CMU200 config IQ tunning fail ", "Fail", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_config_control_repetition( &cmu, m_pTxIqSweep->i_measure_count ) )
- {
- Application->MessageBox( " Agilent 8960 config IQ tunning fail ", "Fail", MB_OK );
- return false;
- }
- }
- break;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- MeasFcnDone = -999; /* Set to unknown state to start */
- Sleep(50);
- _VI_PTR pvi = vi;
- return true;
- }
- //======================================================================
- bool __fastcall T_TXIQ_SWEEP::CheckError(ViStatus ErrorStatus)
- {
- /*------------------------------------------------*/
- /* Check for driver errors. */
- /* If an error occurred reset the instrument and */
- /* return true else return false. */
- /*------------------------------------------------*/
- ViChar ErrorMessage[256];
- ViChar message[100];
- if (VI_SUCCESS > ErrorStatus){
- /* Query the error */
- age1960_error_message(vi, ErrorStatus, ErrorMessage);
- /* set the mouse pointer for the form back to the default */
- Screen->Cursor = crDefault;
- /* Display the error */
- sprintf(message, "Instrument Error: %ld %s",ErrorStatus, ErrorMessage);
- ShowMessage (message);
- /* Send a device clear - to ensure communication with the instrument */
- //age1960_dcl(vi);
- /* reset the instrument */
- age1960_reset(vi);
- return true;
- }
- return false;
- }
- //---------------------------------------------------------------------------
- bool __fastcall T_TXIQ_SWEEP::Trim_IQ_Sweep( void )
- {
- int i, j;
- AnsiString as_str = Get_DataTypeStr();
- as_str = "Output data type: " + as_str;
- sprintf(buf, as_str.c_str());
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- sprintf(buf, "OffsetI = %d, OffsetQ = %d", m_pTxIqSweep->offset_i, m_pTxIqSweep->offset_q);
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- buf[0]=' ';
- sprintf(buf1, "TrimI/TrimQ");
- strcat(buf, buf1);
- for( j=m_pTxIqSweep->min_trim_q; j<=m_pTxIqSweep->max_trim_q; j=j+m_pTxIqSweep->trim_q_step )
- {
- if(j==m_pTxIqSweep->min_trim_q)
- {
- sprintf(buf1, "%3d", j);
- }
- else
- {
- sprintf(buf1, "%12d", j);
- }
- strcat(buf, buf1);
- }
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- m_sBbTxCfg.TxOffsetI = m_pTxIqSweep->offset_i;
- m_sBbTxCfg.TxOffsetQ = m_pTxIqSweep->offset_q;
- if (m_pTxIqSweep->e_bbtxcfg_ver >= BBTXCFG_VER3)
- {
- m_sBbTxCfg.TxPhasesel = m_pTxIqSweep->sc_phasesel;
- }
- for (i=m_pTxIqSweep->min_trim_i; i<=m_pTxIqSweep->max_trim_i; i=i+m_pTxIqSweep->trim_i_step)
- {
- buf[0]=' ';
- sprintf(buf1, "%4d", i );
- strcat(buf, buf1);
- //strcat(buf, " ");
- for (j=m_pTxIqSweep->min_trim_q; j<=m_pTxIqSweep->max_trim_q; j=j+m_pTxIqSweep->trim_q_step)
- {
- m_sBbTxCfg.TxTrimI = i;
- m_sBbTxCfg.TxTrimQ = j;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver, m_sBbTxCfg);
- //if( META_SUCCESS != META_Rf_SetBBTXCfg_r( m_META_HANDLE_Obj.Get_MainHandle(), &RFReq_BBTXCFG, ::cb_rf_setbbtx_cfg_TrOff, &rf_setbbtx_cfg_token, NULL ) )
- //{ return false;
- //}
- this->Suspend();
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- SyncShowMsg("Set BBTXCfg parameter to target fail");
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- Sleep(50);
- rf_tx_level_req.arfcn = m_pTxIqSweep->s_arfcn;
- rf_tx_level_req.bsic = m_pTxIqSweep->tsc;
- rf_tx_level_req.power = m_pTxIqSweep->pcl;
- rf_tx_level_req.frames = -99;
- rf_tx_level_req.dacValue = m_pTxIqSweep->s_afc_dac;
- rf_tx_level_req.burstTypeNB = m_pTxIqSweep->e_burst_type;
- if ( META_Rf_NB_TX_r( m_META_HANDLE_Obj.Get_MainHandle(),
- &rf_tx_level_req,
- ::cb_rf_tx_level_TrOff,
- &rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- return false;
- }
- this->Suspend();
- switch (m_pTxIqSweep->e_output_data_type)
- {
- case TXIQ_OUTPUT_DATA_TYPE_PHERR:
- {
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_PFER) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 initialize measure function (PFER) fail ", "Fail", MB_OK );
- return false;
- }
- Sleep(50);
- if (age1960_fetchPFER_Q(
- vi,
- &PFERIntegrity,
- &PFERRMSError,
- &PFERPeakError,
- &PFERFreqError
- )!= VI_SUCCESS)
- {
- Application->MessageBox( "age1960_fetchPFER_Q() error" , "Error", MB_OK );
- return false;
- }
- }
- else
- {
- if (age1968A_Fetch_EPSK_Average_PhaseError(vi, &PFERRMSError) != VI_SUCCESS)
- {
- Application->MessageBox( "Agilent 8960 fetch EPSK average phase error fail" , "FAIL", MB_OK );
- return false;
- }
- }
- }
- else
- {
- if( ! cmu_mod_init( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_init() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_sample(&cmu, PH_ERR_RMS_AVERAGE, &PFERRMSError) )
- {
- Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_abort( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_abort() error" , "Error", MB_OK );
- return false;
- }
- }
- //FreqError = PFERFreqError;
- sprintf(buf1, "%12.4f", PFERRMSError );
- strcat(buf, buf1);
- // strcat(buf, " ");
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_OOS:
- {
- ViReal64 d_Original_Offset;
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS )
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK );
- return false;
- }
- if (age1960_fetchIQTuning_Q (
- vi,
- age1960_IQ_ARRAY_MIN,
- &IQTIntegrity,
- &IQTSpurFreq,
- &IQTSpurLevel,
- IQTResultsArray,
- IQTFreqsArray,
- &IQTTuningCount
- ) != VI_SUCCESS )
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK );
- return false;
- }
- d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
- if (NAN == d_Original_Offset)
- {
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Fetch_EPSK_Average_OrignalOffset(vi, &d_Original_Offset) != VI_SUCCESS)
- {
- Application->MessageBox("Agilent 8960 fetch EPSK average original offset fail ", "Fail", MB_OK );
- return false;
- }
- }
- }
- else
- {
- if( ! cmu_mod_xper_init( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_sample(&cmu, XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
- {
- Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_abort( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
- return false;
- }
- }
- sprintf(buf1, "%12.6f", d_Original_Offset );
- strcat(buf, buf1);
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_SBS:
- {
- ViReal64 d_IQ_Imbalance;
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK );
- return false;
- }
- if (age1960_fetchIQTuning_Q(vi,
- age1960_IQ_ARRAY_MIN,
- &IQTIntegrity,
- &IQTSpurFreq,
- &IQTSpurLevel,
- IQTResultsArray,
- IQTFreqsArray,
- &IQTTuningCount
- ) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK );
- return false;
- }
- d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
- if (NAN == d_IQ_Imbalance)
- {
- return false;
- }
- }
- else
- {
- if (age1968A_Fetch_EPSK_Average_IQImbalance(vi, &d_IQ_Imbalance) != VI_SUCCESS)
- {
- Application->MessageBox("Agilent 8960 fetch EPSK average IQ imbalance fail", "Fail", MB_OK);
- return false;
- }
- }
- }
- else
- {
- if( ! cmu_mod_xper_init( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_sample(&cmu, XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance) )
- {
- Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_abort( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
- return false;
- }
- }
- sprintf(buf1, "%12.6f", d_IQ_Imbalance );
- strcat(buf, buf1);
- // strcat(buf, " ");
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- }// switch
- }
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall T_TXIQ_SWEEP::Offset_IQ_Sweep( void )
- {
- int i, j;
- AnsiString as_str = Get_DataTypeStr();
- as_str = "Output data type: " + as_str;
- sprintf(buf, as_str.c_str());
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- sprintf(buf, "TrimI = %d, TrimQ = %d", m_pTxIqSweep->trim_i, m_pTxIqSweep->trim_q);
- //strcat(buf, buf1);
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- buf[0]=' ';
- sprintf(buf1, "OffsetI/OffsetQ");
- strcat(buf, buf1);
- for( j=m_pTxIqSweep->min_offset_q; j<=m_pTxIqSweep->max_offset_q; j=j+m_pTxIqSweep->offset_q_step )
- {
- if(j==m_pTxIqSweep->min_offset_q)
- {
- sprintf(buf1, "%5d", j);
- }
- else
- {
- sprintf(buf1, "%12d", j);
- }
- strcat(buf, buf1);
- }
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- m_sBbTxCfg.TxTrimI = m_pTxIqSweep->trim_i;
- m_sBbTxCfg.TxTrimQ = m_pTxIqSweep->trim_q;
- if (m_pTxIqSweep->e_bbtxcfg_ver >= BBTXCFG_VER3)
- {
- m_sBbTxCfg.TxPhasesel = m_pTxIqSweep->sc_phasesel;
- }
- for( i=m_pTxIqSweep->min_offset_i; i<=m_pTxIqSweep->max_offset_i; i=i+m_pTxIqSweep->offset_i_step )
- {
- buf[0]=' ';
- sprintf(buf1, "%4d", i );
- strcat(buf, buf1);
- strcat(buf, " ");
- for (j=m_pTxIqSweep->min_offset_q; j<=m_pTxIqSweep->max_offset_q; j=j+m_pTxIqSweep->offset_q_step )
- {
- m_sBbTxCfg.TxOffsetI = i;
- m_sBbTxCfg.TxOffsetQ = j;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver, m_sBbTxCfg);
- this->Suspend();
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- SyncShowMsg("Set BBTXCfg parameter to target fail");
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- Sleep(50);
- rf_tx_level_req.arfcn = m_pTxIqSweep->s_arfcn;
- rf_tx_level_req.bsic = m_pTxIqSweep->tsc;
- rf_tx_level_req.power = m_pTxIqSweep->pcl;
- rf_tx_level_req.frames = -99;
- rf_tx_level_req.dacValue = m_pTxIqSweep->s_afc_dac;
- rf_tx_level_req.burstTypeNB = m_pTxIqSweep->e_burst_type;
- if ( META_Rf_NB_TX_r( m_META_HANDLE_Obj.Get_MainHandle(),
- &rf_tx_level_req,
- ::cb_rf_tx_level_TrOff,
- &rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- return false;
- }
- this->Suspend();
- switch( m_pTxIqSweep->e_output_data_type )
- {
- case TXIQ_OUTPUT_DATA_TYPE_PHERR:
- {
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_PFER) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 initialize measure function (PFER) fail ", "Fail", MB_OK );
- return false;
- }
- Sleep(50);
- if ( age1960_fetchPFER_Q(
- vi,
- &PFERIntegrity,
- &PFERRMSError,
- &PFERPeakError,
- &PFERFreqError
- )!= VI_SUCCESS)
- {
- Application->MessageBox( "age1960_fetchPFER_Q() error" , "Error", MB_OK );
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Fetch_EPSK_Average_PhaseError(vi, &PFERRMSError) != VI_SUCCESS)
- {
- Application->MessageBox( "Agilent 8960 fetch EPSK average phase error fail" , "FAIL", MB_OK );
- return false;
- }
- }
- }
- else
- {
- if( ! cmu_mod_init( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_init() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_sample(&cmu, PH_ERR_RMS_AVERAGE, &PFERRMSError) )
- {
- Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_abort( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_abort() error" , "Error", MB_OK );
- return false;
- }
- }
- sprintf(buf1, "%12.4f", PFERRMSError );
- strcat(buf, buf1);
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_OOS:
- {
- ViReal64 d_Original_Offset;
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK );
- return false;
- }
- if (age1960_fetchIQTuning_Q(vi,
- age1960_IQ_ARRAY_MIN,
- &IQTIntegrity,
- &IQTSpurFreq,
- &IQTSpurLevel,
- IQTResultsArray,
- IQTFreqsArray,
- &IQTTuningCount
- ) != VI_SUCCESS )
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
- Application->MessageBox( " Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK );
- return false;
- }
- d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
- if( NAN == d_Original_Offset)
- {
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Fetch_EPSK_Average_OrignalOffset(vi, &d_Original_Offset) != VI_SUCCESS)
- {
- Application->MessageBox("Agilent 8960 fetch EPSK average original offset fail ", "Fail", MB_OK );
- return false;
- }
- }
- }
- else
- {
- if( ! cmu_mod_xper_init( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_sample(&cmu, XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
- {
- Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_abort( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
- return false;
- }
- }
- sprintf(buf1, "%12.6f", d_Original_Offset );
- strcat(buf, buf1);
- // strcat(buf, " ");
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_SBS:
- {
- ViReal64 d_IQ_Imbalance;
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox(as_error_msg.c_str() , "Error", MB_OK);
- Application->MessageBox("Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK);
- return false;
- }
- if (age1960_fetchIQTuning_Q(vi,
- age1960_IQ_ARRAY_MIN,
- &IQTIntegrity,
- &IQTSpurFreq,
- &IQTSpurLevel,
- IQTResultsArray,
- IQTFreqsArray,
- &IQTTuningCount
- ) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- Application->MessageBox(as_error_msg.c_str() , "Error", MB_OK);
- Application->MessageBox(" Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK);
- return false;
- }
- d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
- if (NAN == d_IQ_Imbalance)
- {
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Fetch_EPSK_Average_IQImbalance(vi, &d_IQ_Imbalance) != VI_SUCCESS)
- {
- Application->MessageBox("Agilent 8960 fetch EPSK average IQ imbalance fail", "Fail", MB_OK);
- return false;
- }
- }
- }
- else
- {
- if( ! cmu_mod_xper_init( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_sample(&cmu, XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance) )
- {
- Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
- return false;
- }
- if( ! cmu_mod_xper_abort( &cmu ) )
- {
- Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
- return false;
- }
- }
- sprintf(buf1, "%12.6f", d_IQ_Imbalance );
- strcat(buf, buf1);
- // strcat(buf, " ");
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- }// switch
- }
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool __fastcall T_TXIQ_SWEEP::Phasesel_Sweep(void)
- {
- int i, j;
- AnsiString as_str = Get_DataTypeStr();
- as_str = "Output data type: " + as_str;
- sprintf(buf, as_str.c_str());
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- sprintf(buf, "TrimI = %d, TrimQ = %d, OffsetI = %d, OffsetQ = %d",
- m_pTxIqSweep->trim_i, m_pTxIqSweep->trim_q, m_pTxIqSweep->offset_i, m_pTxIqSweep->offset_q);
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- buf[0]=' ';
- sprintf(buf1, "PhaseSel");
- strcat(buf, buf1);
- // for (i=m_pTxIqSweep->sc_min_phasesel; i<=m_pTxIqSweep->sc_max_phasesel; i+=m_pTxIqSweep->c_phasesel_step)
- // {
- // //if (j==m_pTxIqSweep->min_offset_q)
- // //{
- // // sprintf(buf1, "%5d", j);
- // //}
- // //else
- // {
- // sprintf(buf1, "%12d", i);
- // }
- // strcat(buf, buf1);
- // }
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- m_sBbTxCfg.TxTrimI = m_pTxIqSweep->trim_i;
- m_sBbTxCfg.TxTrimQ = m_pTxIqSweep->trim_q;
- m_sBbTxCfg.TxOffsetI = m_pTxIqSweep->offset_i;
- m_sBbTxCfg.TxOffsetQ = m_pTxIqSweep->offset_q;
- for (i=m_pTxIqSweep->sc_min_phasesel; i<=m_pTxIqSweep->sc_max_phasesel; i+=m_pTxIqSweep->c_phasesel_step)
- {
- buf[0]=' ';
- sprintf(buf1, "%4d", i );
- strcat(buf, buf1);
- strcat(buf, " ");
- m_sBbTxCfg.TxPhasesel = i;
- m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
- m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver, m_sBbTxCfg);
- this->Suspend();
- if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
- {
- SyncShowMsg("Set BBTXCfg parameter to target fail");
- return false;
- }
- if (this->Terminated)
- {
- this->OnTerminate = neByUser;
- return false;
- }
- Sleep(50);
- rf_tx_level_req.arfcn = m_pTxIqSweep->s_arfcn;
- rf_tx_level_req.bsic = m_pTxIqSweep->tsc;
- rf_tx_level_req.power = m_pTxIqSweep->pcl;
- rf_tx_level_req.frames = -99;
- rf_tx_level_req.dacValue = m_pTxIqSweep->s_afc_dac;
- rf_tx_level_req.burstTypeNB = m_pTxIqSweep->e_burst_type;
- if (META_Rf_NB_TX_r(m_META_HANDLE_Obj.Get_MainHandle(),
- &rf_tx_level_req,
- ::cb_rf_tx_level_TrOff,
- &rf_tx_level_token,
- NULL
- ) != META_SUCCESS)
- {
- return false;
- }
- this->Suspend();
- switch (m_pTxIqSweep->e_output_data_type)
- {
- case TXIQ_OUTPUT_DATA_TYPE_PHERR:
- {
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_PFER) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- SyncShowMsg(as_error_msg);
- return false;
- }
- Sleep(50);
- if (age1960_fetchPFER_Q(vi,
- &PFERIntegrity,
- &PFERRMSError,
- &PFERPeakError,
- &PFERFreqError
- )!= VI_SUCCESS)
- {
- SyncShowMsg("age1960_fetchPFER_Q() error");
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Fetch_EPSK_Average_PhaseError(vi, &PFERRMSError) != VI_SUCCESS)
- {
- SyncShowMsg("Agilent 8960 fetch EPSK average phase error fail");
- return false;
- }
- }
- }
- else
- {
- if(! cmu_mod_init(&cmu))
- {
- SyncShowMsg("cmu_mod_init() error");
- return false;
- }
- if (!cmu_mod_sample(&cmu, PH_ERR_RMS_AVERAGE, &PFERRMSError))
- {
- SyncShowMsg("cmu_mod_sample() error");
- return false;
- }
- if( ! cmu_mod_abort( &cmu ) )
- {
- SyncShowMsg("cmu_mod_abort() error");
- return false;
- }
- }
- sprintf(buf1, "%12.4f", PFERRMSError );
- strcat(buf, buf1);
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_OOS:
- {
- ViReal64 d_Original_Offset;
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- SyncShowMsg(as_error_msg);
- return false;
- }
- if (age1960_fetchIQTuning_Q(vi,
- age1960_IQ_ARRAY_MIN,
- &IQTIntegrity,
- &IQTSpurFreq,
- &IQTSpurLevel,
- IQTResultsArray,
- IQTFreqsArray,
- &IQTTuningCount
- ) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- SyncShowMsg(as_error_msg.c_str());
- SyncShowMsg(" Agilent 8960 fetch IQ tunning fail ");
- return false;
- }
- d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
- if (NAN == d_Original_Offset)
- {
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Fetch_EPSK_Average_OrignalOffset(vi, &d_Original_Offset) != VI_SUCCESS)
- {
- SyncShowMsg("Agilent 8960 fetch EPSK average original offset fail ");
- return false;
- }
- }
- }
- else // CMU200
- {
- if (!cmu_mod_xper_init(&cmu))
- {
- SyncShowMsg("cmu_mod_xper_init() error");
- return false;
- }
- if (!cmu_mod_xper_sample(&cmu, XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
- {
- SyncShowMsg("cmu_mod_sample() error");
- return false;
- }
- if (!cmu_mod_xper_abort(&cmu))
- {
- SyncShowMsg("cmu_mod_xper_abort() error");
- return false;
- }
- }
- sprintf(buf1, "%12.6f", d_Original_Offset );
- strcat(buf, buf1);
- // strcat(buf, " ");
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_SBS:
- {
- ViReal64 d_IQ_Imbalance;
- if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
- {
- if (GMSK == m_pTxIqSweep->e_modulation)
- {
- if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- SyncShowMsg(as_error_msg.c_str());
- SyncShowMsg("Agilent 8960 initialize measure function (IQTUNING) fail ");
- return false;
- }
- if (age1960_fetchIQTuning_Q(vi,
- age1960_IQ_ARRAY_MIN,
- &IQTIntegrity,
- &IQTSpurFreq,
- &IQTSpurLevel,
- IQTResultsArray,
- IQTFreqsArray,
- &IQTTuningCount
- ) != VI_SUCCESS)
- {
- age1960_error_message(vi, vistat, errmsg);
- AnsiString as_error_msg;
- as_error_msg = (AnsiString) errmsg;
- SyncShowMsg(as_error_msg.c_str());
- SyncShowMsg(" Agilent 8960 fetch IQ tunning fail ");
- return false;
- }
- d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
- if (NAN == d_IQ_Imbalance)
- {
- return false;
- }
- }
- else // EPSK
- {
- if (age1968A_Fetch_EPSK_Average_IQImbalance(vi, &d_IQ_Imbalance) != VI_SUCCESS)
- {
- SyncShowMsg("Agilent 8960 fetch EPSK average IQ imbalance fail");
- return false;
- }
- }
- }
- else
- {
- if (!cmu_mod_xper_init(&cmu))
- {
- SyncShowMsg( "cmu_mod_xper_init() error");
- return false;
- }
- if (!cmu_mod_xper_sample(&cmu, XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance))
- {
- SyncShowMsg("cmu_mod_sample() error");
- return false;
- }
- if (!cmu_mod_xper_abort(&cmu))
- {
- SyncShowMsg("cmu_mod_xper_abort() error");
- return false;
- }
- }
- sprintf(buf1, "%12.6f", d_IQ_Imbalance);
- strcat(buf, buf1);
- // strcat(buf, " ");
- Sleep(50);
- rf_stop.REQ_Start();
- }
- break;
- }// switch
- m_pTxIqSweep->st_Log->Add(buf);
- frmRFTool->write_TXIQ_log();
- }
- return true;
- }
- //----------------------------------------------------------------------------
- AnsiString __fastcall T_TXIQ_SWEEP::Get_DataTypeStr(void)
- {
- AnsiString as_str;
- switch (m_pTxIqSweep->e_output_data_type)
- {
- case TXIQ_OUTPUT_DATA_TYPE_PHERR:
- {
- as_str = "phase error";
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_OOS:
- {
- as_str = "original offset";
- }
- break;
- case TXIQ_OUTPUT_DATA_TYPE_SBS:
- {
- as_str = "IQ imbalance";
- }
- break;
- }
- return as_str;
- }
- //----------------------------------------------------------------------------
- void T_TXIQ_SWEEP::CNF_TXIQ_Sweep(void)
- {
- this->Resume();
- }