cmu200_sig.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:34k
- /*****************************************************************************
- * 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_sig.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * CMU 200 signalling 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!!
- *============================================================================
- ****************************************************************************/
- #pragma hdrstop
- #ifndef _META_FACTORY_CFG_H_
- #include "meta_factory_cfg.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_SIG_H_
- #include "cmu200_sig.h"
- #endif
- #pragma package(smart_init)
- //=============================================================================
- /////////////////////// General //////////////////////////////////
- //=============================================================================
- //---------------------------------------------------------------------------
- bool cmu_sig_init_RCT(CMU_VAR *cmu, AnsiString asFreqBand, bool bReset )
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- if (NULL == cmu->RM)
- {
- 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;
- if (bReset)
- {
- strcpy(cmd, "*rst"); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 13,"GSM900MS_Sig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND) )
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 15,"GSM1800MS_Sig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_PCS1900_BAND) )
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 17,"GSM1900MS_Sig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND) )
- {
- strcpy(cmd, "SYST:REM:ADDR:SEC 19,"GSM850MS_Sig""); viWrite(cmu->base, cmd, strlen(cmd), &num);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- status=viOpen(cmu->RM, (cmu->ADD+"::13::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).s_gsm);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->s_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+"::15::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).s_dcs);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->s_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+"::17::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).s_pcs);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->s_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+"::19::INSTR").c_str(), VI_NULL, cmu->TMO, &(*cmu).s_gsm850);
- if( status<VI_SUCCESS ) return false;
- status=viSetAttribute(cmu->s_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->s_pcs, cmd, strlen(cmd), &num);
- // Sleep(2500);
- }
- // strcpy(cmd, "PROCedure:SIGNalling:ACTion SON"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- }
- //
- if ( IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND) )
- {
- if( bReset )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- // Sleep(2500);
- }
- // strcpy(cmd, "PROCedure:SIGNalling:ACTion SON"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- }
- //
- if ( IsCmuBandSupported( asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported( asFreqBand, CMU_EGSM_BAND) )
- {
- if( bReset )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- //Sleep(2500);
- }
- // strcpy(cmd, "PROCedure:SIGNalling:ACTion SON"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- }
- //gsm nonsignaling setup--------------------------------------------------------
- //Sleep(500);
- if ( IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND) )
- {
- if( bReset )
- {
- strcpy(cmd, "*rst"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- // Sleep(2500);
- }
- // strcpy(cmd, "PROCedure:SIGNalling:ACTion SON"); viWrite(cmu->s_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->s_gsm, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_gsm_i); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_gsm_o); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:BSSignal:CCH:MODE BATC"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:NETWork:SMODe:SCHannel NONE"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- sprintf(cmd, "TRIG:SOUR IFP"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND) )
- {
- strcpy(cmd, "INP:STAT RF2"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_dcs_i); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_dcs_o); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:BSSignal:CCH:MODE BATC"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:NETWork:SMODe:SCHannel NONE"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "TRIG:SOUR IFP"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- }
- if ( IsCmuBandSupported( asFreqBand, CMU_PCS1900_BAND) )
- {
- strcpy(cmd, "INP:STAT RF2"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_pcs_i); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_pcs_o); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:BSSignal:CCH:MODE BATC"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:NETWork:SMODe:SCHannel NONE"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- sprintf(cmd, "TRIG:SOUR IFP"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- }
- // gsm850
- //gsm850 nonsignaling setup--------------------------------------------------------
- if ( IsCmuBandSupported( asFreqBand, CMU_GSM850_BAND) )
- {
- strcpy(cmd, "INP:STAT RF2"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- strcpy(cmd, "OUTP:STAT RF2"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:INP2 %f", cmu->loss_gsm850_i); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- sprintf(cmd, "SENS:CORR:LOSS:OUTP2 %f", cmu->loss_gsm850_o); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:BSSignal:CCH:MODE BATC"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- sprintf(cmd, "CONFigure:NETWork:SMODe:SCHannel NONE"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- sprintf(cmd, "TRIG:SOUR IFP"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- }
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_close(CMU_VAR *cmu, AnsiString asFreqBand)
- {
- int status;
- unsigned long num;
- char cmd[BUF];
-
- // if (cmu->BAND.AnsiCompareIC("GSM") == 0)
- // {
- // if (NULL != cmu->s_gsm)
- // {
- // strcpy(cmd, "ABOR:RFG");
- // viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- // }
- //}
- //else if (cmu->BAND.AnsiCompareIC("DCS") == 0)
- // {
- // if (NULL != cmu->s_dcs)
- // {
- // strcpy(cmd, "ABOR:RFG");
- // viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- // }
- // }
- // else if (cmu->BAND.AnsiCompareIC("PCS") == 0)
- // {
- // if (NULL != cmu->s_pcs)
- // {
- // strcpy(cmd, "ABOR:RFG");
- // viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- // }
- // }
- // else if (cmu->BAND.AnsiCompareIC("GSM850") == 0)
- // {
- // if (NULL != cmu->s_gsm850)
- // {
- // strcpy(cmd, "ABOR:RFG");
- // viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- // }
- // }
- if (IsCmuBandSupported(asFreqBand, CMU_GSM850_BAND))
- {
- if (NULL != cmu->s_gsm850)
- {
- status = viClose(cmu->s_gsm850);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->s_gsm850 = NULL;
- }
- }
- if (IsCmuBandSupported(asFreqBand, CMU_PCS1900_BAND))
- {
- if (NULL != cmu->s_pcs)
- {
- status = viClose(cmu->s_pcs);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->s_pcs = NULL;
- }
- }
- if (IsCmuBandSupported( asFreqBand, CMU_DCS1800_BAND))
- {
- if (NULL != cmu->s_dcs)
- {
- status = viClose(cmu->s_dcs);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->s_dcs = NULL;
- }
- }
- if (IsCmuBandSupported(asFreqBand, CMU_PGSM_BAND) || IsCmuBandSupported(asFreqBand, CMU_EGSM_BAND))
- {
- if (NULL != cmu->s_gsm)
- {
- status = viClose(cmu->s_gsm);
- if (status < VI_SUCCESS)
- {
- return false;
- }
- cmu->s_gsm = NULL;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool cmu_sig_onoff(CMU_VAR *cmu, bool on)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- if( on )
- { sprintf(cmd, "PROCedure:SIGNalling:ACTion SON");
- }
- else
- { sprintf(cmd, "PROCedure:SIGNalling:ACTion SOFF");
- }
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) { status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_net_support( CMU_VAR *cmu, int net_support )
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- switch( net_support )
- {
- case NET_SUPPORT_GSM_ONLY:
- sprintf(cmd, "CONFigure:NETWork:NSUPport GSM");
- break;
- case NET_SUPPORT_GSM_GPRS:
- sprintf(cmd, "CONFigure:NETWork:NSUPport GGPR");
- break;
- case NET_SUPPORT_GSM_EGPRS:
- sprintf(cmd, "CONFigure:NETWork:NSUPport GEGP");
- break;
- }
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) { status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_cellband(CMU_VAR *cmu, int band)
- {
- char cmd[BUF], buf[BUF];
- unsigned long num;
- // abort current active RFG
- if( cmu->s_BAND.AnsiCompareIC("GSM") == 0 ) { strcpy(cmd, "PROCedure:SIGNalling:ACTion SOFF"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); }
- else if( cmu->s_BAND.AnsiCompareIC("DCS") == 0 ) { strcpy(cmd, "PROCedure:SIGNalling:ACTion SOFF"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); }
- else if( cmu->s_BAND.AnsiCompareIC("PCS") == 0 ) { strcpy(cmd, "PROCedure:SIGNalling:ACTion SOFF"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); }
- else if( cmu->s_BAND.AnsiCompareIC("GSM850") == 0 ) { strcpy(cmd, "PROCedure:SIGNalling:ACTion SOFF"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); }
- if( band==0 ) return false;
- else if( band==CMU_PGSM_BAND || band==CMU_EGSM_BAND ) cmu->s_BAND="GSM";
- else if( band==CMU_DCS1800_BAND ) cmu->s_BAND="DCS";
- else if( band==CMU_PCS1900_BAND ) cmu->s_BAND="PCS";
- else if( band==CMU_GSM850_BAND ) cmu->s_BAND="GSM850";
- else
- { return false;}
- if( band==CMU_PGSM_BAND || band==CMU_EGSM_BAND )
- {
- strcpy(cmd, "PROCedure:SIGNalling:ACTion SON;*opc?"); viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- viRead(cmu->s_gsm, buf, BUF, &num);
- Sleep(500);
- }
- else if( band==CMU_DCS1800_BAND )
- {
- strcpy(cmd, "PROCedure:SIGNalling:ACTion SON;*opc?"); viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- viRead(cmu->s_dcs, buf, BUF, &num);
- Sleep(500);
- }
- else if( band==CMU_PCS1900_BAND )
- {
- strcpy(cmd, "PROCedure:SIGNalling:ACTion SON;*opc?"); viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- viRead(cmu->s_pcs, buf, BUF, &num);
- Sleep(500);
- }
- else if( band==CMU_GSM850_BAND )
- {
- strcpy(cmd, "PROCedure:SIGNalling:ACTion SON;*opc?"); viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- viRead(cmu->s_gsm850, buf, BUF, &num);
- Sleep(500);
- }
- else
- {
- return false;
- }
- // Sleep(500);
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_sig_bcharfcn(CMU_VAR *cmu, short chan)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- sprintf(cmd, "CONFigure:BSSignal:CCH:CHANnel %d;*opc?", chan);
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); viRead(cmu->s_gsm, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); viRead(cmu->s_dcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); viRead(cmu->s_pcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) { status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); viRead(cmu->s_gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_sig_cellpower(CMU_VAR *cmu, double power)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- if( power>=0 ) power=-60;
- sprintf(cmd, "CONFigure:BSSignal:CCH:LEVel:ABSolute %f;*opc?", power);
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); viRead(cmu->s_gsm, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); viRead(cmu->s_dcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); viRead(cmu->s_pcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ){ status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); viRead(cmu->s_gsm850, buf, BUF, &num); }
- else { return false; }
- Sleep(100);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_tcharfcn(CMU_VAR *cmu, short chan)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- sprintf(cmd, "CONFigure:BSSignal:CHANnel %d;*opc?", chan);
- if( (cmu->s_BAND).AnsiCompareIC("GSM") == 0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); viRead(cmu->s_gsm, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS") == 0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); viRead(cmu->s_dcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS") == 0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); viRead(cmu->s_pcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850") == 0 ) { status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); viRead(cmu->s_gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_tchtimeslot(CMU_VAR *cmu, int timeslot)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- sprintf(cmd, "CONFigure:BSSignal:TIMeslot %d;*opc?", timeslot);
- if( (cmu->s_BAND).AnsiCompareIC("GSM") == 0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); viRead(cmu->s_gsm, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS") == 0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); viRead(cmu->s_dcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS") == 0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); viRead(cmu->s_pcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850") == 0 ) { status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); viRead(cmu->s_gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_tchlevel(CMU_VAR *cmu, double level)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- sprintf(cmd, "CONFigure:BSSignal:LEVel:UTIMeslot %f;*opc?", level);
- if( (cmu->s_BAND).AnsiCompareIC("GSM") == 0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); viRead(cmu->s_gsm, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS") == 0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); viRead(cmu->s_dcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS") == 0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); viRead(cmu->s_pcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850") == 0 ) { status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); viRead(cmu->s_gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_mstxlevel(CMU_VAR *cmu, int lev)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- sprintf(cmd, "CONFigure:MSSignal:MS:PCL %d;*opc?", lev);
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); viRead(cmu->s_gsm, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); viRead(cmu->s_dcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); viRead(cmu->s_pcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ){ status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); viRead(cmu->s_gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //------------------------------------------------------------------------------
- bool cmu_sig_tsc(CMU_VAR *cmu, int tsc)
- {
- #if 0
- sprintf(cmd, "rfan:tseq GSM%d", tsc);
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- #endif
- return true;
- }
- //=============================================================================
- /////////////////////// Analyzer level //////////////////////////////////
- //=============================================================================
- //=============================================================================
- /////////////////////// Modulation //////////////////////////////////
- //=============================================================================
- bool cmu_sig_mod_init( CMU_VAR *cmu )
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- strcpy(cmd, "init:mod");
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_sig_mod_config_control_mode( CMU_VAR *cmu, int count )
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- char str[256];
- sprintf(str, "conf:mod:perr:cont scal,%d;*opc?", count );
- strcpy(cmd, str);
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) { status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); viRead(cmu->s_gsm, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) { status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); viRead(cmu->s_dcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) { status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); viRead(cmu->s_pcs, buf, BUF, &num); }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) { status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); viRead(cmu->s_gsm850, buf, BUF, &num); }
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //-----------------------------------------------------------------------------
- bool cmu_sig_mod_read(CMU_VAR *cmu, int category, double *mod)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- 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->s_BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_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_sig_mod_fetch(CMU_VAR *cmu, int category, double *mod)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- 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->s_BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_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_sig_mod_sample(CMU_VAR *cmu, int category, double *mod)
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- 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->s_BAND).AnsiCompareIC("GSM")==0 )
- {
- status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_gsm, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 )
- {
- status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_dcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 )
- {
- status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_pcs, buf, BUF, &num); if( status<VI_SUCCESS ) return false;
- }
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 )
- {
- status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num); if( status<VI_SUCCESS ) return false;
- status=viRead(cmu->s_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_sig_mod_abort( CMU_VAR *cmu )
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- strcpy(cmd, "abort:mod");
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }
- //---------------------------------------------------------------------------
- bool cmu_sig_mod_stop( CMU_VAR *cmu )
- {
- int status;
- unsigned long num;
- char cmd[BUF], buf[BUF];
- strcpy(cmd, "stop:mod");
- if( (cmu->s_BAND).AnsiCompareIC("GSM")==0 ) status=viWrite(cmu->s_gsm, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("DCS")==0 ) status=viWrite(cmu->s_dcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("PCS")==0 ) status=viWrite(cmu->s_pcs, cmd, strlen(cmd), &num);
- else if( (cmu->s_BAND).AnsiCompareIC("GSM850")==0 ) status=viWrite(cmu->s_gsm850, cmd, strlen(cmd), &num);
- if( status<VI_SUCCESS ) return false;
- return true;
- }