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

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.  *   rf_offset_iq_sweep_Init_Age8960.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  RF offset IQ sweep Initalize Agilent 8960 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. //---------------------------------------------------------------------------
  66. #include <vcl.h>
  67. #pragma hdrstop
  68. #include "form_RFTool.h"
  69. #include "rf_offset_iq_Sweep_Init_Age8960.h"
  70. #include "meta_utils.h"
  71. //#include "Crystal_INIFileHandle.h"
  72. #include "man_dll.h"
  73. // equipment
  74. #include "ageCommon.h"
  75. #include "age1968A.h"
  76. #include "cmu200.h"
  77. #ifndef  _RCT_COMMON_H_
  78. #include "rct_common.h"
  79. #endif
  80. //---------------------------------------------------------------------------
  81. //#define ONE_SECOND 1
  82. //------------------------------------------------------------------------------
  83. CMU_VAR cmu;
  84. static ViInt16 vi_Band_Crystal;
  85. static T_TXIQ_SWEEP* g_txiq_sweep_ptr;
  86. //==============================================================================
  87. static void CNF_TXIQ_Sweep(void)
  88. {
  89.     g_txiq_sweep_ptr->CNF_TXIQ_Sweep();
  90. }
  91. //----------------------------------------------------------------------------
  92. static void cb_read_CrystalAFC_from_nvram_TrOff()
  93. {
  94.     if(frmRFTool->m_pt_TXIQ_sweep != NULL )
  95.     {
  96.         frmRFTool->m_pt_TXIQ_sweep->Resume();
  97.     }
  98. }
  99. //------------------------------------------------------------------------------
  100. static void cb_write_CrystalAFC_to_nvram_TrOff()
  101. {
  102.     if(frmRFTool->m_pt_TXIQ_sweep != NULL )
  103.     {
  104.         frmRFTool->m_pt_TXIQ_sweep->Resume();
  105.     }
  106. }
  107. //------------------------------------------------------------------------------
  108. void __stdcall cb_rf_setbbtx_cfg_TrOff(const unsigned char cnf, const short token, void *usrData)
  109. {
  110.      if(frmRFTool->m_pt_TXIQ_sweep != NULL )
  111.      {
  112.         frmRFTool->m_pt_TXIQ_sweep->Resume();
  113.      }
  114. }
  115. //------------------------------------------------------------------------------
  116. void __stdcall cb_rf_tx_level_TrOff(const unsigned char cnf, const short token, void *usrData)
  117. {
  118.      if(frmRFTool->m_pt_TXIQ_sweep != NULL )
  119.      {
  120.         frmRFTool->m_pt_TXIQ_sweep->Resume();
  121.      }
  122. }
  123. //------------------------------------------------------------------------------
  124. static void cb_rf_stop_TrOff()
  125. {
  126.     if(frmRFTool->m_pt_TXIQ_sweep != NULL )
  127.     {
  128.         frmRFTool->m_pt_TXIQ_sweep->Resume();
  129.     }
  130. }
  131. //==============================================================================
  132. void _fastcall T_TXIQ_SWEEP::ShowMsg()
  133. {
  134.     ShowMessage( as_Msg );
  135. }
  136. //------------------------------------------------------------------------------
  137. void _fastcall T_TXIQ_SWEEP::SyncShowMsg(AnsiString as)
  138. {
  139.     as_Msg = as;
  140.     Synchronize( ShowMsg );
  141. }
  142. //=========================================================================================
  143. __fastcall T_TXIQ_SWEEP::T_TXIQ_SWEEP(bool CreateSuspended,
  144.                                       S_TXIQ_SWEEP_T *p_txiq_sweep,
  145.                                       ViSession &vs_Age196x,
  146.                                       AnsiString &as_TaModel
  147.                                       ): TThread(CreateSuspended)
  148. {
  149.     g_txiq_sweep_ptr = this;
  150.     m_pTxIqSweep = p_txiq_sweep;
  151.     as_pAgeTaModel = &as_TaModel;
  152.     pvi = &vs_Age196x;
  153. }
  154. //---------------------------------------------------------------------------
  155. void __fastcall T_TXIQ_SWEEP::Execute()
  156. {
  157.     Initialize_Equipment();
  158.     // get BBTXCfg from target
  159.     m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
  160.     m_cTXIQ_RUN_Obj.REQ_GetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver);
  161.     this->Suspend();
  162.     if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
  163.     {
  164.         SyncShowMsg("Get BBTXCfg parameter from target fail");
  165.         return;
  166.     }
  167.     RfBBTXCfg4* p_bbtxcfg = m_cTXIQ_RUN_Obj.Get_BbTxCfg();
  168.     m_sBbTxCfg = *p_bbtxcfg;
  169.     switch (m_pTxIqSweep->e_sweep_type)
  170.     {
  171.         case TXIQ_SWEEP_TYPE_TRIM_IQ:
  172.         {
  173.             if (!Trim_IQ_Sweep())
  174.             {
  175.                 return;
  176.             }
  177.         }
  178.         break;
  179.         case TXIQ_SWEEP_TYPE_OFFSET_IQ:
  180.         {
  181.             if (!Offset_IQ_Sweep())
  182.             {
  183.                 return;
  184.             }
  185.         }
  186.         break;
  187.         case TXIQ_SWEEP_TYPE_PHASESEL:
  188.         {
  189.             if (!Phasesel_Sweep())
  190.             {
  191.                 return;
  192.             }
  193.         }
  194.         break;
  195.     }
  196.     this->OnTerminate = m_pTxIqSweep->ne_onTermSuccess;
  197. }
  198. //======================================================================
  199. bool __fastcall T_TXIQ_SWEEP::Initialize_Equipment(void)
  200. {
  201.     if (m_pTxIqSweep->e_device_type == AGILENT_8960)
  202.     {
  203.         if ((vistat = age1960_init(m_pTxIqSweep->as_ADDR.c_str(), 0, 0, &vi)) != VI_SUCCESS)
  204.         {
  205.             Application->MessageBox(" Initialize Agilent 8960 fail 2", "Fail", MB_OK);
  206.             return false;
  207.         }
  208.         //////////////////////////////////////////////////////////////////////////////
  209.         if ((vistat = age_QueryTaModel(vi, as_pAgeTaModel)) != VI_SUCCESS)
  210.         {
  211.             Application->MessageBox(" Query Agilent 8960 TA Model fail ", "Fail", MB_OK);
  212.             return false;
  213.         }
  214.         //////////////////////////////////////////////////////////////////////////////
  215.         Sleep(50);
  216.         if (vi != VI_NULL)
  217.         {
  218.             if (age1960_dcl(vi)!= VI_SUCCESS)
  219.             {
  220.                 Application->MessageBox(" Agilent 8960 DCL fail ", "Fail", MB_OK);
  221.                 return false;
  222.             }
  223.         }
  224.         //////////////////////////////////////////////////////////////////////////////
  225.         Sleep(50);
  226.         if (vi != VI_NULL)
  227.         {
  228.             vistat = age1960_reset(vi);
  229.             if (vistat != VI_SUCCESS)
  230.             {
  231.                 Application->MessageBox(" Reset Agilent 8960 fail ", "Fail", MB_OK);
  232.                 return false;
  233.             }
  234.         }
  235.         /////////////////////////////////////////////////////////////////////////////
  236.         if(! m_pTxIqSweep->rf_cfg->getTimeOut(i_AGE8960_TimeOut))
  237.         {
  238.             Application->MessageBox( "Execution Failure : Get Time Out from file fail", "FAILURE", MB_OK );
  239.             return false;
  240.         }
  241.         if ((vistat = age1960_timeOut (vi,i_AGE8960_TimeOut)) != VI_SUCCESS)
  242.         {
  243.             Application->MessageBox( " Agilent 8960 set timeout fail ", "Fail", MB_OK );
  244.             return false;
  245.         }
  246.         /////////////////////////////////////////////////////////////////////////////
  247.         if((! m_pTxIqSweep->rf_cfg->getGSM400_CableLoss(d400))   ||
  248.            (! m_pTxIqSweep->rf_cfg->getGSM850_CableLoss(d850))   ||
  249.            (! m_pTxIqSweep->rf_cfg->getGSM900_CableLoss(d900))   ||
  250.            (! m_pTxIqSweep->rf_cfg->getDCS1800_CableLoss(d1800)) ||
  251.            (! m_pTxIqSweep->rf_cfg->getPCS1900_CableLoss(d1900))
  252.           )
  253.         {
  254.             Application->MessageBox( " Agilent 8960 read config file (cable loss) fail ", "Fail", MB_OK );
  255.             return false;
  256.         }
  257.         const AMP_OFFSET_ITEMS = 10;
  258.         ViReal64  freqArray[AMP_OFFSET_ITEMS] = { 400000000.0,
  259.                                                   641000000.0,
  260.                                                   641100000.0,
  261.                                                   876000000.0,
  262.                                                   876100000.0,
  263.                                                   1312000000.0,
  264.                                                   1312100000.0,
  265.                                                   1880000000.0,
  266.                                                   1881000000.0,
  267.                                                   2000000000.0 };
  268.         ViReal64  offsetArray[AMP_OFFSET_ITEMS] = { d400,
  269.                                                     d400,
  270.                                                     d850,
  271.                                                     d850,
  272.                                                     d900,
  273.                                                     d900,
  274.                                                     d1800,
  275.                                                     d1800,
  276.                                                     d1900,
  277.                                                     d1900
  278.                                                   };
  279.         if ((vistat = age1960_amplitudeOffset (
  280.                                                 vi,
  281.                                                 freqArray,
  282.                                                 offsetArray,
  283.                                                 AMP_OFFSET_ITEMS
  284.                                               )) != VI_SUCCESS)
  285.         {
  286.             Application->MessageBox( " Agilent 8960 set cable loss fail ", "Fail", MB_OK );
  287.             return false;
  288.         }
  289.         /////////////////////////////////////////////////////////////////////////////
  290.         if(as_pAgeTaModel->AnsiCompareIC("E1968A") == 0 ||
  291.            as_pAgeTaModel->AnsiCompareIC("E6701C") == 0 ||
  292.            as_pAgeTaModel->AnsiCompareIC("E6701D") == 0 ||
  293.            as_pAgeTaModel->AnsiCompareIC("E6701E") == 0
  294.           )
  295.         {
  296.             if (GMSK == m_pTxIqSweep->e_modulation)
  297.             {
  298.                 vistat = age1968A_operatingMode(vi, OPERATING_MODE_GSM_BCH_TCH);
  299.                 if (vistat!= VI_SUCCESS)
  300.                 {
  301.                     Application->MessageBox(" Agilent 8960 set operation mode fail ", "Fail", MB_OK );
  302.                     return false;
  303.                 }
  304.             }
  305.             else // EPSK
  306.             {
  307.                 vistat = age1968A_operatingMode(vi, OPERATING_MODE_EGPRS_BCH_PDTCH);
  308.                 if (vistat != VI_SUCCESS)
  309.                 {
  310.                     Application->MessageBox(" Agilent 8960 set operation mode fail ", "Fail", MB_OK );
  311.                     return false;
  312.                 }
  313.             }
  314.         }
  315.         else  // Agilent 1960A
  316.         {
  317.             if ((vistat = age1960_operatingMode(
  318.                                                  vi,
  319.                                                  (ViInt16) age1960_TEST_MODE
  320.                                                ))!= VI_SUCCESS)
  321.             {
  322.                 Application->MessageBox( " Agilent 8960 set operation mode fail ", "Fail", MB_OK );
  323.                 return false;
  324.             }
  325.         }
  326.     }
  327.     else //--------------To Do CMU200 Functions------------------
  328.     {
  329.             // double d900,Out900,d400,Out400,d850,Out850,d1800,Out1800,d1900,Out1900;
  330.              AnsiString as_CMU_ADDR;
  331.              int as_CMU_TimeOut;
  332.              AnsiString CMU_GSM_INP,CMU_GSM_OUT;
  333.              AnsiString as_RF_Equipment_ADDR;
  334.             //************************************************************
  335.              if((! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_GSM400_CableLoss( d400 )) ||
  336.                (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_GSM850_CableLoss( d850 )) ||
  337.                (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_GSM900_CableLoss( d900 )) ||
  338.                (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_DCS1800_CableLoss( d1800 )) ||
  339.                (! m_pTxIqSweep->rf_cfg->getCMU200_INPUT_PCS1900_CableLoss( d1900 ))
  340.                                                       )
  341.              {
  342.              Application->MessageBox( " CMU200 read config file (cable loss) fail ", "Fail", MB_OK );
  343.              return false;
  344.              }
  345.            //*************************************************************
  346.             //************************************************************
  347.              if((! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_GSM400_CableLoss( Out400 )) ||
  348.                (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_GSM850_CableLoss( Out850 )) ||
  349.                (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_GSM900_CableLoss( Out900 )) ||
  350.                (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_DCS1800_CableLoss( Out1800 )) ||
  351.                (! m_pTxIqSweep->rf_cfg->getCMU200_OUTPUT_PCS1900_CableLoss( Out1900 ))
  352.                                                       )
  353.              {
  354.              Application->MessageBox( " CMU200 read config file (cable loss) fail ", "Fail", MB_OK );
  355.              return false;
  356.              }
  357.            //*************************************************************
  358.              m_pTxIqSweep->rf_cfg->getCMU200_GPIB_Addr( as_RF_Equipment_ADDR );
  359.              m_pTxIqSweep->rf_cfg->getCMU200_TimeOut(as_CMU_TimeOut);
  360.              cmu.loss_gsm850_i=d850;
  361.              cmu.loss_gsm850_o=Out850;
  362.              cmu.loss_gsm_i=d900;
  363.              cmu.loss_gsm_o=Out900;
  364.              cmu.loss_dcs_i=d1800;
  365.              cmu.loss_dcs_o=Out1800;
  366.              cmu.loss_pcs_i=d1900;
  367.              cmu.loss_pcs_o=Out1900;
  368.         //cmu.ADD=as_CMU_ADDR;
  369.         cmu.ADD=as_RF_Equipment_ADDR.SubString(0, as_RF_Equipment_ADDR.Pos("::INSTR")-1);
  370.         cmu.TMO= StrToInt(as_CMU_TimeOut);
  371.         cmu.BAND="GSM";
  372.         if( !cmu_init_TX_FreqErr(&cmu) )
  373.         {
  374.             Application->MessageBox( "Initial CMU200 fail", "Fail", MB_OK );
  375.             return false;
  376.         }
  377.         Sleep(1500);
  378.     }
  379.     /////////////////////////////////////////////////////////////////////////////
  380.     switch (m_pTxIqSweep->e_band)
  381.     {
  382.          case 0:
  383.          vi_Band = age1960_EGSM_BAND;
  384.             cmu.BAND="GSM";
  385.             vi_Band_Crystal=1;
  386.          break;
  387.          case 1:
  388.             vi_Band = age1960_DCS1800_BAND;
  389.             cmu.BAND="DCS";
  390.             vi_Band_Crystal=3;
  391.          break;
  392.          case 2:
  393.             vi_Band = age1960_PCS1900_BAND;
  394.             cmu.BAND="PCS";
  395.             vi_Band_Crystal=4;
  396.          break;
  397.          case 3:
  398.             vi_Band = age1960_GSM850_BAND;
  399.             cmu.BAND="GSM850";
  400.             vi_Band_Crystal=CMU_GSM850_BAND;
  401.          break;
  402.     } // switch
  403.     if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  404.     {
  405.         if ( age1960_cellBand(
  406.                                 vi,
  407.                                 age1960_CELL_1,
  408.                                 vi_Band
  409.                               ) != VI_SUCCESS )
  410.         {
  411.     age1960_error_message(vi, vistat, errmsg);
  412.             AnsiString as_error_msg;
  413.             as_error_msg = (AnsiString) errmsg;
  414.             Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  415.             Application->MessageBox( " Agilent 8960 set cell band fail ", "Fail", MB_OK );
  416.             return false;
  417.         }
  418.     }
  419.     else
  420.     {
  421.         if( !cmu_cellband(vi_Band_Crystal, &cmu) )
  422.         {
  423.             Application->MessageBox( " CMU200 set cell band fail ", "Fail", MB_OK );
  424.             return false;
  425.         } // if
  426.     }
  427.    /////////////////////////////////////////////////////////////////////////////
  428.    d_P_DL = -60;
  429.    if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  430.    {
  431.         if ( age1960_cellPower(
  432.                                  vi,
  433.                                  age1960_CELL_1,
  434.                                  d_P_DL,
  435.                                  0
  436.                               ) != VI_SUCCESS)
  437.         {
  438.             age1960_error_message(vi, vistat, errmsg);
  439.             AnsiString as_error_msg;
  440.             as_error_msg = (AnsiString) errmsg;
  441.             Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  442.             Application->MessageBox( " Agilent 8960 set cell power fail ", "Fail", MB_OK );
  443.             return false;
  444.         }
  445.     }
  446.     else
  447.     {
  448.         if( !cmu_cellpower(d_P_DL, &cmu) )
  449.         {
  450.             Application->MessageBox( " CMU200 set cell power fail ", "Fail", MB_OK );
  451.             return false;
  452.         } // if
  453.     }
  454.     if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  455.     {
  456.         if ( age1960_TCHARFCN(
  457.                                vi,
  458.                                m_pTxIqSweep->s_arfcn,
  459.                                (short) 0, // current band
  460.                                VI_TRUE
  461.                              )!= VI_SUCCESS)
  462.         {
  463.             age1960_error_message(vi, vistat, errmsg);
  464.             AnsiString as_error_msg;
  465.             as_error_msg = (AnsiString) errmsg;
  466.             Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  467.             Application->MessageBox( " Agilent 8960 set TCH ARFCN fail ", "Fail", MB_OK );
  468.             return false;
  469.         }
  470.     }
  471.     else
  472.     {
  473.         if( !cmu_tcharfcn(m_pTxIqSweep->s_arfcn, &cmu) )
  474.         {
  475.             Application->MessageBox( " CMU200 set TCH ARFCN fail ", "Fail", MB_OK );
  476.             return false;
  477.         }
  478.     }
  479.     /////////////////////////////////////////////////////////////////////////////
  480.     //*****************************************************************
  481.     if(m_pTxIqSweep->e_device_type == AGILENT_8960)
  482.     {
  483.         if( age1968A_ConfigTSC(vi, m_pTxIqSweep->tsc) != VI_SUCCESS )
  484.         {
  485.             Application->MessageBox( " Agilent 8960 config TSC fail ", "Fail", MB_OK );
  486.             return false;
  487.         }
  488.     }
  489.     else
  490.     {
  491.         if( !cmu_tsc(m_pTxIqSweep->tsc, &cmu) )
  492.         {
  493.            Application->MessageBox( " CMU200 config TSC fail ", "Fail", MB_OK );
  494.            return false;
  495.         }
  496.     }
  497.     /////////////////////////////////////////////////////////////////////////////
  498.     if(m_pTxIqSweep->e_device_type == AGILENT_8960)
  499.     {
  500.         if ( age1960_MSTXLevel(
  501.                                      vi,
  502.                                     m_pTxIqSweep->pcl,
  503.                                     (short) 0,  // current band
  504.                                     VI_TRUE
  505.                                    )!= VI_SUCCESS)
  506.         {
  507.             age1960_error_message(vi, vistat, errmsg);
  508.             AnsiString as_error_msg;
  509.             as_error_msg = (AnsiString) errmsg;
  510.             Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  511.             Application->MessageBox( " Agilent 8960 MS TX level fail ", "Fail", MB_OK );
  512.             return false;
  513.         }
  514.     }
  515.     else
  516.     {
  517.         if( !cmu_mxtxlevel(m_pTxIqSweep->pcl, &cmu) )
  518.         {
  519.             Application->MessageBox( " CMU200 MS TX level fail ", "Fail", MB_OK );
  520.             return false;
  521.         }
  522.     }
  523.     /////////////////////////////////////////////////////////////////////////////
  524.     if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  525.     {
  526.         switch( m_pTxIqSweep->e_output_data_type )
  527.         {
  528.             case TXIQ_OUTPUT_DATA_TYPE_PHERR:
  529.             {
  530.                 if (GMSK == m_pTxIqSweep->e_modulation)
  531.                 {
  532.                     if (age1960_confPFER(vi,
  533.                                          m_pTxIqSweep->i_measure_count,
  534.                                          age1960_TRIG_AUTO,
  535.                                          AGE1960_PFER_TRIGGER_DELAY,
  536.                                          AGE1960_PFER_TRIGGER_QUALIFIER_ON,
  537.                                          age1960_BSYNC_MID,
  538.                                          AGE1960_READ_PFER_TIMEOUT)!= VI_SUCCESS)
  539.                     {
  540.                         Application->MessageBox( " Agilent 8960 config PFER fail ", "Fail", MB_OK );
  541.                         return false;
  542.                     }
  543.                 }
  544.                 else // EPSK
  545.                 {
  546.                     if (age1968A_Config_EPSK_ModACcuracy(vi,
  547.                                                          m_pTxIqSweep->i_measure_count,
  548.                                                          age1960_TRIG_AUTO,
  549.                                                          AGE1960_PFER_TRIGGER_DELAY,
  550.                                                          AGE1960_READ_PFER_TIMEOUT) != VI_SUCCESS)
  551.                     {
  552.                         Application->MessageBox(" Agilent 8960 config PFER fail ", "Fail", MB_OK );
  553.                         return false;
  554.                     }
  555.                 }
  556.             }
  557.             break;
  558.             case TXIQ_OUTPUT_DATA_TYPE_OOS:
  559.             case TXIQ_OUTPUT_DATA_TYPE_SBS:
  560.             {
  561.                 if (GMSK == m_pTxIqSweep->e_modulation)
  562.                 {
  563.                     if (age1960_confIQTuning(vi,
  564.                                              m_pTxIqSweep->i_measure_count,
  565.                                              age1960_TRIG_RF_RISE,
  566.                                              AGE1960_IQ_TUNNING_TRIGGER_DELAY,
  567.                                              age1960_IQ_REF_AUTO,
  568.                                              AGE1960_IQ_TUNNING_TRIGGER_QUALIFIER_OFF,
  569.                                              AGE1960_IQ_TUNNING_SPUR_FREQ,
  570.                                              AGE1960_READ_IQ_TUNNING_TIMEOUT) != VI_SUCCESS)
  571.                     {
  572.                         Application->MessageBox( " Agilent 8960 config IQ tunning fail ", "Fail", MB_OK );
  573.                         return false;
  574.                     }
  575.                 }
  576.                 else
  577.                 {
  578.                     if (age1968A_Config_EPSK_ModACcuracy(vi,
  579.                                                          m_pTxIqSweep->i_measure_count,
  580.                                                          age1960_TRIG_AUTO,
  581.                                                          AGE1960_IQ_TUNNING_TRIGGER_DELAY,
  582.                                                          AGE1960_READ_IQ_TUNNING_TIMEOUT) != VI_SUCCESS)
  583.                     {
  584.                         Application->MessageBox( " Agilent 8960 config IQ tunning fail ", "Fail", MB_OK );
  585.                         return false;
  586.                     }
  587.                 }
  588.             }
  589.             break;
  590.         }
  591.     }
  592.     else
  593.     {
  594.         switch( m_pTxIqSweep->e_output_data_type )
  595.         {
  596.             case TXIQ_OUTPUT_DATA_TYPE_PHERR:
  597.             {
  598.                 if( ! cmu_mod_config_control_mode( &cmu, m_pTxIqSweep->i_measure_count ) )
  599.                 {
  600.                     Application->MessageBox( " CMU200 config PFER fail ", "Fail", MB_OK );
  601.                     return false;
  602.                 }
  603.                 if( ! cmu_mod_config_control_repetition( &cmu, m_pTxIqSweep->i_measure_count )  )
  604.                 {
  605.                     Application->MessageBox( " CMU200 config PFER fail ", "Fail", MB_OK );
  606.                     return false;
  607.                 }
  608.             }
  609.             break;
  610.             case TXIQ_OUTPUT_DATA_TYPE_OOS:
  611.             case TXIQ_OUTPUT_DATA_TYPE_SBS:
  612.             {
  613.                  if( ! cmu_mod_xper_config_control_mode( &cmu, m_pTxIqSweep->i_measure_count ) )
  614.                  {
  615.                      Application->MessageBox( " CMU200 config IQ tunning fail ", "Fail", MB_OK );
  616.                      return false;
  617.                  }
  618.                  if( ! cmu_mod_xper_config_control_repetition( &cmu, m_pTxIqSweep->i_measure_count ) )
  619.                  {
  620.                      Application->MessageBox( " Agilent 8960 config IQ tunning fail ", "Fail", MB_OK );
  621.                      return false;
  622.                  }
  623.             }
  624.             break;
  625.         }
  626.     }
  627.     /////////////////////////////////////////////////////////////////////////////
  628.     MeasFcnDone = -999; /* Set to unknown state to start       */
  629.     Sleep(50);
  630.     _VI_PTR pvi = vi;
  631.     return true;
  632. }
  633. //======================================================================
  634. bool __fastcall T_TXIQ_SWEEP::CheckError(ViStatus ErrorStatus)
  635. {
  636. /*------------------------------------------------*/
  637. /* Check for driver errors.                       */
  638. /* If an error occurred reset the instrument and  */
  639. /* return true else return false.                 */
  640. /*------------------------------------------------*/
  641.     ViChar      ErrorMessage[256];
  642.     ViChar      message[100];
  643.     if (VI_SUCCESS > ErrorStatus){
  644.         /* Query the error */
  645.         age1960_error_message(vi, ErrorStatus, ErrorMessage);
  646.         /* set the mouse pointer for the form back to the default */
  647.         Screen->Cursor =  crDefault;
  648.         /* Display the error */
  649.         sprintf(message,  "Instrument Error: %ld %s",ErrorStatus, ErrorMessage);
  650.         ShowMessage (message);
  651.         /* Send a device clear - to ensure communication with the instrument */
  652.         //age1960_dcl(vi);
  653.         /* reset the instrument */
  654.         age1960_reset(vi);
  655.         return  true;
  656.     }
  657.     return false;
  658. }
  659. //---------------------------------------------------------------------------
  660. bool __fastcall T_TXIQ_SWEEP::Trim_IQ_Sweep( void )
  661. {
  662.     int i, j;
  663.     AnsiString as_str = Get_DataTypeStr();
  664.     as_str = "Output data type: " + as_str;
  665.     sprintf(buf, as_str.c_str());
  666.     m_pTxIqSweep->st_Log->Add(buf);
  667.     frmRFTool->write_TXIQ_log();
  668.     sprintf(buf, "OffsetI = %d, OffsetQ = %d", m_pTxIqSweep->offset_i, m_pTxIqSweep->offset_q);
  669.     m_pTxIqSweep->st_Log->Add(buf);
  670.     frmRFTool->write_TXIQ_log();
  671.     buf[0]='';
  672.     sprintf(buf1, "TrimI/TrimQ");
  673.     strcat(buf, buf1);
  674.     for( j=m_pTxIqSweep->min_trim_q; j<=m_pTxIqSweep->max_trim_q; j=j+m_pTxIqSweep->trim_q_step )
  675.     {
  676.         if(j==m_pTxIqSweep->min_trim_q)
  677.         {
  678.             sprintf(buf1, "%3d", j);
  679.         }
  680.         else
  681.         {
  682.             sprintf(buf1, "%12d", j);
  683.         }
  684.         strcat(buf, buf1);
  685.     }
  686.     m_pTxIqSweep->st_Log->Add(buf);
  687.     frmRFTool->write_TXIQ_log();
  688.     m_sBbTxCfg.TxOffsetI = m_pTxIqSweep->offset_i;
  689.     m_sBbTxCfg.TxOffsetQ = m_pTxIqSweep->offset_q;
  690.     if (m_pTxIqSweep->e_bbtxcfg_ver >= BBTXCFG_VER3)
  691.     {
  692.         m_sBbTxCfg.TxPhasesel = m_pTxIqSweep->sc_phasesel;
  693.     }
  694.     for (i=m_pTxIqSweep->min_trim_i; i<=m_pTxIqSweep->max_trim_i; i=i+m_pTxIqSweep->trim_i_step)
  695.     {
  696.         buf[0]='';
  697.         sprintf(buf1, "%4d", i );
  698.         strcat(buf, buf1);
  699.         //strcat(buf, "   ");
  700.         for (j=m_pTxIqSweep->min_trim_q; j<=m_pTxIqSweep->max_trim_q; j=j+m_pTxIqSweep->trim_q_step)
  701.         {
  702.             m_sBbTxCfg.TxTrimI   = i;
  703.             m_sBbTxCfg.TxTrimQ   = j;
  704.             m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
  705.             m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver, m_sBbTxCfg);
  706.             //if( META_SUCCESS != META_Rf_SetBBTXCfg_r( m_META_HANDLE_Obj.Get_MainHandle(), &RFReq_BBTXCFG, ::cb_rf_setbbtx_cfg_TrOff, &rf_setbbtx_cfg_token, NULL ) )
  707.             //{   return false;
  708.             //}
  709.             this->Suspend();
  710.             if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
  711.             {
  712.                 SyncShowMsg("Set BBTXCfg parameter to target fail");
  713.                 return false;
  714.             }
  715.             if (this->Terminated)
  716.             {
  717.                 this->OnTerminate = neByUser;
  718.                 return false;
  719.             }
  720.             Sleep(50);
  721.             rf_tx_level_req.arfcn = m_pTxIqSweep->s_arfcn;
  722.             rf_tx_level_req.bsic  =  m_pTxIqSweep->tsc;
  723.             rf_tx_level_req.power    = m_pTxIqSweep->pcl;
  724.             rf_tx_level_req.frames   = -99;
  725.             rf_tx_level_req.dacValue = m_pTxIqSweep->s_afc_dac;
  726.             rf_tx_level_req.burstTypeNB = m_pTxIqSweep->e_burst_type;
  727.             if ( META_Rf_NB_TX_r( m_META_HANDLE_Obj.Get_MainHandle(),
  728.                     &rf_tx_level_req,
  729.                     ::cb_rf_tx_level_TrOff,
  730.                     &rf_tx_level_token,
  731.                                     NULL
  732.                                    ) != META_SUCCESS)
  733.             {
  734.                 return false;
  735.             }
  736.             this->Suspend();
  737.             switch (m_pTxIqSweep->e_output_data_type)
  738.             {
  739.                 case TXIQ_OUTPUT_DATA_TYPE_PHERR:
  740.                 {
  741.                     if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  742.                     {
  743.                         if (GMSK == m_pTxIqSweep->e_modulation)
  744.                         {
  745.                             if (age1960_initMeasFcn(vi, age1960_PFER) != VI_SUCCESS)
  746.                             {
  747.                                 age1960_error_message(vi, vistat, errmsg);
  748.                                 AnsiString as_error_msg;
  749.                                 as_error_msg = (AnsiString) errmsg;
  750.                                 Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  751.                                 Application->MessageBox( " Agilent 8960 initialize measure function (PFER) fail ", "Fail", MB_OK );
  752.                                 return false;
  753.                             }
  754.                             Sleep(50);
  755.                             if (age1960_fetchPFER_Q(
  756.                                                       vi,
  757.                                                       &PFERIntegrity,
  758.                                                       &PFERRMSError,
  759.                                                       &PFERPeakError,
  760.                                                       &PFERFreqError
  761.                                                     )!= VI_SUCCESS)
  762.                             {
  763.                                 Application->MessageBox( "age1960_fetchPFER_Q() error" , "Error", MB_OK );
  764.                                 return false;
  765.                             }
  766.                         }
  767.                         else
  768.                         {
  769.                             if (age1968A_Fetch_EPSK_Average_PhaseError(vi, &PFERRMSError) != VI_SUCCESS)
  770.                             {
  771.                                 Application->MessageBox( "Agilent 8960 fetch EPSK average phase error fail" , "FAIL", MB_OK );
  772.                                 return false;
  773.                             }
  774.                         }
  775.                     }
  776.                     else
  777.                     {
  778.                             if( ! cmu_mod_init( &cmu ) )
  779.                             {
  780.                                 Application->MessageBox( "cmu_mod_init() error" , "Error", MB_OK );
  781.                                 return false;
  782.                             }
  783.                             if( ! cmu_mod_sample(&cmu, PH_ERR_RMS_AVERAGE, &PFERRMSError) )
  784.                             {
  785.                                 Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
  786.                                 return false;
  787.                             }
  788.                             if( ! cmu_mod_abort( &cmu ) )
  789.                             {
  790.                                 Application->MessageBox( "cmu_mod_abort() error" , "Error", MB_OK );
  791.                                 return false;
  792.                             }
  793.                         }
  794.                             //FreqError = PFERFreqError;
  795.                         sprintf(buf1, "%12.4f", PFERRMSError );
  796.                         strcat(buf, buf1);
  797.                            // strcat(buf, "   ");
  798.                         Sleep(50);
  799.                         rf_stop.REQ_Start();
  800.                     }
  801.                     break;
  802.                     case TXIQ_OUTPUT_DATA_TYPE_OOS:
  803.                     {
  804.                         ViReal64 d_Original_Offset;
  805.                         if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  806.                         {
  807.                             if (GMSK == m_pTxIqSweep->e_modulation)
  808.                             {
  809.                                 if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS )
  810.                                 {
  811.                                     age1960_error_message(vi, vistat, errmsg);
  812.                                     AnsiString as_error_msg;
  813.                                     as_error_msg = (AnsiString) errmsg;
  814.                                     Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  815.                                     Application->MessageBox( " Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK );
  816.                                     return false;
  817.                                 }
  818.                                 if (age1960_fetchIQTuning_Q (
  819.                                                               vi,
  820.                                                               age1960_IQ_ARRAY_MIN,
  821.                                                               &IQTIntegrity,
  822.                                                               &IQTSpurFreq,
  823.                                                               &IQTSpurLevel,
  824.                                                               IQTResultsArray,
  825.                                                               IQTFreqsArray,
  826.                                                               &IQTTuningCount
  827.                                                              ) != VI_SUCCESS )
  828.                                 {
  829.                                     age1960_error_message(vi, vistat, errmsg);
  830.                                     AnsiString as_error_msg;
  831.                                     as_error_msg = (AnsiString) errmsg;
  832.                                     Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  833.                                     Application->MessageBox( " Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK );
  834.                                     return false;
  835.                                 }
  836.                                 d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  837.                                 if (NAN == d_Original_Offset)
  838.                                 {
  839.                                     return false;
  840.                                 }
  841.                             }
  842.                             else  // EPSK
  843.                             {
  844.                                 if (age1968A_Fetch_EPSK_Average_OrignalOffset(vi, &d_Original_Offset) != VI_SUCCESS)
  845.                                 {
  846.                                     Application->MessageBox("Agilent 8960 fetch EPSK average original offset fail ", "Fail", MB_OK );
  847.                                     return false;
  848.                                 }
  849.                             }
  850.                          }
  851.                          else
  852.                          {
  853.                              if( ! cmu_mod_xper_init( &cmu ) )
  854.                             {
  855.                                 Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
  856.                                 return false;
  857.                             }
  858.                             if( ! cmu_mod_xper_sample(&cmu, XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
  859.                             {
  860.                                 Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
  861.                                 return false;
  862.                             }
  863.                             if( ! cmu_mod_xper_abort( &cmu ) )
  864.                             {
  865.                                 Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
  866.                                 return false;
  867.                             }
  868.                          }
  869.                          sprintf(buf1, "%12.6f", d_Original_Offset );
  870.                          strcat(buf, buf1);
  871.                          Sleep(50);
  872.                          rf_stop.REQ_Start();
  873.                     }
  874.                     break;
  875.                     case TXIQ_OUTPUT_DATA_TYPE_SBS:
  876.                     {
  877.                         ViReal64 d_IQ_Imbalance;
  878.                         if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  879.                         {
  880.                             if (GMSK == m_pTxIqSweep->e_modulation)
  881.                             {
  882.                                 if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
  883.                                 {
  884.                                     age1960_error_message(vi, vistat, errmsg);
  885.                                     AnsiString as_error_msg;
  886.                                     as_error_msg = (AnsiString) errmsg;
  887.                                     Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  888.                                     Application->MessageBox( " Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK );
  889.                                     return false;
  890.                                 }
  891.                                 if (age1960_fetchIQTuning_Q(vi,
  892.                                                             age1960_IQ_ARRAY_MIN,
  893.                                                             &IQTIntegrity,
  894.                                                             &IQTSpurFreq,
  895.                                                             &IQTSpurLevel,
  896.                                                             IQTResultsArray,
  897.                                                             IQTFreqsArray,
  898.                                                             &IQTTuningCount
  899.                                                             ) != VI_SUCCESS)
  900.                                 {
  901.                                     age1960_error_message(vi, vistat, errmsg);
  902.                                     AnsiString as_error_msg;
  903.                                     as_error_msg = (AnsiString) errmsg;
  904.                                     Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  905.                                     Application->MessageBox( " Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK );
  906.                                     return false;
  907.                                 }
  908.                                 d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  909.                                 if (NAN == d_IQ_Imbalance)
  910.                                 {
  911.                                     return false;
  912.                                 }
  913.                             }
  914.                             else
  915.                             {
  916.                                 if (age1968A_Fetch_EPSK_Average_IQImbalance(vi, &d_IQ_Imbalance) != VI_SUCCESS)
  917.                                 {
  918.                                     Application->MessageBox("Agilent 8960 fetch EPSK average IQ imbalance fail", "Fail", MB_OK);
  919.                                     return false;
  920.                                 }
  921.                             }
  922.                         }
  923.                         else
  924.                         {
  925.                             if( ! cmu_mod_xper_init( &cmu ) )
  926.                             {
  927.                                 Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
  928.                                 return false;
  929.                             }
  930.                             if( ! cmu_mod_xper_sample(&cmu, XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance) )
  931.                             {
  932.                                 Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
  933.                                 return false;
  934.                             }
  935.                             if( ! cmu_mod_xper_abort( &cmu ) )
  936.                             {
  937.                                 Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
  938.                                 return false;
  939.                             }
  940.                         }
  941.                         sprintf(buf1, "%12.6f", d_IQ_Imbalance );
  942.                         strcat(buf, buf1);
  943.                            // strcat(buf, "   ");
  944.                         Sleep(50);
  945.                         rf_stop.REQ_Start();
  946.                     }
  947.                     break;
  948.                 }// switch
  949.         }
  950.         m_pTxIqSweep->st_Log->Add(buf);
  951.         frmRFTool->write_TXIQ_log();
  952.     }
  953.     return true;
  954. }
  955. //---------------------------------------------------------------------------
  956. bool __fastcall T_TXIQ_SWEEP::Offset_IQ_Sweep( void )
  957. {
  958.     int i, j;
  959.     AnsiString as_str = Get_DataTypeStr();
  960.     as_str = "Output data type: " + as_str;
  961.     sprintf(buf, as_str.c_str());
  962.     m_pTxIqSweep->st_Log->Add(buf);
  963.     frmRFTool->write_TXIQ_log();
  964.     sprintf(buf, "TrimI = %d, TrimQ = %d", m_pTxIqSweep->trim_i, m_pTxIqSweep->trim_q);
  965.     //strcat(buf, buf1);
  966.     m_pTxIqSweep->st_Log->Add(buf);
  967.     frmRFTool->write_TXIQ_log();
  968.     buf[0]='';
  969.     sprintf(buf1, "OffsetI/OffsetQ");
  970.     strcat(buf, buf1);
  971.     for( j=m_pTxIqSweep->min_offset_q; j<=m_pTxIqSweep->max_offset_q; j=j+m_pTxIqSweep->offset_q_step )
  972.     {
  973.         if(j==m_pTxIqSweep->min_offset_q)
  974.         {
  975.             sprintf(buf1, "%5d", j);
  976.         }
  977.         else
  978.         {
  979.             sprintf(buf1, "%12d", j);
  980.         }
  981.         strcat(buf, buf1);
  982.     }
  983.     m_pTxIqSweep->st_Log->Add(buf);
  984.     frmRFTool->write_TXIQ_log();
  985.     m_sBbTxCfg.TxTrimI = m_pTxIqSweep->trim_i;
  986.     m_sBbTxCfg.TxTrimQ = m_pTxIqSweep->trim_q;
  987.     if (m_pTxIqSweep->e_bbtxcfg_ver >= BBTXCFG_VER3)
  988.     {
  989.         m_sBbTxCfg.TxPhasesel = m_pTxIqSweep->sc_phasesel;
  990.     }
  991.     for( i=m_pTxIqSweep->min_offset_i; i<=m_pTxIqSweep->max_offset_i; i=i+m_pTxIqSweep->offset_i_step )
  992.     {
  993.         buf[0]='';
  994.         sprintf(buf1, "%4d", i );
  995.         strcat(buf, buf1);
  996.         strcat(buf, "     ");
  997.         for (j=m_pTxIqSweep->min_offset_q; j<=m_pTxIqSweep->max_offset_q; j=j+m_pTxIqSweep->offset_q_step )
  998.         {
  999.             m_sBbTxCfg.TxOffsetI = i;
  1000.             m_sBbTxCfg.TxOffsetQ = j;
  1001.             m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
  1002.             m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver, m_sBbTxCfg);
  1003.             this->Suspend();
  1004.             if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
  1005.             {
  1006.                 SyncShowMsg("Set BBTXCfg parameter to target fail");
  1007.                 return false;
  1008.             }
  1009.             if (this->Terminated)
  1010.             {
  1011.                 this->OnTerminate = neByUser;
  1012.                 return false;
  1013.             }
  1014.             Sleep(50);
  1015.             rf_tx_level_req.arfcn = m_pTxIqSweep->s_arfcn;
  1016.             rf_tx_level_req.bsic  =  m_pTxIqSweep->tsc;
  1017.             rf_tx_level_req.power    = m_pTxIqSweep->pcl;
  1018.             rf_tx_level_req.frames   = -99;
  1019.             rf_tx_level_req.dacValue = m_pTxIqSweep->s_afc_dac;
  1020.             rf_tx_level_req.burstTypeNB = m_pTxIqSweep->e_burst_type;
  1021.             if ( META_Rf_NB_TX_r( m_META_HANDLE_Obj.Get_MainHandle(),
  1022.                     &rf_tx_level_req,
  1023.                     ::cb_rf_tx_level_TrOff,
  1024.                     &rf_tx_level_token,
  1025.                                     NULL
  1026.                                    ) != META_SUCCESS)
  1027.             {
  1028.                 return false;
  1029.             }
  1030.             this->Suspend();
  1031.             switch( m_pTxIqSweep->e_output_data_type )
  1032.             {
  1033.                 case TXIQ_OUTPUT_DATA_TYPE_PHERR:
  1034.                 {
  1035.                     if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  1036.                     {
  1037.                         if (GMSK == m_pTxIqSweep->e_modulation)
  1038.                         {
  1039.                             if (age1960_initMeasFcn(vi, age1960_PFER) != VI_SUCCESS)
  1040.                             {
  1041.                                 age1960_error_message(vi, vistat, errmsg);
  1042.                                 AnsiString as_error_msg;
  1043.                                 as_error_msg = (AnsiString) errmsg;
  1044.                                 Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  1045.                                 Application->MessageBox( " Agilent 8960 initialize measure function (PFER) fail ", "Fail", MB_OK );
  1046.                                 return false;
  1047.                             }
  1048.                             Sleep(50);
  1049.                             if ( age1960_fetchPFER_Q(
  1050.                                                       vi,
  1051.                                                       &PFERIntegrity,
  1052.                                                       &PFERRMSError,
  1053.                                                       &PFERPeakError,
  1054.                                                       &PFERFreqError
  1055.                                                     )!= VI_SUCCESS)
  1056.                             {
  1057.                                 Application->MessageBox( "age1960_fetchPFER_Q() error" , "Error", MB_OK );
  1058.                                 return false;
  1059.                             }
  1060.                         }
  1061.                         else // EPSK
  1062.                         {
  1063.                             if (age1968A_Fetch_EPSK_Average_PhaseError(vi, &PFERRMSError) != VI_SUCCESS)
  1064.                             {
  1065.                                 Application->MessageBox( "Agilent 8960 fetch EPSK average phase error fail" , "FAIL", MB_OK );
  1066.                                 return false;
  1067.                             }
  1068.                         }
  1069.                     }
  1070.                     else
  1071.                     {
  1072.                         if( ! cmu_mod_init( &cmu ) )
  1073.                         {
  1074.                                 Application->MessageBox( "cmu_mod_init() error" , "Error", MB_OK );
  1075.                                 return false;
  1076.                         }
  1077.                         if( ! cmu_mod_sample(&cmu, PH_ERR_RMS_AVERAGE, &PFERRMSError) )
  1078.                         {
  1079.                                 Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
  1080.                                 return false;
  1081.                         }
  1082.                         if( ! cmu_mod_abort( &cmu ) )
  1083.                         {
  1084.                                 Application->MessageBox( "cmu_mod_abort() error" , "Error", MB_OK );
  1085.                                 return false;
  1086.                         }
  1087.                     }
  1088.                     sprintf(buf1, "%12.4f", PFERRMSError );
  1089.                     strcat(buf, buf1);
  1090.                     Sleep(50);
  1091.                     rf_stop.REQ_Start();
  1092.                 }
  1093.                 break;
  1094.                     case TXIQ_OUTPUT_DATA_TYPE_OOS:
  1095.                     {
  1096.                         ViReal64 d_Original_Offset;
  1097.                         if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  1098.                         {
  1099.                             if (GMSK == m_pTxIqSweep->e_modulation)
  1100.                             {
  1101.                                 if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
  1102.                                 {
  1103.                                     age1960_error_message(vi, vistat, errmsg);
  1104.                                     AnsiString as_error_msg;
  1105.                                     as_error_msg = (AnsiString) errmsg;
  1106.                                     Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  1107.                                     Application->MessageBox( " Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK );
  1108.                                     return false;
  1109.                                 }
  1110.                                 if (age1960_fetchIQTuning_Q(vi,
  1111.                                                             age1960_IQ_ARRAY_MIN,
  1112.                                                             &IQTIntegrity,
  1113.                                                             &IQTSpurFreq,
  1114.                                                             &IQTSpurLevel,
  1115.                                                             IQTResultsArray,
  1116.                                                             IQTFreqsArray,
  1117.                                                             &IQTTuningCount
  1118.                                                             ) != VI_SUCCESS )
  1119.                                 {
  1120.                                     age1960_error_message(vi, vistat, errmsg);
  1121.                                     AnsiString as_error_msg;
  1122.                                     as_error_msg = (AnsiString) errmsg;
  1123.                                     Application->MessageBox( as_error_msg.c_str() , "Error", MB_OK );
  1124.                                     Application->MessageBox( " Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK );
  1125.                                     return false;
  1126.                                 }
  1127.                                 d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1128.                                 if( NAN == d_Original_Offset)
  1129.                                 {
  1130.                                     return false;
  1131.                                 }
  1132.                             }
  1133.                             else // EPSK
  1134.                             {
  1135.                                 if (age1968A_Fetch_EPSK_Average_OrignalOffset(vi, &d_Original_Offset) != VI_SUCCESS)
  1136.                                 {
  1137.                                     Application->MessageBox("Agilent 8960 fetch EPSK average original offset fail ", "Fail", MB_OK );
  1138.                                     return false;
  1139.                                 }
  1140.                             }
  1141.                         }
  1142.                         else
  1143.                         {
  1144.                             if( ! cmu_mod_xper_init( &cmu ) )
  1145.                             {
  1146.                                 Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
  1147.                                 return false;
  1148.                             }
  1149.                             if( ! cmu_mod_xper_sample(&cmu, XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
  1150.                             {
  1151.                                 Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
  1152.                                 return false;
  1153.                             }
  1154.                             if( ! cmu_mod_xper_abort( &cmu ) )
  1155.                             {
  1156.                                 Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
  1157.                                 return false;
  1158.                             }
  1159.                         }
  1160.                         sprintf(buf1, "%12.6f", d_Original_Offset );
  1161.                         strcat(buf, buf1);
  1162.                            // strcat(buf, "   ");
  1163.                         Sleep(50);
  1164.                         rf_stop.REQ_Start();
  1165.                     }
  1166.                     break;
  1167.                     case TXIQ_OUTPUT_DATA_TYPE_SBS:
  1168.                     {
  1169.                         ViReal64 d_IQ_Imbalance;
  1170.                         if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  1171.                         {
  1172.                             if (GMSK == m_pTxIqSweep->e_modulation)
  1173.                             {
  1174.                                 if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
  1175.                                 {
  1176.                                     age1960_error_message(vi, vistat, errmsg);
  1177.                                     AnsiString as_error_msg;
  1178.                                     as_error_msg = (AnsiString) errmsg;
  1179.                                     Application->MessageBox(as_error_msg.c_str() , "Error", MB_OK);
  1180.                                     Application->MessageBox("Agilent 8960 initialize measure function (IQTUNING) fail ", "Fail", MB_OK);
  1181.                                     return false;
  1182.                                 }
  1183.                                 if (age1960_fetchIQTuning_Q(vi,
  1184.                                                             age1960_IQ_ARRAY_MIN,
  1185.                                                             &IQTIntegrity,
  1186.                                                             &IQTSpurFreq,
  1187.                                                             &IQTSpurLevel,
  1188.                                                             IQTResultsArray,
  1189.                                                             IQTFreqsArray,
  1190.                                                             &IQTTuningCount
  1191.                                                             ) != VI_SUCCESS)
  1192.                                 {
  1193.                                     age1960_error_message(vi, vistat, errmsg);
  1194.                                     AnsiString as_error_msg;
  1195.                                     as_error_msg = (AnsiString) errmsg;
  1196.                                     Application->MessageBox(as_error_msg.c_str() , "Error", MB_OK);
  1197.                                     Application->MessageBox(" Agilent 8960 fetch IQ tunning fail ", "Fail", MB_OK);
  1198.                                     return false;
  1199.                                 }
  1200.                                 d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1201.                                 if (NAN == d_IQ_Imbalance)
  1202.                                 {
  1203.                                     return false;
  1204.                                 }
  1205.                             }
  1206.                             else // EPSK
  1207.                             {
  1208.                                 if (age1968A_Fetch_EPSK_Average_IQImbalance(vi, &d_IQ_Imbalance) != VI_SUCCESS)
  1209.                                 {
  1210.                                     Application->MessageBox("Agilent 8960 fetch EPSK average IQ imbalance fail", "Fail", MB_OK);
  1211.                                     return false;
  1212.                                 }
  1213.                             }
  1214.                         }
  1215.                         else
  1216.                         {
  1217.                             if( ! cmu_mod_xper_init( &cmu ) )
  1218.                             {
  1219.                                 Application->MessageBox( "cmu_mod_xper_init() error" , "Error", MB_OK );
  1220.                                 return false;
  1221.                             }
  1222.                             if( ! cmu_mod_xper_sample(&cmu, XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance) )
  1223.                             {
  1224.                                 Application->MessageBox( "cmu_mod_sample() error" , "Error", MB_OK );
  1225.                                 return false;
  1226.                             }
  1227.                             if( ! cmu_mod_xper_abort( &cmu ) )
  1228.                             {
  1229.                                 Application->MessageBox( "cmu_mod_xper_abort() error" , "Error", MB_OK );
  1230.                                 return false;
  1231.                             }
  1232.                         }
  1233.                         sprintf(buf1, "%12.6f", d_IQ_Imbalance );
  1234.                         strcat(buf, buf1);
  1235.                            // strcat(buf, "   ");
  1236.                         Sleep(50);
  1237.                         rf_stop.REQ_Start();
  1238.                     }
  1239.                     break;
  1240.                 }// switch
  1241.         }
  1242.         m_pTxIqSweep->st_Log->Add(buf);
  1243.         frmRFTool->write_TXIQ_log();
  1244.     }
  1245.     return true;
  1246. }
  1247. //----------------------------------------------------------------------------
  1248. bool __fastcall T_TXIQ_SWEEP::Phasesel_Sweep(void)
  1249. {
  1250.     int i, j;
  1251.     AnsiString as_str = Get_DataTypeStr();
  1252.     as_str = "Output data type: " + as_str;
  1253.     sprintf(buf, as_str.c_str());
  1254.     m_pTxIqSweep->st_Log->Add(buf);
  1255.     frmRFTool->write_TXIQ_log();
  1256.     sprintf(buf, "TrimI = %d, TrimQ = %d, OffsetI = %d, OffsetQ = %d",
  1257.             m_pTxIqSweep->trim_i, m_pTxIqSweep->trim_q, m_pTxIqSweep->offset_i, m_pTxIqSweep->offset_q);
  1258.     m_pTxIqSweep->st_Log->Add(buf);
  1259.     frmRFTool->write_TXIQ_log();
  1260.     buf[0]='';
  1261.     sprintf(buf1, "PhaseSel");
  1262.     strcat(buf, buf1);
  1263.    // for (i=m_pTxIqSweep->sc_min_phasesel; i<=m_pTxIqSweep->sc_max_phasesel; i+=m_pTxIqSweep->c_phasesel_step)
  1264.    // {
  1265.    //     //if (j==m_pTxIqSweep->min_offset_q)
  1266.    //     //{
  1267.    //     //    sprintf(buf1, "%5d", j);
  1268.    //     //}
  1269.    //     //else
  1270.    //     {
  1271.    //         sprintf(buf1, "%12d", i);
  1272.    //     }
  1273.    //     strcat(buf, buf1);
  1274.    // }
  1275.     m_pTxIqSweep->st_Log->Add(buf);
  1276.     frmRFTool->write_TXIQ_log();
  1277.     m_sBbTxCfg.TxTrimI   = m_pTxIqSweep->trim_i;
  1278.     m_sBbTxCfg.TxTrimQ   = m_pTxIqSweep->trim_q;
  1279.     m_sBbTxCfg.TxOffsetI = m_pTxIqSweep->offset_i;
  1280.     m_sBbTxCfg.TxOffsetQ = m_pTxIqSweep->offset_q;
  1281.     for (i=m_pTxIqSweep->sc_min_phasesel; i<=m_pTxIqSweep->sc_max_phasesel; i+=m_pTxIqSweep->c_phasesel_step)
  1282.     {
  1283.         buf[0]='';
  1284.         sprintf(buf1, "%4d", i );
  1285.         strcat(buf, buf1);
  1286.         strcat(buf, "     ");
  1287.         m_sBbTxCfg.TxPhasesel = i;
  1288.         m_cTXIQ_RUN_Obj.ConfirmCallback = ::CNF_TXIQ_Sweep;
  1289.         m_cTXIQ_RUN_Obj.REQ_SetBBTxCfg_Start(m_pTxIqSweep->e_bbtxcfg_ver, m_sBbTxCfg);
  1290.         this->Suspend();
  1291.         if (m_cTXIQ_RUN_Obj.Get_ConfirmState() != METAAPP_SUCCESS)
  1292.         {
  1293.             SyncShowMsg("Set BBTXCfg parameter to target fail");
  1294.             return false;
  1295.         }
  1296.         if (this->Terminated)
  1297.         {
  1298.             this->OnTerminate = neByUser;
  1299.             return false;
  1300.         }
  1301.         Sleep(50);
  1302.         rf_tx_level_req.arfcn = m_pTxIqSweep->s_arfcn;
  1303.         rf_tx_level_req.bsic  =  m_pTxIqSweep->tsc;
  1304.         rf_tx_level_req.power    = m_pTxIqSweep->pcl;
  1305.         rf_tx_level_req.frames   = -99;
  1306.         rf_tx_level_req.dacValue = m_pTxIqSweep->s_afc_dac;
  1307.         rf_tx_level_req.burstTypeNB = m_pTxIqSweep->e_burst_type;
  1308.         if (META_Rf_NB_TX_r(m_META_HANDLE_Obj.Get_MainHandle(),
  1309.                             &rf_tx_level_req,
  1310.                             ::cb_rf_tx_level_TrOff,
  1311.                             &rf_tx_level_token,
  1312.                             NULL
  1313.                             ) != META_SUCCESS)
  1314.         {
  1315.             return false;
  1316.         }
  1317.         this->Suspend();
  1318.         switch (m_pTxIqSweep->e_output_data_type)
  1319.         {
  1320.             case TXIQ_OUTPUT_DATA_TYPE_PHERR:
  1321.             {
  1322.                 if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  1323.                 {
  1324.                     if (GMSK == m_pTxIqSweep->e_modulation)
  1325.                     {
  1326.                         if (age1960_initMeasFcn(vi, age1960_PFER) != VI_SUCCESS)
  1327.                         {
  1328.                             age1960_error_message(vi, vistat, errmsg);
  1329.                             AnsiString as_error_msg;
  1330.                             as_error_msg = (AnsiString) errmsg;
  1331.                             SyncShowMsg(as_error_msg);
  1332.                             return false;
  1333.                         }
  1334.                         Sleep(50);
  1335.                         if (age1960_fetchPFER_Q(vi,
  1336.                                                 &PFERIntegrity,
  1337.                                                 &PFERRMSError,
  1338.                                                 &PFERPeakError,
  1339.                                                 &PFERFreqError
  1340.                                                 )!= VI_SUCCESS)
  1341.                         {
  1342.                                 SyncShowMsg("age1960_fetchPFER_Q() error");
  1343.                                 return false;
  1344.                         }
  1345.                     }
  1346.                     else // EPSK
  1347.                     {
  1348.                             if (age1968A_Fetch_EPSK_Average_PhaseError(vi, &PFERRMSError) != VI_SUCCESS)
  1349.                             {
  1350.                                 SyncShowMsg("Agilent 8960 fetch EPSK average phase error fail");
  1351.                                 return false;
  1352.                             }
  1353.                     }
  1354.                 }
  1355.                 else
  1356.                 {
  1357.                         if(! cmu_mod_init(&cmu))
  1358.                         {
  1359.                             SyncShowMsg("cmu_mod_init() error");
  1360.                             return false;
  1361.                         }
  1362.                         if (!cmu_mod_sample(&cmu, PH_ERR_RMS_AVERAGE, &PFERRMSError))
  1363.                         {
  1364.                              SyncShowMsg("cmu_mod_sample() error");
  1365.                              return false;
  1366.                         }
  1367.                         if( ! cmu_mod_abort( &cmu ) )
  1368.                         {
  1369.                             SyncShowMsg("cmu_mod_abort() error");
  1370.                             return false;
  1371.                         }
  1372.                 }
  1373.                 sprintf(buf1, "%12.4f", PFERRMSError );
  1374.                 strcat(buf, buf1);
  1375.                 Sleep(50);
  1376.                 rf_stop.REQ_Start();
  1377.             }
  1378.             break;
  1379.             case TXIQ_OUTPUT_DATA_TYPE_OOS:
  1380.             {
  1381.                 ViReal64 d_Original_Offset;
  1382.                 if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  1383.                 {
  1384.                     if (GMSK == m_pTxIqSweep->e_modulation)
  1385.                     {
  1386.                         if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
  1387.                         {
  1388.                             age1960_error_message(vi, vistat, errmsg);
  1389.                             AnsiString as_error_msg;
  1390.                             as_error_msg = (AnsiString) errmsg;
  1391.                             SyncShowMsg(as_error_msg);
  1392.                             return false;
  1393.                         }
  1394.                         if (age1960_fetchIQTuning_Q(vi,
  1395.                                                     age1960_IQ_ARRAY_MIN,
  1396.                                                     &IQTIntegrity,
  1397.                                                     &IQTSpurFreq,
  1398.                                                     &IQTSpurLevel,
  1399.                                                     IQTResultsArray,
  1400.                                                     IQTFreqsArray,
  1401.                                                     &IQTTuningCount
  1402.                                                     ) != VI_SUCCESS)
  1403.                         {
  1404.                             age1960_error_message(vi, vistat, errmsg);
  1405.                             AnsiString as_error_msg;
  1406.                             as_error_msg = (AnsiString) errmsg;
  1407.                             SyncShowMsg(as_error_msg.c_str());
  1408.                             SyncShowMsg(" Agilent 8960 fetch IQ tunning fail ");
  1409.                             return false;
  1410.                         }
  1411.                         d_Original_Offset = get_Original_Offset(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1412.                         if (NAN == d_Original_Offset)
  1413.                         {
  1414.                             return false;
  1415.                         }
  1416.                     }
  1417.                     else // EPSK
  1418.                     {
  1419.                             if (age1968A_Fetch_EPSK_Average_OrignalOffset(vi, &d_Original_Offset) != VI_SUCCESS)
  1420.                             {
  1421.                                 SyncShowMsg("Agilent 8960 fetch EPSK average original offset fail ");
  1422.                                 return false;
  1423.                             }
  1424.                     }
  1425.                 }
  1426.                 else // CMU200
  1427.                 {
  1428.                         if (!cmu_mod_xper_init(&cmu))
  1429.                         {
  1430.                             SyncShowMsg("cmu_mod_xper_init() error");
  1431.                             return false;
  1432.                         }
  1433.                         if (!cmu_mod_xper_sample(&cmu, XPER_ORIGINAL_OFFSET_AVERAGE, &d_Original_Offset) )
  1434.                         {
  1435.                             SyncShowMsg("cmu_mod_sample() error");
  1436.                             return false;
  1437.                         }
  1438.                         if (!cmu_mod_xper_abort(&cmu))
  1439.                         {
  1440.                             SyncShowMsg("cmu_mod_xper_abort() error");
  1441.                             return false;
  1442.                         }
  1443.                 }
  1444.                 sprintf(buf1, "%12.6f", d_Original_Offset );
  1445.                 strcat(buf, buf1);
  1446.                            // strcat(buf, "   ");
  1447.                 Sleep(50);
  1448.                 rf_stop.REQ_Start();
  1449.             }
  1450.             break;
  1451.             case TXIQ_OUTPUT_DATA_TYPE_SBS:
  1452.             {
  1453.                 ViReal64 d_IQ_Imbalance;
  1454.                 if (AGILENT_8960 == m_pTxIqSweep->e_device_type)
  1455.                 {
  1456.                     if (GMSK == m_pTxIqSweep->e_modulation)
  1457.                     {
  1458.                         if (age1960_initMeasFcn(vi, age1960_IQTUNING) != VI_SUCCESS)
  1459.                         {
  1460.                             age1960_error_message(vi, vistat, errmsg);
  1461.                             AnsiString as_error_msg;
  1462.                             as_error_msg = (AnsiString) errmsg;
  1463.                             SyncShowMsg(as_error_msg.c_str());
  1464.                             SyncShowMsg("Agilent 8960 initialize measure function (IQTUNING) fail ");
  1465.                             return false;
  1466.                         }
  1467.                         if (age1960_fetchIQTuning_Q(vi,
  1468.                                                         age1960_IQ_ARRAY_MIN,
  1469.                                                         &IQTIntegrity,
  1470.                                                         &IQTSpurFreq,
  1471.                                                         &IQTSpurLevel,
  1472.                                                         IQTResultsArray,
  1473.                                                         IQTFreqsArray,
  1474.                                                         &IQTTuningCount
  1475.                                                         ) != VI_SUCCESS)
  1476.                         {
  1477.                                 age1960_error_message(vi, vistat, errmsg);
  1478.                                 AnsiString as_error_msg;
  1479.                                 as_error_msg = (AnsiString) errmsg;
  1480.                                 SyncShowMsg(as_error_msg.c_str());
  1481.                                 SyncShowMsg(" Agilent 8960 fetch IQ tunning fail ");
  1482.                                     return false;
  1483.                         }
  1484.                         d_IQ_Imbalance = get_IQ_Imbalance(IQTFreqsArray, IQTResultsArray, IQTTuningCount);
  1485.                         if (NAN == d_IQ_Imbalance)
  1486.                         {
  1487.                                 return false;
  1488.                         }
  1489.                     }
  1490.                     else // EPSK
  1491.                     {
  1492.                             if (age1968A_Fetch_EPSK_Average_IQImbalance(vi, &d_IQ_Imbalance) != VI_SUCCESS)
  1493.                             {
  1494.                                 SyncShowMsg("Agilent 8960 fetch EPSK average IQ imbalance fail");
  1495.                                 return false;
  1496.                             }
  1497.                     }
  1498.                 }
  1499.                 else
  1500.                 {
  1501.                         if (!cmu_mod_xper_init(&cmu))
  1502.                         {
  1503.                             SyncShowMsg( "cmu_mod_xper_init() error");
  1504.                             return false;
  1505.                         }
  1506.                         if (!cmu_mod_xper_sample(&cmu, XPER_IQ_IMBALANCE_AVERAGE, &d_IQ_Imbalance))
  1507.                         {
  1508.                             SyncShowMsg("cmu_mod_sample() error");
  1509.                             return false;
  1510.                         }
  1511.                         if (!cmu_mod_xper_abort(&cmu))
  1512.                         {
  1513.                             SyncShowMsg("cmu_mod_xper_abort() error");
  1514.                             return false;
  1515.                         }
  1516.                 }
  1517.                 sprintf(buf1, "%12.6f", d_IQ_Imbalance);
  1518.                 strcat(buf, buf1);
  1519.                            // strcat(buf, "   ");
  1520.                 Sleep(50);
  1521.                 rf_stop.REQ_Start();
  1522.             }
  1523.             break;
  1524.         }// switch
  1525.         m_pTxIqSweep->st_Log->Add(buf);
  1526.         frmRFTool->write_TXIQ_log();
  1527.     }
  1528.     return true;
  1529. }
  1530. //----------------------------------------------------------------------------
  1531. AnsiString __fastcall T_TXIQ_SWEEP::Get_DataTypeStr(void)
  1532. {
  1533.     AnsiString as_str;
  1534.     switch (m_pTxIqSweep->e_output_data_type)
  1535.     {
  1536.         case TXIQ_OUTPUT_DATA_TYPE_PHERR:
  1537.         {
  1538.              as_str = "phase error";
  1539.         }
  1540.         break;
  1541.         case TXIQ_OUTPUT_DATA_TYPE_OOS:
  1542.         {
  1543.              as_str = "original offset";
  1544.         }
  1545.         break;
  1546.         case TXIQ_OUTPUT_DATA_TYPE_SBS:
  1547.         {
  1548.              as_str = "IQ imbalance";
  1549.         }
  1550.         break;
  1551.     }
  1552.     return as_str;
  1553. }
  1554. //----------------------------------------------------------------------------
  1555. void T_TXIQ_SWEEP::CNF_TXIQ_Sweep(void)
  1556. {
  1557.     this->Resume();
  1558. }