RCT_ctrl.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:53k
源码类别:

MTK

开发平台:

C++ Builder

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *   RCT_ctrl.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  Radio Communication Tester control function source
  48.  *
  49.  * Author:
  50.  * -------
  51.  *  Andy Ueng (mtk00490)
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * $Revision$
  58.  * $Modtime$
  59.  * $Log$
  60.  *
  61.  *------------------------------------------------------------------------------
  62.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  63.  *============================================================================
  64.  ****************************************************************************/
  65. #include <vcl.h>
  66. #ifndef age1960_INCLUDE
  67. #include "age1960.h"
  68. #endif
  69. #pragma hdrstop
  70. #ifndef  _RCT_CTRL_H_
  71. #include "rct_ctrl.h"
  72. #endif
  73. #ifndef  _RCT_COMMON_H_
  74. #include "rct_common.h"
  75. #endif
  76. // equipment
  77. #ifndef _AGECOMMON_H_
  78. #include "agecommon.h"
  79. #endif
  80. #ifndef _AGE1960_UTILS_H_
  81. #include "age1960_utils.h"
  82. #endif
  83. #ifndef _AGE1968A_H_
  84. #include "age1968a.h"
  85. #endif
  86. #ifndef  _CMU200_SIG_H_
  87. #include "cmu200_sig.h"
  88. #endif
  89. //===========================================================================
  90. //===========================================================================
  91. CRCTCTRL::CRCTCTRL( void )
  92. {
  93. }
  94. //---------------------------------------------------------------------------
  95. CRCTCTRL::~CRCTCTRL()
  96. {
  97. }
  98. //=============================================================================
  99. bool CRCTCTRL::RCT_Init(S_RCT *p_rct, AnsiString asFreqBand)
  100. {
  101.     //-----------------------------------------------------------------------
  102.     //  Agilent
  103.     if(p_rct->device_type == AGILENT_8960)
  104.     {
  105.         ViStatus vistat;
  106.         if ((vistat = age1960_init( p_rct->age.ADD.c_str(), 0, 0, &(p_rct->age.vi))) != VI_SUCCESS)
  107.         {
  108.             return false;
  109.         }
  110.         //////////////////////////////////////////////////////////////////////////////
  111.         if ( (vistat = age_QueryTaModel( p_rct->age.vi, &(p_rct->age.as_TaModel) )) != VI_SUCCESS)
  112.         {
  113.             return false;
  114.         }
  115.         //////////////////////////////////////////////////////////////////////////////
  116.         Sleep(50);
  117.         if ( p_rct->age.vi != VI_NULL)
  118.         {
  119.             if ( age1960_dcl(p_rct->age.vi)!= VI_SUCCESS)
  120.             {
  121.                 return false;
  122.             }
  123.         }
  124.         //////////////////////////////////////////////////////////////////////////////
  125.         Sleep(50);
  126.         if ( p_rct->age.vi != VI_NULL)
  127.         {
  128.             vistat = age1960_reset(p_rct->age.vi);
  129.             if (vistat != VI_SUCCESS)
  130.             {
  131.                 return false;
  132.             }
  133.         }
  134.         /////////////////////////////////////////////////////////////////////////////
  135.         vistat = age1960_timeOut(p_rct->age.vi, p_rct->age.TMO);
  136.         if (vistat != VI_SUCCESS)
  137.         {
  138.             return false;
  139.         }
  140.         /////////////////////////////////////////////////////////////////////////////
  141.         const AMP_OFFSET_ITEMS = 10;
  142.         ViReal64  freqArray[AMP_OFFSET_ITEMS] = { 400000000.0,
  143.                                                   641000000.0,
  144.                                                   641100000.0,
  145.                                                   876000000.0,
  146.                                                   876100000.0,
  147.                                                   1312000000.0,
  148.                                                   1312100000.0,
  149.                                                   1880000000.0,
  150.                                                   1881000000.0,
  151.                                                   2000000000.0 };
  152.         ViReal64  offsetArray[AMP_OFFSET_ITEMS] = { p_rct->age.d400,
  153.                                                     p_rct->age.d400,
  154.                                                     p_rct->age.d850,
  155.                                                     p_rct->age.d850,
  156.                                                     p_rct->age.d900,
  157.                                                     p_rct->age.d900,
  158.                                                     p_rct->age.d1800,
  159.                                                     p_rct->age.d1800,
  160.                                                     p_rct->age.d1900,
  161.                                                     p_rct->age.d1900
  162.                                                   };
  163.         if ((vistat = age1960_amplitudeOffset (
  164.                                                 p_rct->age.vi,
  165.                                                 freqArray,
  166.                                                 offsetArray,
  167.                                                 AMP_OFFSET_ITEMS
  168.                                               )) != VI_SUCCESS)
  169.         {
  170.             return false;
  171.         }
  172.     }
  173.     else if(p_rct->device_type == CMU_200)
  174.     {
  175.        //--------------To Do CMU200 Functions------------------
  176.        //************************************************************
  177.        #if 0
  178.        cmu.loss_gsm850_i = rct.cmu.dIn850;
  179.        cmu.loss_gsm850_o = rct.cmu.dOut850;
  180.        cmu.loss_gsm_i    = rct.cmu.dIn900;
  181.        cmu.loss_gsm_o    = rct.cmu.dOut900;
  182.        cmu.loss_dcs_i    = rct.cmu.dIn1800;
  183.        cmu.loss_dcs_o    = rct.cmu.dOut1800;
  184.        cmu.loss_pcs_i    = rct.cmu.dIn1900;
  185.        cmu.loss_pcs_o    = rct.cmu.dOut1900;
  186.        cmu.ADD  = p_rct->as_GPIBAddr.SubString(0, p_rct->as_GPIBAddr.Pos("::INSTR")-1);
  187.        cmu.TMO  = p_rct->i_TimeOut;
  188.        #endif
  189.        p_rct->cmu.BAND = "GSM";
  190.        if( !cmu_init_RCT( &(p_rct->cmu), asFreqBand, p_rct->bReset ) )
  191.        {
  192.            // Application->MessageBox( "Initial CMU200 fail", "Fail", MB_OK );
  193.             return false;
  194.        }
  195.        Sleep(1500);
  196.     }
  197.     /////////////////////////////////////////////////////////////////////////////
  198.     return true;
  199. }
  200. //--------------------------------------------------------------------------
  201. bool CRCTCTRL::RCT_dcl( S_RCT *p_rct )
  202. {
  203.     if(p_rct->device_type == AGILENT_8960)
  204.     {
  205.         if ( age1960_dcl( p_rct->age.vi )!= VI_SUCCESS)
  206.         {
  207.             return false;
  208.         }
  209.     }
  210.     return true;
  211. }
  212. //--------------------------------------------------------------------------
  213. bool CRCTCTRL::RCT_reset( S_RCT *p_rct )
  214. {
  215.     if(p_rct->device_type == AGILENT_8960)
  216.     {
  217.         if ((age1960_reset( p_rct->age.vi )) != VI_SUCCESS)
  218.         {
  219.             return false;
  220.         }
  221.     }
  222.     return true;
  223. }
  224. //--------------------------------------------------------------------------
  225. bool CRCTCTRL::RCT_close(S_RCT *p_rct, AnsiString asFreqBand)
  226. {
  227.     if (AGILENT_8960 == p_rct->device_type)
  228.     {
  229.         if (age1960_close(p_rct->age.vi)!= VI_SUCCESS)
  230.         {
  231.            return false;
  232.         }
  233.         p_rct->age.vi = NULL;
  234.     }
  235.     else
  236.     {
  237.         if(!cmu_close(&p_rct->cmu, asFreqBand))
  238.         {
  239.             return false;
  240.         }
  241.     }
  242.     return true;
  243. }
  244. //--------------------------------------------------------------------------
  245. bool CRCTCTRL::RCT_close_RM(S_RCT *p_rct)
  246. {
  247.     if (AGILENT_8960 == p_rct->device_type)
  248.     {
  249.     }
  250.     else
  251.     {
  252.         if (!cmu_close_RM(&(p_rct->cmu)))
  253.         {
  254.             return false;
  255.         }
  256.     }
  257.     return true;
  258. }
  259. //--------------------------------------------------------------------------
  260. bool CRCTCTRL::RCT_QueryTaModel(S_RCT *p_rct, AnsiString &asTaModel)
  261. {
  262.     if(p_rct->device_type == AGILENT_8960)
  263.     {
  264.      if ( age_QueryTaModel( p_rct->age.vi, &asTaModel ) != VI_SUCCESS )
  265.         {
  266.             return false;
  267.         }
  268.     }
  269.     else
  270.     {
  271.     }
  272.     return true;
  273. }
  274. //--------------------------------------------------------------------------
  275. bool CRCTCTRL::RCT_operatingMode( S_RCT *p_rct, ViInt16 OperatingMode )
  276. {
  277.     if(p_rct->device_type == AGILENT_8960)
  278.     {
  279.         if( p_rct->age.as_TaModel.AnsiCompareIC( "E1960A" ) == 0)
  280.         {
  281.              if ((age1960A_operatingMode(
  282.                                                  p_rct->age.vi,
  283.                                                  OperatingMode
  284.                                                ))!= VI_SUCCESS)
  285.             {
  286.                 return false;
  287.             }
  288.         }
  289.         else
  290.         {
  291.             if (( age1968A_operatingMode(p_rct->age.vi, (E_AGE_OPERATING_MODE)OperatingMode))!= VI_SUCCESS)
  292.             {
  293.                 return false;
  294.             }
  295.         }
  296.     }
  297.     return true;
  298. }
  299.     
  300. //--------------------------------------------------------------------------
  301. bool CRCTCTRL::RCT_cellBand(S_RCT *p_rct, int i_BAND)
  302. {
  303.     if(p_rct->device_type == AGILENT_8960)
  304.     {
  305.         if ( age1960_cellBand(
  306.                                p_rct->age.vi,
  307.                                age1960_CELL_1,
  308.                                i_BAND
  309.                              ) != VI_SUCCESS )
  310.         {
  311.             return false;
  312.         }
  313.     }
  314.     else if(p_rct->device_type == CMU_200)
  315.     {
  316.         if( !cmu_cellband(i_BAND, &(p_rct->cmu)) )
  317.         {
  318.             return false;
  319.         }
  320.     }
  321.     return true;
  322. }
  323. //--------------------------------------------------------------------------
  324. bool CRCTCTRL::RCT_BurstModTran( S_RCT *p_rct )
  325. {
  326.     if(p_rct->device_type == AGILENT_8960)
  327.     {
  328.     }
  329.     else if(p_rct->device_type == CMU_200)
  330.     {
  331.         if( !cmu_mod_tran(&(p_rct->cmu), true) )
  332.         {
  333.             return false;
  334.         }
  335.     }
  336.     return true;
  337. }
  338. //--------------------------------------------------------------------------
  339. bool CRCTCTRL::RCT_ContModTran( S_RCT *p_rct )
  340. {
  341.     if(p_rct->device_type == AGILENT_8960)
  342.     {
  343.     }
  344.     else if(p_rct->device_type == CMU_200)
  345.     {
  346.         if( !cmu_mod_tran(&(p_rct->cmu), false) )
  347.         {
  348.             return false;
  349.         }
  350.     }
  351.     return true;
  352. }
  353. //--------------------------------------------------------------------------
  354. bool CRCTCTRL::RCT_BCHARFCN(S_RCT *p_rct, short s_ARFCN)
  355. {
  356.     if (AGILENT_8960 == p_rct->device_type)
  357.     {
  358.         if (age1960_BCHARFCN(p_rct->age.vi,
  359.                              age1960_CELL_1,
  360.                              s_ARFCN,
  361.                              age1960_CURRENT_BAND,
  362.                              VI_TRUE
  363.                              ) != VI_SUCCESS)
  364.         {
  365.             return false;
  366.         }
  367.     }
  368.     else 
  369.     {
  370.         if (!cmu_bcharfcn(s_ARFCN, &(p_rct->cmu)))
  371.         {
  372.             return false;
  373.         }
  374.     }
  375.     return true;
  376. }
  377. //--------------------------------------------------------------------------
  378. bool CRCTCTRL::RCT_GenFreq_CW(S_RCT *p_rct, FrequencyBand FreqBand, short arfcn)
  379. {
  380.     if (AGILENT_8960 == p_rct->device_type)
  381.     {
  382.         if (age1968A_GenFreq_CW(p_rct->age.vi, FreqBand, arfcn) != VI_SUCCESS)
  383.         {
  384.         }
  385.     }
  386.     else
  387.     {
  388.     }
  389.     return true;
  390. }
  391. //--------------------------------------------------------------------------
  392. bool CRCTCTRL::RCT_cellPower_CW(S_RCT *p_rct, double d_P_DL)
  393. {
  394.     if (AGILENT_8960 == p_rct->device_type)
  395.     {
  396.         if (age1968A_cellPower_CW(p_rct->age.vi, d_P_DL) != VI_SUCCESS)
  397.         {
  398.             return false;
  399.         }
  400.     }
  401.     else if(p_rct->device_type == CMU_200)
  402.     {
  403.         if (!cmu_cellpower(d_P_DL, &(p_rct->cmu)))
  404.         {
  405.             return false;
  406.         }
  407.     }
  408.     return true;
  409. }
  410. //--------------------------------------------------------------------------
  411. bool CRCTCTRL::RCT_cellPower(S_RCT *p_rct, double d_P_DL)
  412. {
  413.     if (AGILENT_8960 == p_rct->device_type)
  414.     {
  415.         if (age1960_cellPower(p_rct->age.vi, age1960_CELL_1, d_P_DL, 0) != VI_SUCCESS)
  416.         {
  417.             return false;
  418.         }
  419.     }
  420.     else if(p_rct->device_type == CMU_200)
  421.     {
  422.         if( !cmu_cellpower( d_P_DL, &(p_rct->cmu) ) )
  423.         {
  424.             return false;
  425.         }
  426.     }
  427.     return true;
  428. }
  429. //--------------------------------------------------------------------------
  430. bool CRCTCTRL::RCT_PowTranCont(S_RCT *p_rct)
  431. {
  432.     if(p_rct->device_type == AGILENT_8960)
  433.     {
  434.     }
  435.     else if(p_rct->device_type == CMU_200)
  436.     {
  437.         if( !cmu_pow_cont(true, &(p_rct->cmu)) )
  438.         {
  439.             return false;
  440.         }
  441.     }
  442.     return true;
  443. }
  444. //--------------------------------------------------------------------------
  445. bool CRCTCTRL::RCT_PowTranBurst(S_RCT *p_rct)
  446. {
  447.     if(p_rct->device_type == AGILENT_8960)
  448.     {
  449.     }
  450.     else if(p_rct->device_type == CMU_200)
  451.     {
  452.         if( !cmu_pow_cont(false, &(p_rct->cmu)) )
  453.         {
  454.             return false;
  455.         }
  456.     }
  457.     return true;
  458. }
  459. //-------------------------------------------------------------------------
  460. bool CRCTCTRL::RCT_GenFreqOffset(S_RCT *p_rct, double d_kHz)
  461. {
  462.     if (AGILENT_8960 == p_rct->device_type)
  463.     {
  464.     }
  465.     else
  466.     {
  467.         if (!cmu_gen_freq_offset(&(p_rct->cmu), d_kHz))
  468.         {
  469.             return false;
  470.         }
  471.     }
  472.     return true;
  473. }
  474. //-------------------------------------------------------------------------
  475. bool CRCTCTRL::RCT_GenTsc(S_RCT *p_rct, E_CMU200_GEN_TSC_TYPE_T tsc)
  476. {
  477.     if (AGILENT_8960 == p_rct->device_type)
  478.     {
  479.     }
  480.     else
  481.     {
  482.         if (!cmu_gen_tsc(tsc, &(p_rct->cmu)))
  483.         {
  484.             return false;
  485.         }
  486.     }
  487.     return true;
  488. }
  489. //-------------------------------------------------------------------------
  490. bool CRCTCTRL::RCT_GenBitMod(S_RCT *p_rct, E_CMU200_GEN_BIT_MODU_T bit_mod)
  491. {
  492.     if (AGILENT_8960 == p_rct->device_type)
  493.     {
  494.     }
  495.     else
  496.     {
  497.         if (!cmu_gen_bit_mod(bit_mod, &(p_rct->cmu)))
  498.         {
  499.             return false;
  500.         }
  501.     }
  502.     return true;
  503. }
  504. //-------------------------------------------------------------------------
  505. bool CRCTCTRL::RCT_InitRfg(S_RCT *p_rct)
  506. {
  507.     if(p_rct->device_type == AGILENT_8960)
  508.     {
  509.     }
  510.     else
  511.     {
  512.        if( ! cmu_init_rfg( &(p_rct->cmu) ) )
  513.        {
  514.             return false;
  515.        }
  516.     }
  517.     return true;
  518. }
  519. //--------------------------------------------------------------------------
  520. bool CRCTCTRL::RCT_TCHARFCN(S_RCT *p_rct, short s_ARFCN)
  521. {
  522.     if(p_rct->device_type == AGILENT_8960)
  523.     {
  524.         if ( age1960_TCHARFCN(
  525.                                p_rct->age.vi,
  526.                                s_ARFCN,
  527.                                (short) 0, // current band
  528.                                VI_TRUE
  529.                              )!= VI_SUCCESS)
  530.         {
  531.             return false;
  532.         }
  533.     }
  534.     else
  535.     {
  536.         if (!cmu_tcharfcn(s_ARFCN, &(p_rct->cmu)))
  537.         {
  538.             return false;
  539.         }
  540.     }
  541.     return true;
  542. }
  543. //--------------------------------------------------------------------------
  544. bool CRCTCTRL::RCT_PDTCHARFCN(S_RCT *p_rct, short s_ARFCN)
  545. {
  546.     if(p_rct->device_type == AGILENT_8960)
  547.     {
  548.         if (age1968A_PDTCHARFCN(p_rct->age.vi, s_ARFCN) != VI_SUCCESS)
  549.         {
  550.             return false;
  551.         }
  552.     }
  553.     else
  554.     {
  555.         if (!cmu_pdtcharfcn(s_ARFCN, &(p_rct->cmu)))
  556.         {
  557.             return false;
  558.         }
  559.     }
  560.     return true;
  561. }
  562. //-------------------------------------------------------------------------
  563. bool CRCTCTRL::RCT_TCHTimeslot(S_RCT *p_rct, int TCHTimeslot)
  564. {
  565.     if(p_rct->device_type == AGILENT_8960)
  566.     {
  567.         if( age1960_TCHTimeslot(p_rct->age.vi, TCHTimeslot, VI_TRUE) != VI_SUCCESS )
  568.         {
  569.             return false;
  570.         }
  571.     }
  572.     else
  573.     {
  574.         
  575.     }
  576.     return true;
  577. }
  578. //-------------------------------------------------------------------------
  579. bool CRCTCTRL::RCT_initMeasFcn_TXPOWER(S_RCT *p_rct)
  580. {
  581.     if(p_rct->device_type == AGILENT_8960)
  582.     {
  583.         if ( age1960_initMeasFcn(p_rct->age.vi, age1960_TXPOWER) != VI_SUCCESS )
  584.         {
  585.             return false;
  586.         }
  587.         else // CMU 200
  588.         {
  589.         }
  590.     }
  591.     return true;
  592. }
  593. //-------------------------------------------------------------------------
  594. bool CRCTCTRL::RCT_initMeasFcn_EGPRS_TXPOWER(S_RCT *p_rct)
  595. {
  596.     if(p_rct->device_type == AGILENT_8960)
  597.     {
  598.         if ( age1968A_initMeasFcn_EGPRS_TXPOWER(p_rct->age.vi) != VI_SUCCESS )
  599.         {
  600.             return false;
  601.         }
  602.         else // CMU 200
  603.         {
  604.         }
  605.     }
  606.     return true;
  607. }
  608. //-------------------------------------------------------------------------
  609. bool CRCTCTRL::RCT_MSTXLevel(S_RCT *p_rct, int i_pcl)
  610. {
  611.     if(p_rct->device_type == AGILENT_8960)
  612.     {
  613.         if ( age1960_MSTXLevel(
  614.                                      p_rct->age.vi,
  615.                                      i_pcl,
  616.                                     (short) 0,  // current band
  617.                                     VI_TRUE
  618.                                    )!= VI_SUCCESS)
  619.         {
  620.             return false;
  621.         }
  622.     }
  623.     else
  624.     {
  625.         if( !cmu_mxtxlevel( i_pcl, &(p_rct->cmu) ) )
  626.         {
  627.             return false;
  628.         }
  629.     }
  630.     return true;
  631. }
  632. //-------------------------------------------------------------------------
  633. bool CRCTCTRL::RCT_PDTCHMSTargetPower(S_RCT *p_rct, double dBm)
  634. {
  635.     if (AGILENT_8960 == p_rct->device_type)
  636.     {
  637.         if (age1968A_PDTCHMSTargetPower(p_rct->age.vi, dBm) != VI_SUCCESS)
  638.         {
  639.             return false;
  640.         }
  641.     }
  642.     else
  643.     {
  644.     }
  645.     return true;
  646. }
  647.     
  648. //-------------------------------------------------------------------------
  649. bool CRCTCTRL::RCT_PDTCHMSTxLevel(S_RCT *p_rct, int i_pcl)
  650. {
  651.     if (p_rct->device_type == AGILENT_8960)
  652.     {
  653.         if (age1968A_PDTCHMSTxLevel(p_rct->age.vi, i_pcl) != VI_SUCCESS)
  654.         {
  655.             return false;
  656.         }
  657.     }
  658.     else
  659.     {
  660.         if( !cmu_mxtxlevel( i_pcl, &(p_rct->cmu) ) )
  661.         {
  662.             return false;
  663.         }
  664.     }
  665.     return true;
  666. }
  667. //-------------------------------------------------------------------------
  668. bool CRCTCTRL::RCT_Config_ExpectedTxPower(S_RCT *p_rct, bool b_auto_control, double d_expected_power)
  669. {
  670.     if (AGILENT_8960 == p_rct->device_type)
  671.     {
  672.         if (age1968A_Config_ExpectedTxPower(p_rct->age.vi,
  673.                                             b_auto_control,
  674.                                             d_expected_power) != VI_SUCCESS
  675.            )
  676.         {
  677.             return false;
  678.         }
  679.     }
  680.     return true;
  681. }
  682. //-------------------------------------------------------------------------
  683. bool CRCTCTRL::RCT_confTXPower(S_RCT *p_rct)
  684. {
  685.     if(p_rct->device_type == AGILENT_8960)
  686.     {
  687.         if(age1960_confTXPower( p_rct->age.vi,
  688.                                 AGE1960_TX_POWER_MEASURE_COUNT,
  689.                                 age1960_TRIG_AUTO,
  690.                                 AGE1960_TX_POWER_TRIGGER_DELAY,
  691.                                 AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON,
  692.                                 AGE1960_READ_TX_POWER_TIMEOUT) != VI_SUCCESS
  693.                                )
  694.         {
  695.             return false;
  696.         }
  697.     }
  698.     else
  699.     {
  700.         if( ! cmu_config_txpwr_control_mode( &(p_rct->cmu), AGE1960_TX_POWER_MEASURE_COUNT ) )
  701.         {
  702.             return false;
  703.         }    
  704.     }
  705.     return true;
  706. }
  707. //-------------------------------------------------------------------------
  708. bool CRCTCTRL::RCT_confTXPower_EPSK(S_RCT *p_rct)
  709. {
  710.     if(p_rct->device_type == AGILENT_8960)
  711.     {
  712.         if( age1968A_Config_EPSK_TxPower(p_rct->age.vi,
  713.                                 AGE1960_EPSK_TX_POWER_MEASURE_COUNT,
  714.                                 age1960_TRIG_AUTO,
  715.                                 AGE1960_TX_POWER_TRIGGER_DELAY,
  716.                                 AGE1960_TX_POWER_TRIGGER_QUALIFIER_ON,
  717.                                 AGE1960_READ_TX_POWER_TIMEOUT) != VI_SUCCESS
  718.                                )
  719.         {
  720.             return false;
  721.         }
  722.     }
  723.     else
  724.     {
  725.         if( ! cmu_config_txpwr_control_mode_epsk( &(p_rct->cmu), AGE1960_TX_POWER_MEASURE_COUNT ) )
  726.         {
  727.             return false;
  728.         }    
  729.     }
  730.     return true;
  731. }
  732. //-------------------------------------------------------------------------
  733. bool CRCTCTRL::RCT_Config_EPSK_CodingScheme(S_RCT *p_rct, int i_MCS)
  734. {
  735.     if( p_rct->device_type == AGILENT_8960 )
  736.     {
  737.        if( age1968A_Config_EPSK_CodingScheme(p_rct->age.vi, i_MCS) != VI_SUCCESS )
  738.        {
  739.            return false;
  740.        }
  741.     }
  742.     return true;
  743. }
  744. //-------------------------------------------------------------------------
  745. bool CRCTCTRL::RCT_ConfigTSC(S_RCT *p_rct, char c_TSC)
  746. {
  747.     if( p_rct->device_type == AGILENT_8960 )
  748.     {
  749.        if( age1968A_ConfigTSC(p_rct->age.vi, c_TSC) != VI_SUCCESS )
  750.        {
  751.            return false;
  752.        }
  753.    }
  754.    else
  755.    {
  756.         if( !cmu_tsc( c_TSC, &(p_rct->cmu) ) )
  757.         {
  758.             return false;
  759.         }
  760.     }
  761.     return true;
  762. }
  763. //-------------------------------------------------------------------------
  764. bool CRCTCTRL::RCT_TXPowerContOn( S_RCT *p_rct )
  765. {
  766.     if(p_rct->device_type == AGILENT_8960)
  767.     {
  768.        if( age1968A_TXPowerContOn( p_rct->age.vi ) != VI_SUCCESS )
  769.        {
  770.            return false;
  771.        }
  772.     }
  773.     else
  774.     {
  775.        // if( !cmu_pow_cont( true, &(p_rct->cmu) ) )
  776.         if( ! cmu_config_txpwr_repetition_continuous( &(p_rct->cmu) )  )
  777.         {
  778.             return false;
  779.         }
  780.     }
  781.     return true;
  782. }
  783. //-------------------------------------------------------------------------
  784. bool CRCTCTRL::RCT_TXPowerContOff( S_RCT *p_rct )
  785. {
  786.     if( p_rct->device_type == AGILENT_8960 )
  787.     {
  788.         if( age1968A_TXPowerContOff( p_rct->age.vi ) != VI_SUCCESS )
  789.         {
  790.             return false;
  791.         }
  792.     }
  793.     else
  794.     {
  795.        // if( !cmu_pow_cont( false, &(p_rct->cmu) ) )
  796.         if( ! cmu_config_txpwr_repetition_single_shot( &(p_rct->cmu) )  )
  797.         {
  798.             return false;
  799.         }
  800.     }
  801.     return true;
  802. }
  803. //-------------------------------------------------------------------------
  804. bool CRCTCTRL::RCT_EPSK_TXPowerContOn( S_RCT *p_rct )
  805. {
  806.     if(p_rct->device_type == AGILENT_8960)
  807.     {
  808.       //  char chTXPowerON[100];
  809.       //  sprintf(chTXPowerON, "%s", "SET:TXPower:CONT ON ");
  810.       //  if ( age1960_cmd(
  811.       //                        p_rct->age.vi,
  812.       //                        chTXPowerON
  813.       //                      )!= VI_SUCCESS)
  814.       //  {
  815.       //      return false;
  816.       //  }
  817.         if( age1968A_EPSK_TXPowerContOn( p_rct->age.vi ) != VI_SUCCESS )
  818.         {
  819.             return false;
  820.         }
  821.     }
  822.     else
  823.     {
  824.         if( ! cmu_config_txpwr_repetition_continuous_epsk( &(p_rct->cmu) )  )
  825.         {
  826.             return false;
  827.         }
  828.     }
  829.     return true;
  830. }
  831. //-------------------------------------------------------------------------
  832. bool CRCTCTRL::RCT_EPSK_TXPowerContOff( S_RCT *p_rct )
  833. {
  834.     if( p_rct->device_type == AGILENT_8960 )
  835.     {
  836.        // char chTXPowerOFF[100];
  837.        // sprintf(chTXPowerOFF, "%s", "SET:TXPower:CONT OFF ");
  838.        // if ( age1960_cmd(p_rct->age.vi, chTXPowerOFF)!= VI_SUCCESS)
  839.        // {
  840.        //     return false;
  841.        // }
  842.         if( age1968A_EPSK_TXPowerContOff( p_rct->age.vi ) != VI_SUCCESS )
  843.         {
  844.             return false;
  845.         }
  846.     }
  847.     else
  848.     {
  849.        // if( !cmu_pow_cont( false, &(p_rct->cmu) ) )
  850.         if( ! cmu_config_txpwr_repetition_single_shot_epsk( &(p_rct->cmu) )  )
  851.         {
  852.             return false;
  853.         }
  854.     }
  855.     return true;
  856. }
  857. //-------------------------------------------------------------------------
  858. bool CRCTCTRL::RCT_ReadTxPower( S_RCT *p_rct, ViReal64 &virTX )
  859. {
  860.     ViInt32  viPowerInteg;
  861.     if( p_rct->device_type == AGILENT_8960 )
  862.     {
  863.         if( p_rct->age.as_TaModel.AnsiCompareIC( "E1960A" ) == 0 )
  864.         {
  865.             if ( age1960_readTXPower_Q(
  866.                                          p_rct->age.vi,
  867.                                          VI_TRUE,
  868.                                          &viPowerInteg,
  869.                                          &virTX
  870.                                       )!= VI_SUCCESS)
  871.             {
  872.                 return false;
  873.             }
  874.         }
  875.         else // GSM
  876.         {
  877.             if( age1968A_ReadTxPower(p_rct->age.vi, &virTX) != VI_SUCCESS )
  878.             {
  879.                 return false;
  880.             }
  881.         }
  882.     }
  883.     else
  884.     {
  885.         viPowerInteg=0;
  886.         if( !cmu_readtxpower( &virTX, &(p_rct->cmu) ) )
  887.         {
  888.             return false;
  889.         }
  890.     }
  891.     return true;
  892. }
  893. //-------------------------------------------------------------------------
  894. bool CRCTCTRL::RCT_ReadTxPower_EPSK( S_RCT *p_rct, ViReal64 &virTX )
  895. {
  896.     if( p_rct->device_type == AGILENT_8960 )
  897.     {
  898.             if( age1968A_ReadEGPRSTxPower(p_rct->age.vi, &virTX) != VI_SUCCESS )
  899.             {
  900.                 return false;
  901.             }
  902.     }
  903.     else
  904.     {
  905.         //viPowerInteg=0;
  906.         if( !cmu_readtxpower_8psk( &virTX, &(p_rct->cmu) ) )
  907.         {
  908.             return false;
  909.         }
  910.     }
  911.     return true;
  912. }
  913. //==========================================================================
  914. // phase error
  915. bool CRCTCTRL::RCT_confPFER(S_RCT *p_rct, int measure_count )
  916. {
  917.     if( p_rct->device_type == AGILENT_8960 )
  918.     {
  919.         if (age1968A_confPFER(p_rct->age.vi,
  920.                              measure_count,
  921.                              age1960_TRIG_AUTO,
  922.                              AGE1960_PFER_TRIGGER_DELAY,
  923.                              AGE1960_PFER_TRIGGER_QUALIFIER_ON,
  924.                              AGE1960_READ_PFER_TIMEOUT)!= VI_SUCCESS)
  925.         {
  926.             return false;
  927.         }
  928.     }
  929.     else
  930.     {
  931.         if( ! cmu_mod_config_control_mode( &(p_rct->cmu), measure_count ) )
  932.         {
  933.             return false;
  934.         }
  935.         if( ! cmu_mod_config_control_repetition( &(p_rct->cmu), measure_count )  )
  936.         {
  937.             return false;
  938.         }
  939.     }
  940.     return true;
  941. }
  942. //--------------------------------------------------------------------------
  943. //bool CRCTCTRL::RCT_initMeasFcn_PFER( S_RCT *p_rct )
  944. //{
  945. //    if( p_rct->device_type == AGILENT_8960 )
  946. //    {
  947. //        if ( age1960_initMeasFcn(p_rct->age.vi, age1960_PFER) != VI_SUCCESS )
  948. //        {
  949. //            return false;
  950. //        }
  951. //        else // CMU 200
  952. //        {
  953. //
  954. //        }
  955. //    }
  956. //    return true;
  957. //}
  958. //---------------------------------------------------------------------------
  959. bool CRCTCTRL::RCT_FetchAvgFreqErr( S_RCT *p_rct, ViReal64  &AvgFreqErr )
  960. {
  961.     ViInt32   PFERIntegrity;
  962.     ViReal64  PFERRMSError;
  963.     ViReal64  PFERPeakError;
  964.     ViReal64  PFERFreqError;
  965.     
  966.     if (AGILENT_8960 == p_rct->device_type)
  967.     {
  968.         if( age_FetchAvgFreqError(p_rct->age.vi, &PFERFreqError) != VI_SUCCESS )
  969.         {
  970.             return false;
  971.         }
  972.     }
  973.     else
  974.     {
  975.         if( ! cmu_mod_init( &(p_rct->cmu) ) )
  976.         {
  977.             return false;
  978.         }
  979.         if( ! cmu_mod_sample(&(p_rct->cmu), FREQ_ERR_AVERAGE, &PFERFreqError) )
  980.         {
  981.             return false;
  982.         }
  983.         if( ! cmu_mod_abort( &(p_rct->cmu) )  )
  984.         {
  985.             return false;
  986.         }
  987.     }
  988.     AvgFreqErr = PFERFreqError;
  989.     return true;
  990. }
  991. //---------------------------------------------------------------------------
  992. bool CRCTCTRL::RCT_FetchAvgPhErr( S_RCT *p_rct, ViReal64  &AvgPhErr )
  993. {
  994.     ViInt32   PFERIntegrity;
  995.     ViReal64  PFERRMSError;
  996.     ViReal64  PFERPeakError;
  997.     ViReal64  PFERFreqError;
  998.     if( p_rct->device_type == AGILENT_8960 )
  999.     {
  1000.         if ( age1960_fetchPFER_Q(
  1001.                                       p_rct->age.vi,
  1002.                                       &PFERIntegrity,
  1003.                                       &PFERRMSError,
  1004.                                       &PFERPeakError,
  1005.                                       &PFERFreqError
  1006.                                      )!= VI_SUCCESS)
  1007.         {
  1008.             return false;
  1009.         }
  1010.     }
  1011.     else
  1012.     {
  1013.         if( ! cmu_mod_init( &(p_rct->cmu ) ) )
  1014.         {
  1015.             return false;
  1016.         }
  1017.         if( ! cmu_mod_sample(&(p_rct->cmu), PH_ERR_RMS_AVERAGE, &PFERRMSError) )
  1018.        // if( !cmu_readmod(PH_ERR_RMS_AVERAGE, &cmu, &PFERFreqError) )
  1019.         {
  1020.             return false;
  1021.         }
  1022.         if( ! cmu_mod_abort( &(p_rct->cmu) ) )
  1023.         {
  1024.             return false;
  1025.         }
  1026.     }
  1027.     AvgPhErr = PFERRMSError;
  1028.     return true;
  1029. }
  1030. //---------------------------------------------------------------------------
  1031. bool CRCTCTRL::RCT_ReadAvgFreqErr( S_RCT *p_rct, ViReal64  &AvgFreqErr )
  1032. {
  1033.     ViInt32   PFERIntegrity;
  1034.     ViReal64  PFERRMSError;
  1035.     ViReal64  PFERPeakError;
  1036.     ViReal64  PFERFreqError;
  1037.     if(AGILENT_8960 == p_rct->device_type)
  1038.     {
  1039.         if( age_ReadAvgFreqError(p_rct->age.vi, &PFERFreqError) != VI_SUCCESS )
  1040.         {
  1041.             return false;
  1042.         }
  1043.     }
  1044.     else
  1045.     {
  1046.         if( ! cmu_mod_read(&(p_rct->cmu), FREQ_ERR_AVERAGE, &PFERFreqError) )
  1047.         {
  1048.             return false;
  1049.         }
  1050.     }
  1051.     AvgFreqErr = PFERFreqError;
  1052.     return true;
  1053. }
  1054. //---------------------------------------------------------------------------
  1055. bool CRCTCTRL::RCT_ReadAvgPhErr( S_RCT *p_rct, ViReal64  &AvgPhErr )
  1056. {
  1057.     ViInt32   PFERIntegrity;
  1058.     ViReal64  PFERRMSError;
  1059.     ViReal64  PFERPeakError;
  1060.     ViReal64  PFERFreqError;
  1061.     if( AGILENT_8960 == p_rct->device_type )
  1062.     {
  1063.         if ( age1960_readPFER_Q(
  1064.                                       p_rct->age.vi,
  1065.                                       &PFERIntegrity,
  1066.                                       &PFERRMSError,
  1067.                                       &PFERPeakError,
  1068.                                       &PFERFreqError
  1069.                                      )!= VI_SUCCESS)
  1070.         {
  1071.             return false;
  1072.         }
  1073.     }
  1074.     else
  1075.     {
  1076.         if( ! cmu_mod_read(&(p_rct->cmu), PH_ERR_RMS_AVERAGE, &PFERRMSError) )
  1077.         {
  1078.             return false;
  1079.         }
  1080.     }
  1081.     AvgPhErr = PFERRMSError;
  1082.     return true;
  1083. }
  1084. //===========================================================================
  1085. /////////////////////////       IQ tunning      /////////////////////////////
  1086. //===========================================================================
  1087. bool CRCTCTRL::RCT_initMeasFcn_IQTuning( S_RCT *p_rct )
  1088. {
  1089.     if( p_rct->device_type == AGILENT_8960 )
  1090.     {
  1091.         if ( age1960_initMeasFcn(p_rct->age.vi, age1960_IQTUNING) != VI_SUCCESS )
  1092.         {
  1093.             return false;
  1094.         }
  1095.         else // CMU 200
  1096.         {
  1097.         }
  1098.     }
  1099.     return true;
  1100. }
  1101. //---------------------------------------------------------------------------
  1102. bool CRCTCTRL::RCT_confIQTuning( S_RCT *p_rct, int measure_count )
  1103. {
  1104.     if( p_rct->device_type == AGILENT_8960 )
  1105.     {
  1106.         if( age1960_confIQTuning(p_rct->age.vi,
  1107.                                           measure_count,
  1108.                                           age1960_TRIG_RF_RISE,
  1109.                                           AGE1960_IQ_TUNNING_TRIGGER_DELAY,
  1110.                                           age1960_IQ_REF_AUTO,
  1111.                                           AGE1960_IQ_TUNNING_TRIGGER_QUALIFIER_OFF,
  1112.                                           AGE1960_IQ_TUNNING_SPUR_FREQ,
  1113.                                           AGE1960_READ_IQ_TUNNING_TIMEOUT) != VI_SUCCESS )
  1114.         {
  1115.             return false;
  1116.         }
  1117.     }
  1118.     else
  1119.     {
  1120.         if( ! cmu_mod_xper_config_control_mode( &(p_rct->cmu), measure_count ) )
  1121.         {
  1122.             return false;
  1123.         }
  1124.         if( ! cmu_mod_xper_config_control_repetition( &(p_rct->cmu), measure_count ) )
  1125.         {
  1126.             return false;
  1127.         }
  1128.     }
  1129.     return true;
  1130. }
  1131. //----------------------------------------------------------------------------
  1132. bool CRCTCTRL::RCT_readTxOriginalOffset( S_RCT *p_rct, double &d_Original_Offset )
  1133. {
  1134.     if( AGILENT_8960 == p_rct->device_type )
  1135.     {
  1136.         ViInt32   IQTIntegrity;
  1137.         ViReal64  IQTSpurFreq;
  1138.         ViReal64  IQTSpurLevel;
  1139.         ViReal64  IQTResultsArray[age1960_IQ_ARRAY_MIN];
  1140.         ViReal64  IQTFreqsArray[age1960_IQ_ARRAY_MIN];
  1141.         ViInt32   IQTTuningCount;
  1142.         if( age1960_readIQTuning_Q(  p_rct->age.vi,
  1143.                                        age1960_IQ_ARRAY_MIN,
  1144.                                        &IQTIntegrity,
  1145.                                        &IQTSpurFreq,
  1146.                                        &IQTSpurLevel,
  1147.                                        IQTResultsArray,
  1148.                                        IQTFreqsArray,
  1149.                                        &IQTTuningCount) != VI_SUCCESS )
  1150.         {
  1151.             return false;
  1152.         }
  1153.         d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1154.         if( NAN == d_Original_Offset )
  1155.         {
  1156.             return false;
  1157.         }
  1158.     }
  1159.     else
  1160.     {
  1161.         if( ! cmu_mod_xper_read( &(p_rct->cmu), XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
  1162.         {
  1163.             return false;
  1164.         }
  1165.     }
  1166.     return true;
  1167. }
  1168. //----------------------------------------------------------------------------
  1169. bool CRCTCTRL::RCT_fetchTxOriginalOffset( S_RCT *p_rct, double &d_Original_Offset )
  1170. {
  1171.     if( AGILENT_8960 == p_rct->device_type )
  1172.     {
  1173.         ViInt32   IQTIntegrity;
  1174.         ViReal64  IQTSpurFreq;
  1175.         ViReal64  IQTSpurLevel;
  1176.         ViReal64  IQTResultsArray[age1960_IQ_ARRAY_MIN];
  1177.         ViReal64  IQTFreqsArray[age1960_IQ_ARRAY_MIN];
  1178.         ViInt32   IQTTuningCount;
  1179.         if( age1960_fetchIQTuning_Q (  p_rct->age.vi,
  1180.                                        age1960_IQ_ARRAY_MIN,
  1181.                                        &IQTIntegrity,
  1182.                                        &IQTSpurFreq,
  1183.                                        &IQTSpurLevel,
  1184.                                        IQTResultsArray,
  1185.                                        IQTFreqsArray,
  1186.                                        &IQTTuningCount) != VI_SUCCESS )
  1187.         {
  1188.             return false;
  1189.         }
  1190.         d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1191.         if( NAN == d_Original_Offset )
  1192.         {
  1193.             return false;
  1194.         }
  1195.     }
  1196.     else
  1197.     {
  1198.         if( ! cmu_mod_xper_init( &(p_rct->cmu) ) )
  1199.         {
  1200.             return false;
  1201.         }
  1202.         if( ! cmu_mod_xper_sample( &(p_rct->cmu), XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
  1203.         {
  1204.             return false;
  1205.         }
  1206.         if( ! cmu_mod_xper_abort( &(p_rct->cmu) ) )
  1207.         {
  1208.             return false;
  1209.         }
  1210.     }
  1211.     return true;
  1212. }
  1213. //---------------------------------------------------------------------------
  1214. bool CRCTCTRL::RCT_fetchTxIqImbalance( S_RCT *p_rct, double &d_IQ_Imbalance )
  1215. {
  1216.     if( AGILENT_8960 == p_rct->device_type )
  1217.     {
  1218.         ViInt32   IQTIntegrity;
  1219.         ViReal64  IQTSpurFreq;
  1220.         ViReal64  IQTSpurLevel;
  1221.         ViReal64  IQTResultsArray[age1960_IQ_ARRAY_MIN];
  1222.         ViReal64  IQTFreqsArray[age1960_IQ_ARRAY_MIN];
  1223.         ViInt32   IQTTuningCount;
  1224.         if( age1960_fetchIQTuning_Q (  p_rct->age.vi,
  1225.                                        age1960_IQ_ARRAY_MIN,
  1226.                                        &IQTIntegrity,
  1227.                                        &IQTSpurFreq,
  1228.                                        &IQTSpurLevel,
  1229.                                        IQTResultsArray,
  1230.                                        IQTFreqsArray,
  1231.                                        &IQTTuningCount
  1232.                                        ) != VI_SUCCESS )
  1233.         {
  1234.             return false;
  1235.         }
  1236.         d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1237.         if( NAN == d_IQ_Imbalance )
  1238.         {
  1239.             return false;
  1240.         }
  1241.     }
  1242.     else
  1243.     {
  1244.         if( ! cmu_mod_xper_init( &(p_rct->cmu) ) )
  1245.         {
  1246.             return false;
  1247.         }
  1248.         if( ! cmu_mod_xper_sample( &(p_rct->cmu), XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance) )
  1249.         {
  1250.             return false;
  1251.         }
  1252.         if( ! cmu_mod_xper_abort( &(p_rct->cmu) ) )
  1253.         {
  1254.             return false;
  1255.         }
  1256.     }
  1257.     return true;
  1258. }
  1259. //---------------------------------------------------------------------------
  1260. bool CRCTCTRL::RCT_readTxIqImbalance( S_RCT *p_rct, double &d_IQ_Imbalance )
  1261. {
  1262.     if( AGILENT_8960 == p_rct->device_type )
  1263.     {
  1264.         ViInt32   IQTIntegrity;
  1265.         ViReal64  IQTSpurFreq;
  1266.         ViReal64  IQTSpurLevel;
  1267.         ViReal64  IQTResultsArray[age1960_IQ_ARRAY_MIN];
  1268.         ViReal64  IQTFreqsArray[age1960_IQ_ARRAY_MIN];
  1269.         ViInt32   IQTTuningCount;
  1270.         if( age1960_readIQTuning_Q (  p_rct->age.vi,
  1271.                                        age1960_IQ_ARRAY_MIN,
  1272.                                        &IQTIntegrity,
  1273.                                        &IQTSpurFreq,
  1274.                                        &IQTSpurLevel,
  1275.                                        IQTResultsArray,
  1276.                                        IQTFreqsArray,
  1277.                                        &IQTTuningCount
  1278.                                        ) != VI_SUCCESS )
  1279.         {
  1280.             return false;
  1281.         }
  1282.         d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1283.         if( NAN == d_IQ_Imbalance )
  1284.         {
  1285.             return false;
  1286.         }
  1287.     }
  1288.     else
  1289.     {
  1290.         if( ! cmu_mod_xper_read( &(p_rct->cmu), XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance) )
  1291.         {
  1292.             return false;
  1293.         }
  1294.     }
  1295.     return true;
  1296. }
  1297. //---------------------------------------------------------------------------
  1298. bool CRCTCTRL::RCT_readTxIq(S_RCT *p_rct, double &d_IQ_Imbalance, double &d_Original_Offset)
  1299. {
  1300.     if (AGILENT_8960 == p_rct->device_type)
  1301.     {
  1302.         ViInt32   IQTIntegrity;
  1303.         ViReal64  IQTSpurFreq;
  1304.         ViReal64  IQTSpurLevel;
  1305.         ViReal64  IQTResultsArray[age1960_IQ_ARRAY_MIN];
  1306.         ViReal64  IQTFreqsArray[age1960_IQ_ARRAY_MIN];
  1307.         ViInt32   IQTTuningCount;
  1308.         if (age1960_readIQTuning_Q (p_rct->age.vi,
  1309.                                        age1960_IQ_ARRAY_MIN,
  1310.                                        &IQTIntegrity,
  1311.                                        &IQTSpurFreq,
  1312.                                        &IQTSpurLevel,
  1313.                                        IQTResultsArray,
  1314.                                        IQTFreqsArray,
  1315.                                        &IQTTuningCount
  1316.                                        ) != VI_SUCCESS )
  1317.         {
  1318.             return false;
  1319.         }
  1320.         d_IQ_Imbalance    = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1321.         d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1322.         if ((NAN == d_IQ_Imbalance) || (NAN == d_Original_Offset))
  1323.         {
  1324.             return false;
  1325.         }
  1326.     }
  1327.     else
  1328.     {
  1329.         if (! cmu_mod_xper_read_txiq( &(p_rct->cmu), &d_IQ_Imbalance, &d_Original_Offset))
  1330.         {
  1331.             return false;
  1332.         }
  1333.     }
  1334.     return true;
  1335. }
  1336. //===========================================================================
  1337. //////////////////////////           EPSK           /////////////////////////
  1338. //===========================================================================
  1339. bool CRCTCTRL::RCT_Config_EPSK_ModACcuracy(S_RCT *p_rct, int iMeasureCount, int iTriSour, int iDelay, int iTimeout)
  1340. {
  1341.     if( AGILENT_8960 == p_rct->device_type )
  1342.     {
  1343.         if( age1968A_Config_EPSK_ModACcuracy(p_rct->age.vi,
  1344.                                            iMeasureCount,
  1345.                                            iTriSour,
  1346.                                            iDelay,
  1347.                                            iTimeout) != VI_SUCCESS )
  1348.         {
  1349.             return false;
  1350.         }
  1351.     }
  1352.     else
  1353.     {
  1354.         if (!cmu_mod_overview_config_control_mode_8psk(&(p_rct->cmu), iMeasureCount))
  1355.         {
  1356.             return false;
  1357.         }    
  1358.     }
  1359.     return true;
  1360. }
  1361. //---------------------------------------------------------------------------
  1362. bool CRCTCTRL::RCT_Fetch_EPSK_Average_OrignalOffset( S_RCT *p_rct, ViReal64 *p_virOOS )
  1363. {
  1364.     if( AGILENT_8960 == p_rct->device_type )
  1365.     {
  1366.         if( age1968A_Fetch_EPSK_Average_OrignalOffset(p_rct->age.vi, p_virOOS ) != VI_SUCCESS )
  1367.         {
  1368.             return false;
  1369.         }
  1370.     }
  1371.     else
  1372.     {
  1373.         if (!cmu_mod_overview_fetch_8psk(&(p_rct->cmu), 8, p_virOOS))
  1374.         {
  1375.             return false;
  1376.         }
  1377.     }
  1378.     return true;
  1379. }
  1380. //---------------------------------------------------------------------------
  1381. bool CRCTCTRL::RCT_Fetch_EPSK_Average_IQImbalance( S_RCT *p_rct, ViReal64 *p_virSBS )
  1382. {
  1383.     if (AGILENT_8960 == p_rct->device_type)
  1384.     {
  1385.         if( age1968A_Fetch_EPSK_Average_IQImbalance( p_rct->age.vi, p_virSBS) != VI_SUCCESS )
  1386.         {
  1387.             return false;
  1388.         }
  1389.     }
  1390.     else
  1391.     {
  1392.         if (!cmu_mod_overview_read_8psk(&(p_rct->cmu), 16, p_virSBS))
  1393.         {
  1394.             return false;
  1395.         }
  1396.     }
  1397.     return true;
  1398. }
  1399. //---------------------------------------------------------------------------
  1400. bool CRCTCTRL::RCT_Fetch_EPSK_Average_TxIq(S_RCT *p_rct, ViReal64 *p_virSBS, ViReal64 *p_virOOS)
  1401. {
  1402.     if (AGILENT_8960 == p_rct->device_type)
  1403.     {
  1404.        // if( age1968A_Fetch_EPSK_Average_TxIq( p_rct->age.vi, p_virSBS, p_virOOS) != VI_SUCCESS )
  1405.        // {
  1406.        //     return false;
  1407.        // }
  1408.         if (age1968A_Fetch_EPSK_Average_OrignalOffset(p_rct->age.vi, p_virOOS) != VI_SUCCESS)
  1409.         {
  1410.             return false;
  1411.         }
  1412.         if (age1968A_Fetch_EPSK_Average_IQImbalance(p_rct->age.vi, p_virSBS) != VI_SUCCESS )
  1413.         {
  1414.             return false;
  1415.         }
  1416.     }
  1417.     else
  1418.     {
  1419.         if (!cmu_Fetch_EPSK_Average_TxIq(&(p_rct->cmu), p_virSBS, p_virOOS))
  1420.         {
  1421.             return false;
  1422.         }
  1423.     }
  1424.     return true;
  1425. }
  1426. //===========================================================================
  1427. /////////////////////////         Multislot TX power    /////////////////////
  1428. //===========================================================================
  1429. bool CRCTCTRL::RCT_confMultiSlotTxPower( S_RCT *p_rct, int measure_count, E_MODULATION_TYPE modulation )
  1430. {
  1431.     if( AGILENT_8960 == p_rct->device_type )
  1432.     {
  1433.     }
  1434.     else
  1435.     {
  1436.         if( ! cmu_config_multislot_txpower_control_mode( &(p_rct->cmu), measure_count ) )
  1437.             return false;
  1438.         if( ! cmu_config_multislot_txpower_repetition_single_shot( &(p_rct->cmu) )  )
  1439.             return false;
  1440.         if( ! cmu_config_multi_slot_count( &(p_rct->cmu), 4 ) )
  1441.             return false;
  1442.         if( ! cmu_config_trigger_slot_offset( &(p_rct->cmu), TIMESLOT_0 ) )
  1443.             return false;
  1444.         if( ! cmu_config_multislot_modulation( &(p_rct->cmu), modulation ) )
  1445.             return false;
  1446.     }
  1447.     return true;
  1448. }
  1449. //---------------------------------------------------------------------------
  1450. bool CRCTCTRL::RCT_readMultiSlotAverageTxPower( S_RCT *p_rct, S_MULTISLOT_BURST_POWER *power )
  1451. {
  1452.     if( AGILENT_8960 == p_rct->device_type )
  1453.     {
  1454.     }
  1455.     else
  1456.     {
  1457.         if( ! cmu_read_multislot_average_txpower( &(p_rct->cmu), power )  )
  1458.             return false;
  1459.     }
  1460.     return true;
  1461. }
  1462. //===========================================================================
  1463. /////////////////////////         Signalling       //////////////////////////
  1464. //===========================================================================
  1465. bool CRCTCTRL::RCT_sig_Init( S_RCT *p_rct, AnsiString asFreqBand )
  1466. {
  1467.     //-----------------------------------------------------------------------
  1468.     //  Agilent
  1469.     if(CMU_200 == p_rct->device_type)
  1470.     {
  1471.        p_rct->cmu.s_BAND = "GSM";
  1472.        if( ! cmu_sig_init_RCT( &(p_rct->cmu), asFreqBand, p_rct->bReset ) )
  1473.        {
  1474.            return false;
  1475.        }
  1476.        Sleep(3500);
  1477.     }
  1478.     /////////////////////////////////////////////////////////////////////////////
  1479.     return true;
  1480. }
  1481. //--------------------------------------------------------------------------
  1482. bool CRCTCTRL::RCT_sig_close(S_RCT *p_rct, AnsiString asFreqBand)
  1483. {
  1484.     if(p_rct->device_type == CMU_200)
  1485.     {
  1486.         if (!cmu_sig_close(&p_rct->cmu, asFreqBand))
  1487.         {
  1488.             return false;
  1489.         }
  1490.     }
  1491.     return true;
  1492. }
  1493.         
  1494. //--------------------------------------------------------------------------
  1495. bool CRCTCTRL::RCT_sig_cellBand(S_RCT *p_rct, int i_BAND)
  1496. {
  1497.     if(p_rct->device_type == CMU_200)
  1498.     {
  1499.         if( ! cmu_sig_cellband(&(p_rct->cmu), i_BAND) )
  1500.         {
  1501.             return false;
  1502.         }
  1503.     }
  1504.     return true;
  1505. }
  1506. //--------------------------------------------------------------------------
  1507. bool CRCTCTRL::RCT_sig_cellPower(S_RCT *p_rct, double d_P_DL)
  1508. {
  1509.     if(p_rct->device_type == CMU_200)
  1510.     {
  1511.         if( ! cmu_sig_cellpower(  &(p_rct->cmu), d_P_DL ) )
  1512.         {
  1513.             return false;
  1514.         }
  1515.     }
  1516.     return true;
  1517. }
  1518. //--------------------------------------------------------------------------
  1519. bool CRCTCTRL::RCT_sig_BCHARFCN(S_RCT *p_rct, short s_ARFCN)
  1520. {
  1521.     if (CMU_200 == p_rct->device_type)
  1522.     {
  1523.         if (!cmu_sig_bcharfcn(&(p_rct->cmu), s_ARFCN))
  1524.         {
  1525.             return false;
  1526.         }
  1527.     }
  1528.     return true;
  1529. }
  1530. //--------------------------------------------------------------------------
  1531. bool CRCTCTRL::RCT_sig_TCHARFCN(S_RCT *p_rct, short s_ARFCN)
  1532. {
  1533.     if (CMU_200 == p_rct->device_type)
  1534.     {
  1535.         if (!cmu_sig_tcharfcn(&(p_rct->cmu), s_ARFCN))
  1536.         {
  1537.             return false;
  1538.         }
  1539.     }
  1540.     return true;
  1541. }
  1542. //-------------------------------------------------------------------------
  1543. bool CRCTCTRL::RCT_sig_TCHTimeslot(S_RCT *p_rct, int TCHTimeslot)
  1544. {
  1545.     if( CMU_200 == p_rct->device_type )
  1546.     {
  1547.         if( ! cmu_sig_tchtimeslot( &(p_rct->cmu), TCHTimeslot ) )
  1548.         {
  1549.             return false;
  1550.         }
  1551.     }
  1552.     return true;
  1553. }
  1554. //-------------------------------------------------------------------------
  1555. bool CRCTCTRL::RCT_sig_TCHLevel(S_RCT *p_rct, double level)
  1556. {
  1557.     if( CMU_200 == p_rct->device_type )
  1558.     {
  1559.         if( ! cmu_sig_tchlevel( &(p_rct->cmu), level ) )
  1560.         {
  1561.             return false;
  1562.         }
  1563.     }
  1564.     return true;
  1565. }
  1566. //-------------------------------------------------------------------------
  1567. bool CRCTCTRL::RCT_sig_ConfigTSC(S_RCT *p_rct, char c_TSC)
  1568. {
  1569.     if( CMU_200 == p_rct->device_type )
  1570.     {
  1571.         if( !cmu_sig_tsc( &(p_rct->cmu), c_TSC ) )
  1572.         {
  1573.             return false;
  1574.         }
  1575.     }
  1576.     return true;
  1577. }
  1578. //-------------------------------------------------------------------------
  1579. bool CRCTCTRL::RCT_sig_MSTXLevel(S_RCT *p_rct, int i_pcl)
  1580. {
  1581.     if( CMU_200 == p_rct->device_type )
  1582.     {
  1583.         if( ! cmu_sig_mstxlevel( &(p_rct->cmu), i_pcl ) )
  1584.         {
  1585.             return false;
  1586.         }
  1587.     }
  1588.     return true;
  1589. }
  1590. //-------------------------------------------------------------------------
  1591. bool CRCTCTRL::RCT_sig_confPFER(S_RCT *p_rct, int measure_count )
  1592. {
  1593.     if( CMU_200 == p_rct->device_type )
  1594.     {
  1595.         if( ! cmu_sig_mod_config_control_mode( &(p_rct->cmu), measure_count ) )
  1596.         {
  1597.             return false;
  1598.         }
  1599. #if 0
  1600.         if( ! cmu_sig_mod_config_control_repetition( &(p_rct->cmu), measure_count )  )
  1601.         {
  1602.             return false;
  1603.         }
  1604. #endif        
  1605.     }
  1606.     return true;
  1607. }
  1608. //---------------------------------------------------------------------------
  1609. bool CRCTCTRL::RCT_sig_FetchAvgFreqErr( S_RCT *p_rct, ViReal64  &AvgFreqErr )
  1610. {
  1611.     ViInt32   PFERIntegrity;
  1612.     ViReal64  PFERRMSError;
  1613.     ViReal64  PFERPeakError;
  1614.     ViReal64  PFERFreqError;
  1615.     if(CMU_200 == p_rct->device_type )
  1616.     {
  1617.         if( ! cmu_sig_mod_init( &(p_rct->cmu) ) )
  1618.         {
  1619.             return false;
  1620.         }
  1621.         if( ! cmu_sig_mod_sample(&(p_rct->cmu), FREQ_ERR_AVERAGE, &PFERFreqError) )
  1622.         {
  1623.             return false;
  1624.         }
  1625.         if( ! cmu_sig_mod_abort( &(p_rct->cmu) )  )
  1626.         {
  1627.             return false;
  1628.         }
  1629.     }
  1630.     AvgFreqErr = PFERFreqError;
  1631.     return true;
  1632. }
  1633. //---------------------------------------------------------------------------
  1634. bool CRCTCTRL::RCT_sig_FetchAvgPhErr( S_RCT *p_rct, ViReal64  &AvgPhErr )
  1635. {
  1636.     ViInt32   PFERIntegrity;
  1637.     ViReal64  PFERRMSError;
  1638.     ViReal64  PFERPeakError;
  1639.     ViReal64  PFERFreqError;
  1640.     if(CMU_200 == p_rct->device_type )
  1641.     {
  1642.         if( ! cmu_sig_mod_init( &(p_rct->cmu ) ) )
  1643.         {
  1644.             return false;
  1645.         }
  1646.         if( ! cmu_sig_mod_sample(&(p_rct->cmu), PH_ERR_RMS_AVERAGE, &PFERRMSError) )
  1647.        // if( !cmu_readmod(PH_ERR_RMS_AVERAGE, &cmu, &PFERFreqError) )
  1648.         {
  1649.             return false;
  1650.         }
  1651.         if( ! cmu_sig_mod_abort( &(p_rct->cmu) ) )
  1652.         {
  1653.             return false;
  1654.         }
  1655.     }
  1656.     AvgPhErr = PFERRMSError;
  1657.     return true;
  1658. }
  1659. //---------------------------------------------------------------------------
  1660. bool CRCTCTRL::RCT_sig_ReadAvgFreqErr( S_RCT *p_rct, ViReal64  &AvgFreqErr )
  1661. {
  1662.     ViInt32   PFERIntegrity;
  1663.     ViReal64  PFERRMSError;
  1664.     ViReal64  PFERPeakError;
  1665.     ViReal64  PFERFreqError;
  1666.     if(CMU_200 == p_rct->device_type )
  1667.     {
  1668.         if( ! cmu_sig_mod_read(&(p_rct->cmu), FREQ_ERR_AVERAGE, &PFERFreqError) )
  1669.         {
  1670.             return false;
  1671.         }
  1672.     }
  1673.     AvgFreqErr = PFERFreqError;
  1674.     return true;
  1675. }
  1676. //---------------------------------------------------------------------------
  1677. bool CRCTCTRL::RCT_sig_ReadAvgPhErr( S_RCT *p_rct, ViReal64  &AvgPhErr )
  1678. {
  1679.     ViInt32   PFERIntegrity;
  1680.     ViReal64  PFERRMSError;
  1681.     ViReal64  PFERPeakError;
  1682.     ViReal64  PFERFreqError;
  1683.     if(CMU_200 == p_rct->device_type )
  1684.     {
  1685.         if( ! cmu_sig_mod_read(&(p_rct->cmu), PH_ERR_RMS_AVERAGE, &PFERRMSError) )
  1686.         {
  1687.             return false;
  1688.         }
  1689.     }
  1690.     AvgPhErr = PFERRMSError;
  1691.     return true;
  1692. }
  1693. //===========================================================================
  1694. /////////////////////////         string       //////////////////////////////
  1695. //===========================================================================
  1696. const AnsiString  AGILENT_8960_STR = "Agilent 8960";
  1697. const AnsiString  CMU_200_STR      = "CMU 200";
  1698. //---------------------------------------------------------------------------
  1699. int CRCTCTRL::RCT_StringToDeviceType( AnsiString as_str )
  1700. {
  1701.     int device_type;
  1702.     if( as_str.AnsiCompareIC(AGILENT_8960_STR) == 0 )
  1703.     {
  1704.         device_type = AGILENT_8960;
  1705.     }
  1706.     else
  1707.     {
  1708.         device_type = CMU_200;
  1709.     }
  1710.     return device_type;
  1711. }
  1712. //---------------------------------------------------------------------------
  1713. AnsiString CRCTCTRL::RCT_DeviceTypeToString( E_DEVICE_TYPE device_type )
  1714. {
  1715.     AnsiString as_str;
  1716.     switch( device_type )
  1717.     {
  1718.         case AGILENT_8960:
  1719.             as_str = AGILENT_8960_STR;
  1720.         break;
  1721.         case CMU_200:
  1722.             as_str = CMU_200_STR;
  1723.         break;
  1724.         default:
  1725.             as_str = "Unkown device";
  1726.         break;
  1727.     }
  1728.     return as_str;
  1729. }