T_Init_Age8960.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:20k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * T_Init_Age8960.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Equipement thread source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "man_dll.h"
- #include "META_Factory.h"
- #include "t_init_age8960.h"
- #include "meta_utils.h"
- #include "meta_factory_cfg.h"
- // equipment
- #include "ageCommon.h"
- #include "age1968A.h"
- //#ifndef hpe3631a_INCLUDE
- //#include "hpe3631a.h"
- //#endif
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- // Important: Methods and properties of objects in VCL can only be
- // used in a method called using Synchronize, for example:
- //
- // Synchronize(UpdateCaption);
- //
- // where UpdateCaption could look like:
- //
- // void __fastcall Unit1::UpdateCaption()
- // {
- // Form1->Caption = "Updated in a thread";
- // }
- //---------------------------------------------------------------------------
- bool is_Age8960_start = false;
- bool is_age1960_fail = false;
- bool is_AgilentPowerSupply_fail = false;
- // added by Andy Ueng for ADC calibration
- bool IS_AgilentPowerSupply_INITIALISE = false;
- // end of added
- //------------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- //R&S
- #include "cmu200.h"
- #include "K2302.h"
- extern K2302_VAR k2302;
- CMU_VAR cmu;
- //------------------------------------------------------------------------------
- void _fastcall T_Init_Age8960::ShowMsg()
- {
- ShowMessage( as_Msg );
- }
- //------------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- void _fastcall T_Init_Age8960::SyncShowMsg(AnsiString as)
- {
- as_Msg = as;
- Synchronize( ShowMsg );
- }
- //------------------------------------------------------------------------------
- __fastcall T_Init_Age8960::T_Init_Age8960(
- bool CreateSuspended,
- AnsiString as_ADDR,
- AnsiString as_Agilent_Power_Supply_addr,
- int i_TimeOut,
- signed short ss_Band,
- TNotifyEvent ne_OnTermHandler,
- ViSession &vs_Age196x,
- ViSession &vs_AgePowerSupply, // for ADC calibration
- TMETA_factory_cfg *cfg,
- TStringList *st_Log,
- AnsiString &as_TaModel
- )
- : TThread(CreateSuspended)
- {
- as_RF_Equipment_ADDR = as_ADDR;
- as_AGE8960_ADDR = as_ADDR;
- as_Agilent_Power_Supply_ADDR = as_Agilent_Power_Supply_addr;
- i_AGE8960_TimeOut = i_TimeOut;
- ss_CellBand = ss_Band;
- ne_OnTerminate = ne_OnTermHandler;
- pvi_Age196x = &vs_Age196x;
- pvi_AgePowerSupply = &vs_AgePowerSupply; // for ADC calibration
- MF_cfg = cfg;
- log = st_Log; // for log
- as_pAgeTaModel = &as_TaModel;
- is_Age8960_start = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall T_Init_Age8960::Execute()
- {
- //////////////////////////// RF calibration ///////////////////////////////////////
- if( Form_META_Factory->cbAFC->Checked || Form_META_Factory->cbRxPathLoss->Checked || Form_META_Factory->cbIP2->Checked ||
- Form_META_Factory->cbTxPcl->Checked || Form_META_Factory->cbTxPhaseError->Checked )
- {
- if ( Form_META_Factory->rbAgilent8960->Checked )
- {
- if ((vistat = age1960_init( as_AGE8960_ADDR.c_str(), 0, 0, &vi_Age196x)) != VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Initialize Agilent 8960 fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < Initialize (init)"
- );
- return;
- }
- if ( (vistat = age_QueryTaModel( vi_Age196x, as_pAgeTaModel )) != VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Query Agilent 8960 TA Model fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < Query Agilent 8960 TA Model (init)"
- );
- return;
- }
- //////////////////////////////////////////////////////////////////////////////
- Sleep(50);
- if ( vi_Age196x != VI_NULL)
- {
- if ( age1960_dcl(vi_Age196x)!= VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Agilent 8960 DCL fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < DCL (init)"
- );
- return;
- }
- }
- Sleep(50);
- if ( vi_Age196x != VI_NULL)
- {
- if ((vistat = age1960_reset( vi_Age196x )) != VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Reset Agilent 8960 fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < reset (init) "
- );
- return;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- if ((vistat = age1960_timeOut (
- vi_Age196x,
- i_AGE8960_TimeOut
- )) != VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Agilent 8960 set timeout fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < set timeout (init)"
- );
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- /*
- ViStatus _VI_FUNC age1960_amplitudeOffset(ViSession instrumentHandle, ViReal64 frequencyArray
- [燷, ViReal64 offsetArray[燷, ViInt32 ampOffsetItems);
- */
- const AMP_OFFSET_ITEMS = 10;
- ViReal64 freqArray[AMP_OFFSET_ITEMS] = { 400000000.0,
- 641000000.0,
- 641100000.0,
- 876000000.0,
- 876100000.0,
- 1312000000.0,
- 1312100000.0,
- 1880000000.0,
- 1881000000.0,
- 2000000000.0 };
- // ViReal64 offsetArray[AMP_OFFSET_ITEMS] = { d_dB_CableLoss, d_dB_CableLoss };
- double d400,d850,d900,d1800,d1900;
- if((! MF_cfg->getGSM400_CableLoss( d400 )) ||
- (! MF_cfg->getGSM850_CableLoss( d850 )) ||
- (! MF_cfg->getGSM900_CableLoss( d900 )) ||
- (! MF_cfg->getDCS1800_CableLoss( d1800 )) ||
- (! MF_cfg->getPCS1900_CableLoss( d1900 ))
- )
- {
- //SyncShowMsg("Agilent 8960 read config file cable loss fail");
- Application->MessageBox( " Agilent 8960 read config file (cable loss) fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < read config file (cable loss) (init)"
- );
- return;
- }
- ViReal64 offsetArray[AMP_OFFSET_ITEMS] = { d400,
- d400,
- d850,
- d850,
- d900,
- d900,
- d1800,
- d1800,
- d1900,
- d1900
- };
- if ((vistat = age1960_amplitudeOffset (
- vi_Age196x,
- freqArray,
- offsetArray,
- AMP_OFFSET_ITEMS
- )) != VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Agilent 8960 set cable loss fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < set cable loss (init)"
- );
- return;
- }
- /////////////////////////////////////////////////////////////////////////////
- if( as_pAgeTaModel->AnsiCompareIC( "E1968A" ) == 0 || as_pAgeTaModel->AnsiCompareIC( "E6701C" ) == 0 || as_pAgeTaModel->AnsiCompareIC( "E6701D" ) == 0 )
- {
- if ((vistat = age1968A_operatingMode(
- vi_Age196x,
- (ViInt16) OPERATING_MODE_GSM_BCH_TCH
- ))!= VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Agilent 8960 set operation mode fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < set opeartion mode (init)"
- );
- return;
- }
- }
- else // Agilent 1960A
- {
- if ((vistat = age1960_operatingMode(
- vi_Age196x,
- (ViInt16) age1960_TEST_MODE
- ))!= VI_SUCCESS)
- {
- is_age1960_fail = true;
- Application->MessageBox( " Agilent 8960 set operation mode fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < set opeartion mode (init)"
- );
- return;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- /*
- if ((vistat = age1960_cellBand(
- vi,
- age1960_CELL_1,
- // (short)( cbox_Cell_Band->ItemIndex+1)
- ss_CellBand
- ))!= VI_SUCCESS)
- {
- //SyncShowMsg("Agilent 8960 set Cell Band fail");
- Application->MessageBox( " Agilent 8960 set cell band fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 8960 < set cell band (init)"
- );
- return;
- }
- */
- _VI_PTR pvi_Age196x = vi_Age196x;
- } // Agilent 8960
- else // CMU 200
- {
- double d400,d850,d900,d1800,d1900,Out400,Out850,Out900,Out1800,Out1900;
- if((! MF_cfg->getCMU200_INPUT_GSM400_CableLoss( d400 )) ||
- (! MF_cfg->getCMU200_INPUT_GSM850_CableLoss( d850 )) ||
- (! MF_cfg->getCMU200_INPUT_GSM900_CableLoss( d900 )) ||
- (! MF_cfg->getCMU200_INPUT_DCS1800_CableLoss( d1800 )) ||
- (! MF_cfg->getCMU200_INPUT_PCS1900_CableLoss( d1900 )) )
- {
- Application->MessageBox( "CMU 200 read config file cable loss fail", "Fail", MB_OK );
- return;
- }
- if((! MF_cfg->getCMU200_OUTPUT_GSM400_CableLoss( Out400 )) ||
- (! MF_cfg->getCMU200_OUTPUT_GSM850_CableLoss( Out850 )) ||
- (! MF_cfg->getCMU200_OUTPUT_GSM900_CableLoss( Out900 )) ||
- (! MF_cfg->getCMU200_OUTPUT_DCS1800_CableLoss( Out1800 )) ||
- (! MF_cfg->getCMU200_OUTPUT_PCS1900_CableLoss( Out1900 )) )
- {
- Application->MessageBox( "CMU 200 read config file cable loss fail", "Fail", MB_OK );
- return;
- }
- cmu.loss_gsm850_i=d850;
- cmu.loss_gsm850_o=Out850;
- cmu.loss_gsm_i=d900;
- cmu.loss_gsm_o=Out900;
- cmu.loss_dcs_i=d1800;
- cmu.loss_dcs_o=Out1800;
- cmu.loss_pcs_i=d1900;
- cmu.loss_pcs_o=Out1900;
- cmu.ADD=as_RF_Equipment_ADDR.SubString(0, as_RF_Equipment_ADDR.Pos("::INSTR")-1);
- cmu.TMO=i_AGE8960_TimeOut;
- cmu.BAND="GSM";
- if( !cmu_init(&cmu) )
- {
- Application->MessageBox( "Initial CMU200 fail", "Fail", MB_OK );
- return;
- }
- Sleep(1500);
- _VI_PTR pvi_Age196x = vi_Age196x;
- }
- } // RF calibration checked
- /////////////////////// ADC calibration /////////////////////////////////////
- if (m_pCal->s_CalItem.b_adc_cal)
- {
- if( Form_META_Factory->rbAgilent661x->Checked )
- {
- if((vistat = hp661x_init( as_Agilent_Power_Supply_ADDR.c_str(), 0, 0, &vi_AgePowerSupply)) != VI_SUCCESS)
- {
- is_AgilentPowerSupply_fail = true;
- Application->MessageBox( " Initialize Agilent 661x fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 661x < initialize (init)"
- );
- return;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 661x ok < initialize (init)"
- );
- }
- else if ( Form_META_Factory->rbAgilent663x2->Checked )
- {
- if((vistat = hp663x2_init(as_Agilent_Power_Supply_ADDR.c_str(), 0, 0, &vi_AgePowerSupply)) != VI_SUCCESS)
- {
- is_AgilentPowerSupply_fail = true;
- Application->MessageBox( " Initialize Agilent 663x2 fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 663x2 < initialize (init)"
- );
- return;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent 663x2 ok < initialize (init)"
- );
- }
- else if ( Form_META_Factory->rbAgilentE3631A->Checked )
- {
- if((vistat = hpe3631a_init(as_Agilent_Power_Supply_ADDR.c_str(), 0, 0, &vi_AgePowerSupply)) != VI_SUCCESS)
- {
- is_AgilentPowerSupply_fail = true;
- Application->MessageBox( " Initialize Agilent E3631A fail ", "Fail", MB_OK );
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent E3631A < initialize (init)"
- );
- return;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Agilent E3631A ok < initialize (init)"
- );
- }
- IS_AgilentPowerSupply_INITIALISE = true;
- _VI_PTR pvi_AgePowerSupply = vi_AgePowerSupply;
- }
- ///////////////////// RF or ADC calibration //////////////////////////////////
- if( Form_META_Factory->cbAFC->Checked || Form_META_Factory->cbRxPathLoss->Checked || Form_META_Factory->cbIP2->Checked ||
- Form_META_Factory->cbTxPcl->Checked || Form_META_Factory->cbTxPhaseError->Checked ||
- m_pCal->s_CalItem.b_adc_cal
- )
- {
- this->OnTerminate = ne_OnTerminate;
- (void)vistat;
- }
- }
- //---------------------------------------------------------------------------