Age1968A.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:36k
- /*****************************************************************************
- * 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:
- * ---------
- * Age1968a.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Agilent 1968A software utility 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>
- #include <math.h>
- #include "visatype.h"
- #include "visa.h"
- #include "age1960.h"
- #pragma hdrstop
- #include "man_dll.h"
- #include "meta_utils.h"
- #include "meta_msg.h"
- #include "Age1968A.h"
- #include "AgeCommon.h"
- #ifndef _VISA_COMMON_H_
- #include "visa_common.h"
- #endif
- // misc
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _GSM_UTILS_H_
- #include "gsm_utils.h"
- #endif
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- ViStatus age1968A_operatingMode(ViSession vi, E_AGE_OPERATING_MODE OperatingMode)
- {
- AnsiString asOperatingMode;
- ViStatus vistat;
- switch (OperatingMode)
- {
- case OPERATING_MODE_ACTIVE:
- {
- asOperatingMode = "CALL:OPERating:MODE CALL";
- }
- break;
- case OPERATING_MODE_GSM_CW:
- {
- asOperatingMode = "CALL:OPERating:MODE CW";
- }
- break;
- case OPERATING_MODE_GSM_BCH:
- {
- asOperatingMode = "CALL:OPERating:MODE GBTest";
- }
- break;
- case OPERATING_MODE_GSM_BCH_TCH:
- {
- asOperatingMode = "CALL:OPERATING:MODE GBTTest";
- }
- break;
- case OPERATING_MODE_GPRS_BCH:
- {
- asOperatingMode = "CALL:OPERATING:MODE PBTest";
- }
- break;
- case OPERATING_MODE_GPRS_BCH_PDTCH:
- {
- asOperatingMode = "CALL:OPERATING:MODE PBPTest";
- }
- break;
- case OPERATING_MODE_EGPRS_BCH:
- {
- asOperatingMode = "CALL:OPERATING:MODE EBTest";
- }
- break;
- case OPERATING_MODE_EGPRS_BCH_PDTCH:
- {
- asOperatingMode = "CALL:OPERATING:MODE EBPTest";
- }
- break;
- default:
- {
- asOperatingMode = "CALL:OPERATING:MODE GBTTest";
- }
- break;
- }
- vistat = age1960_cmd(vi, asOperatingMode.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //===========================================================================
- //////////////////////////// CW mode ////////////////////////////////
- //===========================================================================
- ViStatus age1968A_cellPower_CW(ViSession vi, double dBm)
- {
- AnsiString as_cmd = "CALL:POWer:CW " + Double_To_AnsiString(dBm);
- ViStatus vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_GenFreq_CW(ViSession vi, FrequencyBand FreqBand, short arfcn)
- {
- double d_CenterFreq;
- getCenterFreq(FreqBand, arfcn, false, &d_CenterFreq);
- AnsiString as_cmd = "CALL:CELL:RFGENERATOR:FREQUENCY:SELECTED " + Double_To_AnsiString(d_CenterFreq) + "MHZ";
- ViStatus vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //===========================================================================
- ///////////////////////// PDTCH ////////////////////////////////
- //===========================================================================
- ViStatus age1968A_PDTCHMSTargetPower(ViSession vi, double dBm)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "RFAN:CONT:POW:AUTO OFF";
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- as_cmd = "RFAN:MAN:POW:BURS " + Double_To_AnsiString(dBm);
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
-
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_PDTCHMSTxLevel(ViSession vi, int i_PCL)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "RFAN:CONT:POW:AUTO ON";
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- as_cmd = "CALL:PDTCH:MS:TXLevel:BURSt " + IntToStr(i_PCL);
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_PDTCHARFCN(ViSession vi, short s_ARFCN)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "CALL:PDTCH:ARFCn:SELected " + IntToStr(s_ARFCN);
- vistat = age1960_cmd( vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //===========================================================================
- //////////////////////////////// TX power //////////////////////////////////
- //===========================================================================
- ViStatus age1968A_Config_ExpectedTxPower(ViSession vi, bool b_auto_control, double d_expected_power)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- if (b_auto_control)
- {
- as_cmd = "RFANalyzer:CONTrol:POWer:AUTO ON";
- vistat = age1960_cmd( vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- }
- else
- {
- as_cmd = "RFANalyzer:CONTrol:POWer:AUTO OFF";
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- as_cmd = "RFANalyzer:MANual:POWer:BURSt " + Double_To_AnsiString(d_expected_power);
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- }
- return VI_SUCCESS;
- }
- //--------------------------------------------------------------------------
- ViStatus age1968A_initMeasFcn_EGPRS_TXPOWER(ViSession vi)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "INITIATE:ETXPOWER";
- vistat = age1960_cmd( vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_TXPowerContOn(ViSession vi)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "SET:TXPower:CONT ON";
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_TXPowerContOff(ViSession vi)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "SET:TXPower:CONT OFF";
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_EPSK_TXPowerContOn(ViSession vi)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "SET:ETXPower:CONT ON";
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_EPSK_TXPowerContOff(ViSession vi)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "SET:ETXPower:CONT OFF";
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_ConfigTxPower(ViSession vi, int iMeasureCount, int iTriSour, int iDelay, int iTriQual, int iTimeout)
- {
- AnsiString asTXPowerSnum, asTXPowerTriSour, asTXPowerTimeout, asTXPowerDelay, asTXPowerTriQual;
- ViStatus vistat;
- // set measurecount
- asTXPowerSnum = "SETUP:TXPOWER:COUNT:SNUMBER " + IntToStr(iMeasureCount);
- vistat = age1960_cmd(vi,asTXPowerSnum.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // triger source
- switch (iTriSour)
- {
- case age1960_TRIG_AUTO:
- {
- asTXPowerTriSour = "SETUP:TXPOWER:TRIGGER:SOURCE AUTO";
- }
- break;
- case age1960_TRIG_PROT:
- {
- asTXPowerTriSour = "SETUP:TXPOWER:TRIGGER:SOURCE PROTocol";
- }
- break;
- case age1960_TRIG_RF_RISE:
- {
- asTXPowerTriSour = "SETUP:TXPOWER:TRIGGER:SOURCE RISE";
- }
- break;
- case age1960_TRIG_IMMEDIATE:
- {
- asTXPowerTriSour = "SETUP:TXPOWER:TRIGGER:SOURCE IMMediate";
- }
- break;
- default: // set to auto
- {
- asTXPowerTriSour = "SETUP:TXPOWER:TRIGGER:SOURCE AUTO";
- }
- break;
- }
- vistat = age1960_cmd(vi,asTXPowerTriSour.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set delay
- asTXPowerDelay = "SETUP:TXPOWER:TRIGGER:DELAY " + IntToStr( iDelay ); // sec
- vistat = age1960_cmd(vi,asTXPowerDelay.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set trigger qualifier
- if (AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON == iTriQual)
- {
- asTXPowerTriQual = "SETUP:TXPOWER:TRIGGER:QUALIFIER ON";
- }
- else
- {
- asTXPowerTriQual = "SETUP:TXPOWER:TRIGGER:QUALIFIER OFF";
- }
- vistat = age1960_cmd(vi,asTXPowerTriQual.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set timeout
- asTXPowerTimeout = "SETUP:TXPOWER:TIMEOUT:STIME " + IntToStr(iTimeout); // sec
- vistat = age1960_cmd(vi,asTXPowerTimeout.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_Config_EPSK_TxPower(ViSession vi, int iMeasureCount, int iTriSour, int iDelay, int iTriQual, int iTimeout)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- // set modulation
- // as_cmd = "SETup:ETXPower:MODulation EPSK";
- // if ( vistat = age1960_cmd(vi, as_cmd.c_str())!= VI_SUCCESS )
- // {
- // return vistat;
- //}
- // set measurecount
- as_cmd = "SETUP:ETXPOWER:COUNT:SNUMBER " + IntToStr(iMeasureCount);
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS )
- {
- return vistat;
- }
- // triger source
- switch (iTriSour)
- {
- case age1960_TRIG_AUTO:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE AUTO";
- }
- break;
- case age1960_TRIG_PROT:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE PROTocol";
- }
- break;
- case age1960_TRIG_RF_RISE:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE RISE";
- }
- break;
- case age1960_TRIG_IMMEDIATE:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE IMMediate";
- }
- break;
- default: // set to auto
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE AUTO";
- }
- break;
- }
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set delay
- as_cmd = "SETUP:ETXPOWER:TRIGGER:DELAY " + IntToStr(iDelay); // sec
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- #if 0
- // set trigger qualifier
- if (iTriQual == AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON )
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:QUALIFIER ON";
- }
- else
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:QUALIFIER OFF";
- }
- if (vistat = age1960_cmd(vi, s_cmd.c_str())!= VI_SUCCESS )
- {
- return vistat;
- }
- // set timeout
- as_cmd = "SETUP:ETXPOWER:TIMEOUT:STIME " + IntToStr( iTimeout ); // sec
- if ( vistat = age1960_cmd(vi, as_cmd.c_str())!= VI_SUCCESS )
- {
- return vistat;
- }
- #endif
- return vistat;
- }
- //------------------------------------------------------------------------------
- ViStatus age1968A_ReadTxPower(ViSession vi, ViReal64 *p_virTX)
- {
- AnsiString asTXPowerRead, asStr, asIntegrity, asTxPower, asBase, asExponent;;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- asTXPowerRead = "READ:TXP?";
- vistat=viWrite(vi, asTXPowerRead.c_str(), strlen(asTXPowerRead.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- //Sleep( 100 );
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if( getIntegrityFromStr( asStr, asIntegrity ) == false ) return VI_ERROR_ABORT;
- if( (asIntegrity.ToInt() != (int) INTEGRITY_NORMAL) &&
- (asIntegrity.ToInt() != (int) INTEGRITY_OVER_RANGE) &&
- (asIntegrity.ToInt() != (int) INTEGRITY_UNDER_RANGE )
- )
- {
- return VI_ERROR_ABORT;
- }
- if( getTxPowerFromStr( asStr, asTxPower ) == false ) return VI_ERROR_ABORT;
- if( getBaseFromStr( asTxPower, asBase ) == false ) return VI_ERROR_ABORT;
- if( getExponentFromStr( asTxPower, asExponent )== false ) return VI_ERROR_ABORT;
- //if( asExponent.ToInt() >= 0 )
- {
- *p_virTX = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
- }
- //Application->MessageBox( temp.c_str() , "Warning", MB_OK );
- //if( temp.Pos("NAN") ) return vistat;
- //temp=temp.SubString(1, temp.Pos(",")-1);
- //*p_virTX = atof(temp.c_str());
- return vistat;
- }
- //------------------------------------------------------------------------------
- ViStatus age1968A_ReadEGPRSTxPower(ViSession vi, ViReal64 *p_virTX)
- {
- AnsiString asTXPowerRead, asStr, asIntegrity, asTxPower, asBase, asExponent;;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- asTXPowerRead = "READ:ETXPower?";
- vistat=viWrite(vi, asTXPowerRead.c_str(), strlen(asTXPowerRead.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- //Sleep( 100 );
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if( getEpskIntegrityFromStr( asStr, asIntegrity ) == false ) return VI_ERROR_ABORT;
- if( (asIntegrity.ToInt() != (int) INTEGRITY_NORMAL) &&
- (asIntegrity.ToInt() != (int) INTEGRITY_OVER_RANGE) &&
- (asIntegrity.ToInt() != (int) INTEGRITY_UNDER_RANGE ) &&
- (asIntegrity.ToInt() != (int) INTEGRITY_SYNC_NOT_FOUND) &&
- (asIntegrity.ToInt() != (int) INTEGRITY_TRIGGER_EARLY_OR_FALL_EARLY) &&
- (asIntegrity.ToInt() != (int) INTEGRITY_TRIGGER_LATE_OR_RISE_LATE)
- )
- {
- return VI_ERROR_ABORT;
- }
- if( getEpskTxPowerFromStr( asStr, asTxPower ) == false ) return VI_ERROR_ABORT;
- if( getEpskBaseFromStr( asTxPower, asBase ) == false ) return VI_ERROR_ABORT;
- if( getEpskExponentFromStr( asTxPower, asExponent )== false ) return VI_ERROR_ABORT;
- //if( asExponent.ToInt() >= 0 )
- {
- *p_virTX = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
- }
- //Application->MessageBox( temp.c_str() , "Warning", MB_OK );
- //if( temp.Pos("NAN") ) return vistat;
- //temp=temp.SubString(1, temp.Pos(",")-1);
- //*p_virTX = atof(temp.c_str());
- return vistat;
- }
- //==============================================================================
- ///////////////////////////////// PFER ////////////////////////////////////
- //==============================================================================
- ViStatus age1968A_confPFER(ViSession vi, int iMeasureCount, int iTriSour,
- int iDelay, int iTriQual, int iTimeout)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- // burst sync
- as_cmd = "SETUP:PFERROR:SYNC MIDAMBLE";
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set measurecount
- as_cmd = "SETup:PFERror:COUNt:NUMBer " + IntToStr(iMeasureCount);
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // triger source
- switch (iTriSour)
- {
- case age1960_TRIG_AUTO:
- {
- as_cmd = "SETup:PFERror:TRIG:SOURce AUTO";
- }
- break;
- case age1960_TRIG_PROT:
- {
- as_cmd = "SETup:PFERror:TRIG:SOURce PROTocol";
- }
- break;
- case age1960_TRIG_RF_RISE:
- {
- as_cmd = "SETup:PFERror:TRIG:SOURce RISE";
- }
- break;
- case age1960_TRIG_IMMEDIATE:
- {
- as_cmd = "SETup:PFERror:TRIG:SOURce IMMediate";
- }
- break;
- default: // set to auto
- {
- as_cmd = "SETup:PFERror:TRIG:SOURce AUTO";
- }
- break;
- }
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set delay
- as_cmd = "SETup:PFERror:TRIGger:DELay " + IntToStr(iDelay); // sec
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set trigger qualifier
- if (AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON == iTriQual)
- {
- as_cmd = "SETup:PFERror:TRIGger:QUALifier:GSM ON";
- }
- else
- {
- as_cmd = "SETup:PFERror:TRIGger:QUALifier:GSM OFF";
- }
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set timeout
- as_cmd = "SETup:PFERror:TIMeout:TIME " + IntToStr(iTimeout); // sec
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //------------------------------------------------------------------------------
- ViStatus age1968A_ReadFreqError(ViSession vi, ViReal64 *p_virFreqErr)
- {
- AnsiString asPFERRead, asStr, asIntegrity, asTxPower, asBase, asExponent;;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- asPFERRead = "READ:PFER?";
- vistat=viWrite(vi, asPFERRead.c_str(), strlen(asPFERRead.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if( getIntegrityFromStr( asStr, asIntegrity ) == false ) return VI_ERROR_ABORT;
- if( (asIntegrity.ToInt() != (int) INTEGRITY_NORMAL) && (asIntegrity.ToInt() != (int) INTEGRITY_OVER_RANGE) && (asIntegrity.ToInt() != (int) INTEGRITY_UNDER_RANGE ))
- {
- return VI_ERROR_ABORT;
- }
- if( getTxPowerFromStr( asStr, asTxPower ) == false ) return VI_ERROR_ABORT;
- if( getBaseFromStr( asTxPower, asBase ) == false ) return VI_ERROR_ABORT;
- if( getExponentFromStr( asTxPower, asExponent )== false ) return VI_ERROR_ABORT;
- {
- *p_virFreqErr = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
- }
- return vistat;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_ConfigTSC(ViSession vi, int i_TSC)
- {
- AnsiString asTSC;
- ViStatus vistat;
- unsigned long num;
- // set measurecount
- asTSC = "CALL:BURSt:TYPE TSC" + IntToStr(i_TSC);
- vistat = age1960_cmd(vi, asTSC.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return vistat;
- }
- //------------------------------------------------------------------------------
- ViReal64 __fastcall get_Original_Offset(ViReal64 *p_IQTFreqs, ViReal64 *p_IQTResults, ViInt32 IQTTuningCount)
- {
- for(int i=0; i<IQTTuningCount; i++)
- {
- if( *(p_IQTFreqs+i) == IQT_ORIGINAL_OFFSET_FREQ )
- {
- return *(p_IQTResults+i);
- }
- }
- return NAN;
- }
- //------------------------------------------------------------------------------
- ViReal64 __fastcall get_IQ_Imbalance(ViReal64 *p_IQTFreqs, ViReal64 *p_IQTResults, ViInt32 IQTTuningCount)
- {
- for(int i=0; i<IQTTuningCount; i++)
- {
- if( *(p_IQTFreqs+i) == IQT_IQ_IMBALANCE_FREQ )
- {
- return *(p_IQTResults+i);
- }
- }
- return NAN;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ViStatus age1968A_Config_DynPower(ViSession vi, int iMeasureCount, int iTimeout)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- as_cmd = "SETup:DPOWer:CONTinuous OFF";
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- as_cmd = "SETUP:DPOWER:COUNT:NUMBER:SELECTED " + IntToStr(iMeasureCount);
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- as_cmd = "SETup:DPOWer:TIMeout " + IntToStr( iTimeout ) + "S";
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return VI_SUCCESS;
- }
- //==============================================================================
- //////////////////////////// EPSK ///////////////////////////////
- //==============================================================================
- ViStatus age1968A_Config_EPSK_CodingScheme(ViSession vi, int i_MCS)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- unsigned long num;
- as_cmd = "CALL:PDTCH:MCSCheme:EBPTest MCS" + IntToStr(i_MCS) + "P1";
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return vistat;
- }
- //---------------------------------------------------------------------------
- ViStatus age1968A_confTXPower( ViSession vi, int iMeasureCount, int iTriSour,
- int iDelay, int iTriQual, int iTimeout )
- {
- AnsiString as_cmd;
- ViStatus vistat;
- // set measure count
- as_cmd = "SETUP:ETXPOWER:COUNT:SNUMBER " + IntToStr(iMeasureCount);
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // triger source
- switch (iTriSour)
- {
- case age1960_TRIG_AUTO:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE AUTO";
- }
- break;
- case age1960_TRIG_PROT:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE PROTocol";
- }
- break;
- case age1960_TRIG_RF_RISE:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE RISE";
- }
- break;
- case age1960_TRIG_IMMEDIATE:
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE IMMediate";
- }
- break;
- default: // set to auto
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:SOURCE AUTO";
- }
- break;
- }
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set delay
- as_cmd = "SETUP:ETXPOWER:TRIGGER:DELAY " + IntToStr(iDelay); // sec
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set trigger qualifier
- if (AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON == iTriQual)
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:QUALIFIER ON";
- }
- else
- {
- as_cmd = "SETUP:ETXPOWER:TRIGGER:QUALIFIER OFF";
- }
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set timeout
- as_cmd = "SETUP:ETXPOWER:TIMEOUT:STIME " + IntToStr(iTimeout); // sec
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return vistat;
- }
- //----------------------------------------------------------------------------
- ViStatus age1968A_FetchEpskTxPower(ViSession vi, ViReal64 *p_virTX)
- {
- AnsiString asTXPowerFetch, asStr, asIntegrity, asTxPower, asBase, asExponent;;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- asTXPowerFetch = "FETCh:ETXP:POW:BURSt?";
- vistat=viWrite(vi, asTXPowerFetch.c_str(), strlen(asTXPowerFetch.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- //Sleep( 100 );
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if( getIntegrityFromStr( asStr, asIntegrity ) == false ) return VI_ERROR_ABORT;
- if( (asIntegrity.ToInt() != (int) INTEGRITY_NORMAL) && (asIntegrity.ToInt() != (int) INTEGRITY_OVER_RANGE) && (asIntegrity.ToInt() != (int) INTEGRITY_UNDER_RANGE ))
- {
- return VI_ERROR_ABORT;
- }
- if( getTxPowerFromStr( asStr, asTxPower ) == false ) return VI_ERROR_ABORT;
- if( getBaseFromStr( asTxPower, asBase ) == false ) return VI_ERROR_ABORT;
- if( getExponentFromStr( asTxPower, asExponent )== false ) return VI_ERROR_ABORT;
- //if( asExponent.ToInt() >= 0 )
- {
- *p_virTX = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
- }
- //Application->MessageBox( temp.c_str() , "Warning", MB_OK );
- //if( temp.Pos("NAN") ) return vistat;
- //temp=temp.SubString(1, temp.Pos(",")-1);
- //*p_virTX = atof(temp.c_str());
- return vistat;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ViStatus age1968A_Config_EPSK_ModACcuracy(ViSession vi, int iMeasureCount, int iTriSour, int iDelay, int iTimeout)
- {
- AnsiString as_cmd;
- ViStatus vistat;
- // set single
- as_cmd = "SETup:EMACcuracy:CONTinuous OFF";
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- as_cmd = "SETup:EMACcuracy:IQIMbalance:STATe ON";
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set measurecount
- as_cmd = "SETup:EMACcuracy:COUNT:SNUMBER " + IntToStr(iMeasureCount);
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // triger source
- switch (iTriSour)
- {
- case age1960_TRIG_AUTO:
- {
- as_cmd = "SETup:EMACcuracy:TRIGGER:SOURCE AUTO";
- }
- break;
- case age1960_TRIG_PROT:
- {
- as_cmd = "SETup:EMACcuracy:TRIGGER:SOURCE PROTocol";
- }
- break;
- case age1960_TRIG_RF_RISE:
- {
- as_cmd = "SETup:EMACcuracy:TRIGGER:SOURCE RISE";
- }
- break;
- case age1960_TRIG_IMMEDIATE:
- {
- as_cmd = "SETup:EMACcuracy:TRIGGER:SOURCE IMMediate";
- }
- break;
- default: // set to auto
- {
- as_cmd = "SETup:EMACcuracy:TRIGGER:SOURCE AUTO";
- }
- break;
- }
- vistat = age1960_cmd(vi, as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set delay
- as_cmd = "SETup:EMACcuracy:TRIGGER:DELAY " + IntToStr(iDelay); // sec
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // set timeout
- as_cmd = "SETup:EMACcuracy:TIMEOUT:STIME " + IntToStr(iTimeout); // sec
- vistat = age1960_cmd(vi,as_cmd.c_str());
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- return vistat;
- }
- //----------------------------------------------------------------------------
- ViStatus age1968A_Fetch_EPSK_Average_PhaseError(ViSession vi, ViReal64 *p_virPhErr)
- {
- AnsiString as_cmd, asStr, asIntegrity, as_OOS, as_SBS, asBase, asExponent;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- // init
- as_cmd = "INIT:EMACcuracy:ON";
- vistat = viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- // fetch
- as_cmd = "FETCh:EMACcuracy:PERRor:RMS?";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if (vistat != VI_SUCCESS)
- {
- return vistat;
- }
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if (!getBaseFromStr(asStr, asBase))
- {
- return VI_ERROR_ABORT;
- }
- if (!getExponentFromStr(asStr, asExponent))
- {
- return VI_ERROR_ABORT;
- }
- *p_virPhErr = (ViReal64) atof(asBase.c_str()) * pow10(asExponent.ToInt());
- // *p_virPhErr = 0 - *p_virOOS;
- // abort
- as_cmd = "ABORt:EMACcuracy";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- return vistat;
- }
- //----------------------------------------------------------------------------
- ViStatus age1968A_Fetch_EPSK_Average_OrignalOffset(ViSession vi, ViReal64 *p_virOOS )
- {
- AnsiString as_cmd, asStr, asIntegrity, as_OOS, as_SBS, asBase, asExponent;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- as_cmd = "INIT:EMACcuracy:ON";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- as_cmd = "FETCh:EMACcuracy:OOFFset?";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- //Sleep( 100 );
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if (asStr.AnsiPos("9.91E37"))
- {
- return VI_ERROR_INV_EXPR;
- }
-
- if (!getBaseFromStr(asStr, asBase))
- {
- return VI_ERROR_ABORT;
- }
- if (!getExponentFromStr(asStr, asExponent))
- {
- return VI_ERROR_ABORT;
- }
- *p_virOOS = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
- *p_virOOS = 0 - *p_virOOS;
- as_cmd = "ABORt:EMACcuracy";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- return vistat;
- }
- //----------------------------------------------------------------------------
- ViStatus age1968A_Fetch_EPSK_Average_IQImbalance(ViSession vi, ViReal64 *p_virSBS)
- {
- AnsiString as_cmd, asStr, asIntegrity, as_OOS, as_SBS, asBase, asExponent;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- as_cmd = "INIT:EMACcuracy:ON";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- as_cmd = "FETCh:EMACcuracy:IQIMbalance?";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- //Sleep( 100 );
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if (asStr.AnsiPos("9.91E37"))
- {
- return VI_ERROR_INV_EXPR;
- }
- if (!getBaseFromStr(asStr, asBase))
- {
- return VI_ERROR_ABORT;
- }
- if (!getExponentFromStr(asStr, asExponent))
- {
- return VI_ERROR_ABORT;
- }
- *p_virSBS = (ViReal64) atof(asBase.c_str()) * pow10(asExponent.ToInt());
- as_cmd = "ABORt:EMACcuracy";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- return vistat;
- }
- //----------------------------------------------------------------------------
- ViStatus age1968A_Fetch_EPSK_Average_TxIq(ViSession vi, ViReal64 *p_virSBS, ViReal64 *p_virOOS)
- {
- AnsiString as_cmd, asStr, asIntegrity, as_OOS, as_SBS, asBase, asExponent;
- ViStatus vistat;
- unsigned long num;
- char buf[BUFSIZE];
- as_cmd = "INIT:EMACcuracy:ON";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- as_cmd = "FETCh:EMACcuracy?";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- vistat=viRead(vi, buf, BUFSIZE, &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- buf[num-1]=NULL;
- asStr=(AnsiString)buf;
- if (asStr.AnsiPos("9.91E37"))
- {
- return VI_ERROR_INV_EXPR;
- }
- if (!getBaseFromStr(asStr, asBase))
- {
- return VI_ERROR_ABORT;
- }
- if (!getExponentFromStr(asStr, asExponent))
- {
- return VI_ERROR_ABORT;
- }
-
- *p_virSBS = (ViReal64) atof(asBase.c_str()) * pow10( asExponent.ToInt() );
-
- as_cmd = "ABORt:EMACcuracy";
- vistat=viWrite(vi, as_cmd.c_str(), strlen(as_cmd.c_str()), &num);
- if( vistat!=VI_SUCCESS ) return vistat;
- return vistat;
- }