cmu200.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:92k
- /*****************************************************************************
- * 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:
- * ---------
- * cmu200.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * CMU 200 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 <assert.h>
- #pragma hdrstop
- #ifndef _META_FACTORY_CFG_H_
- #include "meta_factory_cfg.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- #ifndef _META_UTILS_H_
- #include "meta_utils.h"
- #endif
- #ifndef _META_FACTORY_H_
- #include "meta_factory.h"
- #endif
- #ifndef _FORM_MAIN_H_
- #include "form_main.h"
- #endif
- #ifndef _CMU200_H_
- #include "cmu200.h"
- #endif
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- //---------------------------------------------------------------------------
- bool cmu_init_rfg(CMU_VAR *cmu)
- {
- if( cmu->BAND.AnsiCompareIC("GSM") == 0 ) { strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm, cmd, strlen(cmd), &num); }
- else if( cmu->BAND.AnsiCompareIC("DCS") == 0 ) { strcpy(cmd, "INIT:RFG"); viWrite(cmu->dcs, cmd, strlen(cmd), &num); }
- else if( cmu->BAND.AnsiCompareIC("PCS") == 0 ) { strcpy(cmd, "INIT:RFG"); viWrite(cmu->pcs, cmd, strlen(cmd), &num); }
- else if( cmu->BAND.AnsiCompareIC("GSM850") == 0 ) { strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num); }
- else { return false; }
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_init_TX_FreqErr(CMU_VAR *cmu)
- {
- // band
- //RFBandSupport_S band_support;
- status=viOpenDefaultRM(&cmu->RM);
- if( status<VI_SUCCESS ) return false;
- status=viOpen(cmu->RM, (cmu->ADD+"::0::INSTR").c_str(), VI_NULL, cmu->TMO, &cmu->base);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->base, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- strcpy(cmd, "*rst"); viWrite(cmu->base, cmd, strlen(cmd), &num);
- //strcpy(cmd, "*idn?"); viWrite(cmu->base, cmd, strlen(cmd), &num); viRead(cmu->base, buf, BUF, &num);
- strcpy(cmd, "SYST:REM:ADDR:SEC 3,"GSM900MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- strcpy(cmd, "SYST:REM:ADDR:SEC 5,"GSM1800MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- strcpy(cmd, "SYST:REM:ADDR:SEC 7,"GSM1900MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- if( frmMainSel->cbGSM850->Checked )
- //frmMainSel->Get_FinalBandSupport( band_support );
- //if( band_support.GSM850 )
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 9,"GSM850MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- status=viOpen(cmu->RM, (cmu->ADD+"::3::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).gsm);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->gsm, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- status=viOpen(cmu->RM, (cmu->ADD+"::5::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).dcs);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->dcs, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- status=viOpen(cmu->RM, (cmu->ADD+"::7::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).pcs);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->pcs, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- if( frmMainSel->cbGSM850->Checked )
- //frmMainSel->Get_FinalBandSupport( band_support );
- //if( band_support.GSM850 )
- {
- status=viOpen(cmu->RM, (cmu->ADD+"::9::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).gsm850);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->gsm850, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- }
- strcpy(cmd, "*rst"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "INIT:RFG"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- //Sleep(500);
- strcpy(cmd, "*rst"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "INIT:RFG"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- // Sleep(500);
- strcpy(cmd, "*rst"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- //gsm nonsignaling setup--------------------------------------------------------
- //Sleep(500);
- if( frmMainSel->cbGSM850->Checked )
- //frmMainSel->Get_FinalBandSupport( band_support );
- //if( band_support.GSM850 )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_init_RCT(CMU_VAR *cmu, AnsiString asFreqBand, bool bReset)
- {
- // RM
- status = viOpenDefaultRM(&cmu->RM);
- if (status<VI_SUCCESS)
- {
- return false;
- }
- // base
- status=viOpen (cmu->RM, (cmu->ADD+"::0::INSTR").c_str(), VI_NULL, cmu->TMO, &cmu->base);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- status=viSetAttribute(cmu->base, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- if (bReset)
- {
- strcpy(cmd, "*rst"); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- // GSM handle
- if (IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 3,"GSM900MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- // DCS hancle
- if (IsCmuBandSupported(asFreqBand, CMU_DCS1800_BAND))
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 5,"GSM1800MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- // PCS handle
- if (IsCmuBandSupported(asFreqBand, CMU_PCS1900_BAND))
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 7,"GSM1900MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- // GSM850 handle
- if (IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND))
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 9,"GSM850MS_NSig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- // timeout
- if (IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- status = viOpen(cmu->RM, (cmu->ADD+"::3::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).gsm);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- status = viSetAttribute(cmu->gsm, VI_ATTR_TMO_VALUE, cmu->TMO);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- if (IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND) )
- {
- status=viOpen(cmu->RM, (cmu->ADD+"::5::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).dcs);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->dcs, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_PCS1900_BAND) )
- {
- status=viOpen(cmu->RM, (cmu->ADD+"::7::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).pcs);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->pcs, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND) )
- {
- status=viOpen(cmu->RM, (cmu->ADD+"::9::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).gsm850);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->gsm850, VI_ATTR_TMO_VALUE, cmu->TMO);
- if( status<VI_SUCCESS ) return false;
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_PCS1900_BAND) )
- {
- if( bReset )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- }
- //strcpy(cmd, "INIT:RFG"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- }
- //Sleep(500);
- if ( IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND) )
- {
- if( bReset )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- }
- //strcpy(cmd, "INIT:RFG"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- }
- // Sleep(500);
- if ( IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- if( bReset )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- }
- // strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- }
- //gsm nonsignaling setup--------------------------------------------------------
- //Sleep(500);
- if ( IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND) )
- {
- if( bReset )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- // strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- //gsm nonsignaling setup--------------------------------------------------------
- if ( IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- strcpy(cmd, "INP:STAT RF2"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_gsm_i); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_gsm_o); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- //jh lai, MTK AFC debug
- //strcpy(cmd, "CONF:RFG:MOD:TRAN BURS"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- //strcpy(cmd, "CONF:RFG:MOD:BIT:SEL ALL0"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- //strcpy(cmd, "CONF:RFG:MOD:BIT:SEL DUMM"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:FREQ:CHAN 70CH"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:LEV:UTIM -60"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:SOUR RFP"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:THR HIGH"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:SOUR IFP"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:THR LOW"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:CHAN 70CH"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:TSEQ GSM5"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "LEV:MODE AUT"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT SCAL,10"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT:REP SING,NONE,NONE"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRAC:REM:MODE:DISP OFF"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- // strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- }
- //dcs nonsignaling setup-------------------------------------------------------
- if ( IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND) )
- {
- strcpy(cmd, "INP:STAT RF2"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_dcs_i); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_dcs_o); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:FREQ:CHAN 512CH"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:LEV:UTIM -60"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:SOUR RFP"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:THR HIGH"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:SOUR IFP"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:THR LOW"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:CHAN 512CH"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:TSEQ GSM5"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "LEV:MODE AUT"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT SCAL,10"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT:REP SING,NONE,NONE"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRAC:REM:MODE:DISP OFF"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- }
- //pcs nonsignaling setup-------------------------------------------------------
- if ( IsCmuBandSupported( asFreqBand, CMU_PCS1900_BAND) )
- {
- strcpy(cmd, "INP:STAT RF2"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_pcs_i); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_pcs_o); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:FREQ:CHAN 512CH"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:LEV:UTIM -60"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:SOUR RFP"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:THR HIGH"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:SOUR IFP"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:THR LOW"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:CHAN 512CH"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:TSEQ GSM5"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "LEV:MODE AUT"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT SCAL,10"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT:REP SING,NONE,NONE"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRAC:REM:MODE:DISP OFF"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- }
- // gsm850
- //gsm850 nonsignaling setup--------------------------------------------------------
- if ( IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND) )
- {
- strcpy(cmd, "INP:STAT RF2"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_gsm850_i); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_gsm850_o); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- //jh lai, MTK AFC debug
- //strcpy(cmd, "CONF:RFG:MOD:TRAN BURS"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- //strcpy(cmd, "CONF:RFG:MOD:BIT:SEL ALL0"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- //strcpy(cmd, "CONF:RFG:MOD:BIT:SEL DUMM"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:FREQ:CHAN 190CH"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "SOUR:RFG:LEV:UTIM -60"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:SOUR RFP"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRIG:THR HIGH"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:SOUR IFP"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "TRIG:THR LOW"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:CHAN 190CH"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "RFAN:TSEQ GSM5"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "LEV:MODE AUT"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT SCAL,10"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:POW:CONT:REP SING,NONE,NONE"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- // strcpy(cmd, "TRAC:REM:MODE:DISP OFF"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- // strcpy(cmd, "INIT:RFG"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_reset( CMU_VAR *cmu, AnsiString asFreqBand )
- {
- // reset
- if ( IsCmuBandSupported( asFreqBand, CMU_PCS1900_BAND) )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- Sleep(2000);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND) )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- Sleep(2000);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- Sleep(2000);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND) )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- Sleep(2000);
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_cellband(int band, CMU_VAR *cmu)
- {
- // if( cmu->BAND.AnsiCompareIC("GSM")==0 && band==CMU_PGSM_BAND ) return true;
- // else if( cmu->BAND.AnsiCompareIC("GSM")==0 && band==CMU_EGSM_BAND ) return true;
- // else if( cmu->BAND.AnsiCompareIC("DCS")==0 && band==CMU_DCS1800_BAND ) return true;
- // else if( cmu->BAND.AnsiCompareIC("PCS")==0 && band==CMU_PCS1900_BAND ) return true;
- // else if( cmu->BAND.AnsiCompareIC("GSM850")==0 && band==CMU_GSM850_BAND ) return true;
- // abort current active RFG
- if( cmu->BAND.AnsiCompareIC("GSM") == 0 ) { strcpy(cmd, "ABOR:RFG"); viWrite(cmu->gsm, cmd, strlen(cmd), &num); }
- else if( cmu->BAND.AnsiCompareIC("DCS") == 0 ) { strcpy(cmd, "ABOR:RFG"); viWrite(cmu->dcs, cmd, strlen(cmd), &num); }
- else if( cmu->BAND.AnsiCompareIC("PCS") == 0 ) { strcpy(cmd, "ABOR:RFG"); viWrite(cmu->pcs, cmd, strlen(cmd), &num); }
- else if( cmu->BAND.AnsiCompareIC("GSM850") == 0 ) { strcpy(cmd, "ABOR:RFG"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num); }
- if( band==0 ) return false;
- else if( band==CMU_PGSM_BAND || band==CMU_EGSM_BAND ) cmu->BAND="GSM";
- else if( band==CMU_DCS1800_BAND ) cmu->BAND="DCS";
- else if( band==CMU_PCS1900_BAND ) cmu->BAND="PCS";
- else if( band==CMU_GSM850_BAND ) cmu->BAND="GSM850";
- else
- { return false;}
- if( band==CMU_PGSM_BAND || band==CMU_EGSM_BAND )
- {
- strcpy(cmd, "init:rfg;*opc?"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- viRead(cmu->gsm, buf, BUF, &num);
- Sleep(500);
- }
- else if( band==CMU_DCS1800_BAND )
- {
- strcpy(cmd, "init:rfg;*opc?"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- viRead(cmu->dcs, buf, BUF, &num);
- Sleep(500);
- }
- else if( band==CMU_PCS1900_BAND )
- {
- strcpy(cmd, "init:rfg;*opc?"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- viRead(cmu->pcs, buf, BUF, &num);
- Sleep(500);
- }
- else if( band==CMU_GSM850_BAND )
- {
- strcpy(cmd, "init:rfg;*opc?"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- viRead(cmu->gsm850, buf, BUF, &num);
- Sleep(500);
- }
- else
- {
- return false;
- }
- // Sleep(500);
- return true;
- }
- //cmu generator functions-------------------------------------------------------
- bool cmu_bcharfcn(short chan, CMU_VAR *cmu)
- {
- sprintf(cmd, "sour:rfg:freq %dch;*opc?", chan);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) { status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); viRead(cmu->gsm, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) { status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); viRead(cmu->dcs, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) { status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); viRead(cmu->pcs, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) { status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); viRead(cmu->gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_cellpower(double power, CMU_VAR *cmu)
- {
- if( power>=0 ) power=-60;
- sprintf(cmd, "sour:rfg:lev:utim %f", power);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- else { return false; }
- Sleep(100);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_pow_cont(bool set, CMU_VAR *cmu)
- {
- if( set )
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT");
- else
- strcpy(cmd, "CONF:RFG:MOD:TRAN BURS");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- else { return false; }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- ///////////////////////////// Generator /////////////////////////////////
- //---------------------------------------------------------------------------
- bool cmu_gen_freq_offset(CMU_VAR *cmu, double d_freq)
- {
- AnsiString as_cmd = "SOURce:RFGenerator:FM:DEViation " + Double_To_AnsiString(d_freq);
- if ((cmu->BAND).AnsiCompareIC("GSM") == 0)
- {
- status = viWrite(cmu->gsm, as_cmd.c_str(), as_cmd.Length(), &num);
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS") == 0)
- {
- status = viWrite(cmu->dcs, as_cmd.c_str(), as_cmd.Length(), &num);
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS") == 0)
- {
- status = viWrite(cmu->pcs, as_cmd.c_str(), as_cmd.Length(), &num);
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850")==0)
- {
- status = viWrite(cmu->gsm850, as_cmd.c_str(), as_cmd.Length(), &num);
- }
- else
- {
- assert(false);
- return false;
- }
- if (status < VI_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_gen_bit_mod(E_CMU200_GEN_BIT_MODU_T mode, CMU_VAR *cmu)
- {
- switch (mode)
- {
- case CMU200_GEN_BIT_MODU_OFF:
- {
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL OFF");
- }
- break;
- case CMU200_GEN_BIT_MODU_ALL_ZERO:
- {
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL ALL0");
- }
- break;
- case CMU200_GEN_BIT_MODU_PRBS:
- {
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS");
- }
- break;
- case CMU200_GEN_BIT_MODU_DUMMY_BURST:
- {
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL DUMM");
- }
- break;
- case CMU200_GEN_BIT_MODU_8_PSK_ALL_ZERO:
- {
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL EALL0");
- }
- break;
- case CMU200_GEN_BIT_MODU_8_PSK_PRBS:
- {
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL EPRBS");
- }
- break;
- default:
- {
- assert(false);
- }
- }
- if ((cmu->BAND).AnsiCompareIC("GSM") == 0)
- {
- status = viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS") == 0)
- {
- status = viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS") == 0)
- {
- status = viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850")==0)
- {
- status = viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- else
- {
- assert(false);
- return false;
- }
- if (status < VI_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //-----------------------------------------------------------------------
- bool cmu_gen_tsc(E_CMU200_GEN_TSC_TYPE_T tsc, CMU_VAR *cmu)
- {
- switch (tsc)
- {
- case CMU200_GEN_TSC_ALL_ZERO:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL ALL");
- }
- break;
- case CMU200_GEN_TSC_GSM_0:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM0");
- }
- break;
- case CMU200_GEN_TSC_GSM_1:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM1");
- }
- break;
- case CMU200_GEN_TSC_GSM_2:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM2");
- }
- break;
- case CMU200_GEN_TSC_GSM_3:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM3");
- }
- break;
- case CMU200_GEN_TSC_GSM_4:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM4");
- }
- break;
- case CMU200_GEN_TSC_GSM_5:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5");
- }
- break;
- case CMU200_GEN_TSC_GSM_6:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM6");
- }
- break;
- case CMU200_GEN_TSC_GSM_7:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM7");
- }
- break;
- case CMU200_GEN_TSC_DUMMY:
- {
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL DUMMy");
- }
- break;
- default:
- {
- }
- break;
- }
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- else { return false; }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //cmu analyser functions--------------------------------------------------------
- bool cmu_tsc(int tsc, CMU_VAR *cmu)
- {
- sprintf(cmd, "rfan:tseq GSM%d", tsc);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_tcharfcn(short chan, CMU_VAR *cmu)
- {
- sprintf(cmd, "rfan:chan %dch;*opc?", chan);
- if( (cmu->BAND).AnsiCompareIC("GSM") == 0 ) { status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); viRead(cmu->gsm, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("DCS") == 0 ) { status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); viRead(cmu->dcs, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("PCS") == 0 ) { status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); viRead(cmu->pcs, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("GSM850") == 0 ) { status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); viRead(cmu->gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_pdtcharfcn(short chan, CMU_VAR *cmu)
- {
- sprintf(cmd, "rfan:chan %dch;*opc?", chan);
- if( (cmu->BAND).AnsiCompareIC("GSM") == 0 ) { status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); viRead(cmu->gsm, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("DCS") == 0 ) { status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); viRead(cmu->dcs, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("PCS") == 0 ) { status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); viRead(cmu->pcs, buf, BUF, &num); }
- else if( (cmu->BAND).AnsiCompareIC("GSM850") == 0 ) { status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); viRead(cmu->gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_mxtxlevel(int lev, CMU_VAR *cmu)
- {
- sprintf(cmd, "conf:rfan:tpcl %d", lev);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_txpwr_repetition_single_shot( CMU_VAR *cmu )
- {
- char str[256];
- sprintf(str, "conf:pow:cont:rep sing,none,none");
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_txpwr_repetition_continuous( CMU_VAR *cmu )
- {
- char str[256];
- sprintf(str, "conf:pow:cont:rep cont");
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_txpwr_repetition_single_shot_epsk( CMU_VAR *cmu )
- {
- char str[256];
- sprintf(str, "conf:pow:epsk:cont:rep sing,none,none");
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_txpwr_repetition_continuous_epsk( CMU_VAR *cmu )
- {
- char str[256];
- sprintf(str, "conf:pow:epsk:cont:rep cont");
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_txpwr_control_mode( CMU_VAR *cmu, int count )
- {
- char str[256];
- sprintf(str, "conf:pow:cont scal,%d", count );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_txpwr_control_mode_epsk( CMU_VAR *cmu, int count )
- {
- char str[256];
- sprintf(str, "conf:pow:epsk:cont scal,%d", count );
- //sprintf(str, "conf:pow:epsk:cont array,%d", count );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- sprintf(str, "conf:pow:epsk:cont:rpm dcom" );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_readtxpower(double *pow, CMU_VAR *cmu)
- {
- AnsiString temp;
- strcpy(cmd, "read:pow?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- temp=temp.SubString(1, temp.Pos(",")-1);
- *pow = atof(temp.c_str());
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_readtxpower_8psk(double *pow, CMU_VAR *cmu)
- {
- AnsiString temp;
- strcpy(cmd, "read:pow:epsk?");
- // strcpy(cmd, "READ:ARRAy:POWer:EPSK:AVERage?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- temp=temp.SubString(1, temp.Pos(",")-1);
- *pow = atof(temp.c_str());
- return true;
- }
- //=============================================================================
- /////////////////////// Modulation //////////////////////////////////
- //=============================================================================
- bool cmu_mod_init( CMU_VAR *cmu )
- {
- strcpy(cmd, "init:mod");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_config_control_mode( CMU_VAR *cmu, int count )
- {
- char str[256];
- sprintf(str, "conf:mod:perr:cont scal,%d", count );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_config_control_mode_8psk( CMU_VAR *cmu, int count )
- {
- char str[256];
- sprintf(str, "conf:mod:perr:epsk:cont scal,%d", count );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_overview_config_control_mode_8psk(CMU_VAR *cmu, int count)
- {
- char str[256];
- // sprintf(str, "conf:mod:over:epsk:cont scal,%d", count);
- sprintf(str, "CONF:MOD:EPSK:CONT SCAL,%d", count);
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_config_control_repetition( CMU_VAR *cmu, int count )
- {
- #if 0
- char str[256];
- sprintf( str, "conf:mod:cont:rep sing,none,none" );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- #endif
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_config_control_repetition_8psk( CMU_VAR *cmu, int count )
- {
- #if 0
- char str[256];
- sprintf( str, "conf:mod:epsk:cont:rep sing,none,none" );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- #endif
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_config_control_subarray( CMU_VAR *cmu, int sample )
- {
- char str[256];
- sprintf( str, "conf:sub:mod:perr:gsmk:arit, 0, %d", sample );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_read(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "read:mod?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<10;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- // *mod = atof(value[7].c_str());
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_read_8psk(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int i_num;
- AnsiString as;
- strcpy(cmd, "read:mod:epsk?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1] = NULL;
- temp = (AnsiString) buf;
- if (temp.Pos("NAN"))
- {
- return false;
- }
- for (i=0; i<EPSK_MOD_PH_ERR_END; i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- i_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(i_num+1, temp.Length());
- temp=temp_total;
- }
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_overview_read_8psk(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp;
- AnsiString temp_total;
- AnsiString temp_value;
- AnsiString value[EPSK_MOD_OVERVIEW_END];
- int i_num;
-
- strcpy(cmd, "read:mod:epsk?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(int i=0;i<18;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- i_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(i_num+1, temp.Length());
- temp=temp_total;
- }
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_overview_fetch_8psk(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp;
- AnsiString temp_total;
- AnsiString temp_value;
- AnsiString value[EPSK_MOD_OVERVIEW_END];
- int i_num;
- // init
- strcpy(cmd, "INIT:MOD:EPSK");
- if ((cmu->BAND).AnsiCompareIC("GSM")==0)
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS")==0)
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS")==0)
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850")==0)
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- // fetch
- strcpy(cmd, "FETC:MOD:EPSK?");
- if ((cmu->BAND).AnsiCompareIC("GSM")==0)
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS")==0)
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS")==0)
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850")==0)
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(int i=0;i<18;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- i_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(i_num+1, temp.Length());
- temp=temp_total;
- }
- *mod = atof(value[category].c_str());
- #if 0
- // abort
- strcpy(cmd, "ABORT:MOD:EPSK");
- if ((cmu->BAND).AnsiCompareIC("GSM")==0)
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS")==0)
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS")==0)
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850")==0)
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- }
- #endif
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_Fetch_EPSK_Average_TxIq(CMU_VAR *cmu, ViReal64 *p_virSBS, ViReal64 *p_virOOS)
- {
- AnsiString temp;
- AnsiString temp_total;
- AnsiString temp_value;
- AnsiString value[EPSK_MOD_PH_ERR_END];
- int i_num;
- // init
- strcpy(cmd, "INIT:MOD:EPSK");
- if ((cmu->BAND).AnsiCompareIC("GSM") == 0)
- {
- status = viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS") == 0)
- {
- status = viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS")==0)
- {
- status = viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850") == 0)
- {
- status = viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- // fetch
- strcpy(cmd, "FETC:MOD:EPSK?");
- if ((cmu->BAND).AnsiCompareIC("GSM") == 0)
- {
- status = viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- status = viRead(cmu->gsm, buf, BUF, &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS") == 0)
- {
- status = viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- status = viRead(cmu->dcs, buf, BUF, &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS") == 0)
- {
- status = viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- status = viRead(cmu->pcs, buf, BUF, &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850") == 0)
- {
- status = viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- status = viRead(cmu->gsm850, buf, BUF, &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if (temp.Pos("NAN"))
- {
- return false;
- }
- for (int i=0;i<EPSK_MOD_PH_ERR_END; i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- i_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(i_num+1, temp.Length());
- temp=temp_total;
- }
- *p_virSBS = atof(value[EPSK_MOD_IQ_IMBALANCE_AVERAGE].c_str());
- *p_virOOS = atof(value[EPSK_MOD_ORIGINAL_OFFSET_AVERAGE].c_str());
- #if 0
- // abort
- strcpy(cmd, "ABORT:MOD:EPSK");
- if ((cmu->BAND).AnsiCompareIC("GSM") == 0)
- {
- status = viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("DCS") == 0)
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("PCS") == 0)
- {
- status = viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- else if ((cmu->BAND).AnsiCompareIC("GSM850") == 0)
- {
- status = viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- }
- #endif
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_fetch(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "fetch:mod?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<10;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_fetch_8psk(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "read:mod:epsk?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for (i=0; i<EPSK_MOD_PH_ERR_END; i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_sample(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "sample:mod?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<10;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- // *mod = atof(value[7].c_str());
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_sample_8psk(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "read:mod:epsk?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<EPSK_MOD_PH_ERR_END;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- *mod = atof(value[category].c_str());
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_mod_abort( CMU_VAR *cmu )
- {
- strcpy(cmd, "abort:mod");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_mod_abort_8psk( CMU_VAR *cmu )
- {
- strcpy(cmd, "abort:mod:epsk");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_mod_stop( CMU_VAR *cmu )
- {
- strcpy(cmd, "stop:mod");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_mod_stop_8psk( CMU_VAR *cmu )
- {
- strcpy(cmd, "stop:mod:epsk");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //==============================================================================
- bool cmu_close(CMU_VAR *cmu, AnsiString asFreqBand)
- {
- if (cmu->BAND.AnsiCompareIC("GSM") == 0)
- {
- if (NULL != cmu->gsm)
- {
- strcpy(cmd, "ABOR:RFG");
- viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- }
- }
- else if (cmu->BAND.AnsiCompareIC("DCS") == 0)
- {
- if (NULL != cmu->dcs)
- {
- strcpy(cmd, "ABOR:RFG");
- viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- }
- }
- else if (cmu->BAND.AnsiCompareIC("PCS") == 0)
- {
- if (NULL != cmu->pcs)
- {
- strcpy(cmd, "ABOR:RFG");
- viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- }
- }
- else if (cmu->BAND.AnsiCompareIC("GSM850") == 0)
- {
- if (NULL != cmu->gsm850)
- {
- strcpy(cmd, "ABOR:RFG");
- viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- }
- if (IsCmuBandSupported(asFreqBand, CMU_GSM850_BAND))
- {
- if (NULL != cmu->gsm850)
- {
- status = viClose(cmu->gsm850);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->gsm850 = NULL;
- }
- }
- if (IsCmuBandSupported( asFreqBand, CMU_PCS1900_BAND))
- {
- if (NULL != cmu->pcs)
- {
- status = viClose(cmu->pcs);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->pcs = NULL;
- }
- }
- if (IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND))
- {
- if (NULL != cmu->dcs)
- {
- status = viClose(cmu->dcs);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->dcs = NULL;
- }
- }
- if (IsCmuBandSupported(asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported(asFreqBand, CMU_EGSM_BAND))
- {
- if (NULL != cmu->gsm)
- {
- status = viClose(cmu->gsm);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->gsm = NULL;
- }
- }
-
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_close_RM(CMU_VAR *cmu)
- {
- if (NULL != cmu->base)
- {
- status = viClose(cmu->base);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->base = NULL;
- }
- if (NULL != cmu->RM)
- {
- status = viClose(cmu->RM);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->RM = NULL;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_mod_tran(CMU_VAR *cmu, bool is_burst_mode)
- {
- if(is_burst_mode)
- {
- if( cmu->BAND.AnsiCompareIC("GSM")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN BURS"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- }
- else if( cmu->BAND.AnsiCompareIC("DCS")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN BURS"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- }
- else if( cmu->BAND.AnsiCompareIC("PCS")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN BURS"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- }
- else if( cmu->BAND.AnsiCompareIC("GSM850")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN BURS"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- }
- else
- {
- if( cmu->BAND.AnsiCompareIC("GSM")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- }
- else if( cmu->BAND.AnsiCompareIC("DCS")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- }
- else if( cmu->BAND.AnsiCompareIC("PCS")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- }
- else if( cmu->BAND.AnsiCompareIC("GSM850")==0 )
- {
- strcpy(cmd, "CONF:RFG:MOD:TRAN CONT"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:BIT:SEL PRBS"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "CONF:RFG:MOD:TSEQ:SEL GSM5"); viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- }
- }
- return true;
- }
- //==============================================================================
- //////////////////////// CMU external phase error /////////////////////////
- //==============================================================================
- bool cmu_mod_xper_init( CMU_VAR *cmu )
- {
- strcpy(cmd, "init:mod:xper");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_config_control_mode( CMU_VAR *cmu, int count )
- {
- char str[256];
- sprintf( str, "conf:mod:xper:cont scal,%d", count);
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_config_control_repetition( CMU_VAR *cmu, int count )
- {
- #if 0
- char str[256];
- sprintf( str, "conf:mod:xper:gsmk:cont rep,%d,son", count );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- #endif
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_config_control_subarray( CMU_VAR *cmu, int sample )
- {
- char str[256];
- sprintf(str, "conf:sub:mod:xper:gsmk:arit, 0, %d", sample);
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_read(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "read:mod:xper?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<=17;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- // *mod = atof(value[7].c_str());
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_read_txiq(CMU_VAR *cmu, double *d_IQ_Imbalance, double *d_Original_Offset)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "read:mod:xper?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<=17;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- *d_IQ_Imbalance = atof(value[XPER_IQ_IMBALANCE_AVERAGE].c_str());
- *d_Original_Offset = atof(value[XPER_ORIGINAL_OFFSET_AVERAGE].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_fetch(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "fetch:mod:xper?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<=17;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- // *mod = atof(value[7].c_str());
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_sample(CMU_VAR *cmu, int category, double *mod)
- {
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "sample:mod:xper?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<=17;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- // *mod = atof(value[7].c_str());
- *mod = atof(value[category].c_str());
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_mod_xper_abort( CMU_VAR *cmu )
- {
- strcpy(cmd, "abort:mod:xper");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //==============================================================================
- //////////////////////// CMU multislot /////////////////////////
- //==============================================================================
- //-----------------------------------------------------------------------------
- bool cmu_config_multislot_txpower_control_mode( CMU_VAR *cmu, int count )
- {
- char str[256];
- sprintf(str, "CONFigure:POWer:MSLot:CONTrol SCALar, %d", count );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_multislot_txpower_repetition_single_shot( CMU_VAR *cmu )
- {
- char str[256];
- sprintf(str, "CONFigure:POWer:MSLot:CONTrol:REPetition sing,none,none");
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_multi_slot_count( CMU_VAR *cmu, int timeslot_count )
- {
- char str[256];
- AnsiString as_cmd = "CONFigure:POWer:MSLot:SCOunt " + IntToStr( timeslot_count );
- sprintf( str, as_cmd.c_str() );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_trigger_slot_offset( CMU_VAR *cmu, E_TIMESLOT timeslot )
- {
- char str[256];
- AnsiString as_cmd = "CONFigure:RFANalyzer:MCONTrol:TSOFfset " + IntToStr( (int) timeslot );
- sprintf( str, as_cmd.c_str() );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_config_multislot_modulation( CMU_VAR *cmu, E_MODULATION_TYPE modulation )
- {
- AnsiString as_cmd;
- char str[256];
- if( MOD_GMSK == modulation )
- {
- AnsiString as_cmd = "CONFigure:POWer:MSLot:MVIew GMSK,GMSK,GMSK,GMSK";
- }
- else
- {
- AnsiString as_cmd = "CONFigure:POWer:MSLot:MVIew EPSK,EPSK,EPSK,EPSK";
- }
- sprintf( str, as_cmd.c_str() );
- strcpy(cmd, str);
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->gsm, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->dcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->pcs, cmd, strlen(cmd), &num);
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_read_multislot_average_txpower( CMU_VAR *cmu, S_MULTISLOT_BURST_POWER *power )
- {
- #if 0
- AnsiString temp,temp_total,temp_other,temp_value;
- AnsiString value1,value2,value3,value4,value5,value6,value7,value9;
- AnsiString value10,value11,value12,value13,value14;
- AnsiString value[14];
- int i=0;
- int as_num;
- AnsiString as;
- strcpy(cmd, "READ:ARRay:POWer:MSLot:AVERage?");
- if( (cmu->BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->gsm850, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- buf[num-1]=NULL;
- temp=(AnsiString)buf;
- if( temp.Pos("NAN") ) return false;
- for(i=0;i<=17;i++)
- {
- temp_value=temp.SubString(1, temp.Pos(",")-1);
- as_num= temp.AnsiPos(",");
- value[i]=temp_value;
- temp_total=temp.SubString(as_num+1, temp.Length());
- temp=temp_total;
- }
- // *mod = atof(value[7].c_str());
- *mod = atof(value[category].c_str());
- #endif
- return true;
- }
- //---------------------------------------------------------------------------