form_RFCTBBTXRun.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:30k
- /*****************************************************************************
- * 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:
- * ---------
- * form_RFCTBBTX.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF continuous TX BB TX form 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
- // form
- #include "form_RFTool.h"
- #include "form_main.h"
- #ifndef _FORM_RFCTBBTXRUN_H_
- #include "form_RFCTBBTXRun.h"
- #endif
- #include "rf_common.h"
- #include "misc.h"
- #ifndef _RF_CT_RUN_THRD_H_
- #include "rf_ct_run_thrd.h"
- #endif
- #ifndef _META_LAB_MSG_H_
- #include "meta_lab_msg.h"
- #endif
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TfrmCTBBTXRunTimeSetting *frmCTBBTXRunTimeSetting;
- //static int Default_ARFCN[4] = { 0, 512, 512, 128 };
- // BB TX parameters
- //T_RFCTRUN* pt_rf_ctrun;
- //==============================================================================
- static void ConfirmCallback_CT( void )
- { frmCTBBTXRunTimeSetting->ConfirmCallback_CT();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_GetBBTxCfg(void)
- {
- frmCTBBTXRunTimeSetting->ConfirmCallback_GetBBTxCfg();
- }
- //--------------------------------------------------------------------------
- static void CNF_SetBBTxCfg(void)
- {
- //frmCTBBTXRunTimeSetting->CNF_SetBBTxCfg();
- }
- //============================================================================
- __fastcall TfrmCTBBTXRunTimeSetting::TfrmCTBBTXRunTimeSetting(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::Init( void )
- {
- m_bInit = true;
- }
- //----------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::FormCreate(TObject *Sender)
- {
- WindowProc = SubClassWndProc;
- Init();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::FormActivate(TObject *Sender)
- {
- if (m_bInit)
- {
- m_bInit = false;
- // BBTXCfg
- BBCHIP_TYPE bb_chip = frmMainSel->Get_FinalBBChip();
- m_eBbTxCfgVer = m_pcRF_TXIQRUN_Obj->Query_BBTxCfgVer_Start(bb_chip);
- if (m_eBbTxCfgVer >= BBTXCFG_VER3)
- {
- lblCTBBTXPhasesel->Visible = true;
- lblCTBBTXPhasesel->Visible = true;
- }
- else
- {
- lblCTBBTXPhasesel->Visible = false;
- lblCTBBTXPhasesel->Visible = false;
- }
- // CT support level
- m_eCtSupport = frmRFTool->Get_CtSupport();
- if (CT_SUPPORT_0 == m_eCtSupport)
- {
- lblTXModulation->Visible = false;
- cbTXModulation->Visible = false;
- rbCTPattern->Visible = false;
- edtCTPattern->Visible = false;
- lblPCL->Visible = false;
- edtPCL->Visible = false;
- }
- else if (CT_SUPPORT_1 == m_eCtSupport)
- {
- lblTXModulation->Visible = true;
- cbTXModulation->Visible = true;
- rbCTPattern->Visible = true;
- edtCTPattern->Visible = true;
- lblPCL->Visible = false;
- edtPCL->Visible = false;
- }
- else
- {
- lblTXModulation->Visible = true;
- cbTXModulation->Visible = true;
- rbCTPattern->Visible = true;
- edtCTPattern->Visible = true;
- lblPCL->Visible = true;
- edtPCL->Visible = true;
- }
- }
- }
- //==============================================================================
- void _fastcall TfrmCTBBTXRunTimeSetting::SubClassWndProc( Messages::TMessage &Message)
- {
- switch ( Message.Msg )
- {
- // case WM_ML_QUERY_BBTXCFG3SUPPPORT_SUCCESS:
- // m_bBBTXCfg3Support = true;
- // lblCTBBTXPhasesel->Visible = true;
- // edtCTBBTXPhasesel->Visible = true;
- // break;
- // case WM_ML_QUERY_BBTXCFG3SUPPPORT_FAILED:
- // m_bBBTXCfg3Support = false;
- // lblCTBBTXPhasesel->Visible = false;
- // edtCTBBTXPhasesel->Visible = false;
- // break;
- default:
- this->WndProc( Message );
- break;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::ConfirmCallback_CT(void)
- {
- E_METAAPP_RESULT_T state = m_pcRF_CT_Obj->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Continuous TX progressing";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Continuous TX fail";
- Application->MessageBox("Execution Failure : Continue TX", "FAILURE", MB_OK);
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Continuous TX timeout";
- Application->MessageBox("Execution Timeout : Continue TX", "TIMEOUT", MB_OK);
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Continuous TX stop";
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::btnCTStartClick(TObject *Sender)
- {
- if (1 == btnCTStart->Tag)
- {
- return;
- }
- if (!CheckBbTxCfgFields())
- {
- return;
- }
- m_eCurBand = (E_BANDSEL) cbxCTBand->ItemIndex;
- CurrentPageLock();
- m_pcRF_TXIQRUN_Obj->ConfirmCallback = ::CNF_SetBBTxCfg;
- m_pcRF_TXIQRUN_Obj->REQ_SetBBTxCfg_Start(m_eBbTxCfgVer, m_sBbTxCfg);
- sbCT->Panels->Items[0]->Text = (AnsiString)" Continuous TX processing";
- }
- //---------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::CNF_SetBBTxCfg(void)
- {
- E_METAAPP_RESULT_T state = m_pcRF_TXIQRUN_Obj->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- S_RF_CT rf_ct;
- AnsiString text;
- // band
- rf_ct.e_band = (E_BANDSEL) cbxCTBand->ItemIndex;
- m_eCurBand = rf_ct.e_band;
- // ARFCN
- text = edtCTArfcn->Text;
- if (!IsValidARFCN(text, rf_ct.e_band, rf_ct.s_arfcn))
- {
- edtArfcnCheck(edtCTArfcn);
- return;
- }
- // PCL
- text = edtPCL->Text;
- if (!IsValidPCL(text, rf_ct.e_band, rf_ct.i_pcl))
- {
- edtPCLCheck(edtPCL);
- return;
- }
- rf_ct.e_rf_ct_support = m_eCtSupport;
- rf_ct.i_on_off = 1 - btnCTStart->Tag;
- // pattern
- if (rbCTAll0->Checked)
- {
- rf_ct.i_pattern = CONT_TX_ALL_ZEROS;
- }
- else if (rbCTAll1->Checked)
- {
- rf_ct.i_pattern = CONT_TX_ALL_ONES;
- }
- else if (rbCTAlternate->Checked)
- {
- rf_ct.i_pattern = CONT_TX_ALTERNATE_BITS;
- }
- else if (rbCTRandom->Checked)
- {
- rf_ct.i_pattern = CONT_TX_PSEUDO_RANDOM;
- }
- else
- {
- rf_ct.i_pattern = CONT_TX_PATTERN_WITHOUT_TSC;
- }
- if (rbCTPattern->Checked)
- {
- text = edtCTPattern->Text; if( !IsValidCTPattern( text, rf_ct.us_pattern_data ) ) { edtCTPatternCheck(edtCTPattern); return; }
- }
- if (0 == cbTXModulation->ItemIndex) // GMSK
- {
- rf_ct.us_modtype = 0;
- }
- else
- {
- rf_ct.us_modtype = 1;
- }
- CurrentPageLock();
- m_pcRF_CT_Obj->ConfirmCallback = ::ConfirmCallback_CT;
- m_pcRF_CT_Obj->REQ_Start(rf_ct);
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Set BB TX run time setting fail";
- Application->MessageBox( "Execution Failure : Set BB TX run time setting", "FAILURE", MB_OK );
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Set BB TX run time setting timeout";
- Application->MessageBox( "Execution Timeout : Set BB TX run time setting", "TIMEOUT", MB_OK );
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Set BB TX run time setting stop";
- CurrentPageReset();
- }
- break;
- }
- }
- //===========================================================================
- bool TfrmCTBBTXRunTimeSetting::CheckBbTxCfgFields(void)
- {
- signed char tx_trim_i;
- signed char tx_trim_q;
- signed char tx_offset_i;
- signed char tx_offset_q;
- signed char tx_cal_bias;
- char tx_iq_swap;
- signed char tx_cmv;
- signed char tx_gain;
- signed char tx_calrcsel;
- signed char tx_phasesel;
- AnsiString text;
- text = edtCTTrimI->Text; if (!IsValidTrimIQ(text, tx_trim_i)) { edtTrimIQCheck(edtCTTrimI); return false; }
- m_sBbTxCfg.TxTrimI = tx_trim_i;
- text = edtCTTrimQ->Text; if (!IsValidTrimIQ(text, tx_trim_q)) { edtTrimIQCheck(edtCTTrimQ); return false; }
- m_sBbTxCfg.TxTrimQ = tx_trim_q;
- text = edtCTOffsetI->Text; if (!IsValidOffsetIQ(m_eBbTxCfgVer, text, tx_offset_i) ) { edtOffsetIQCheck(edtCTOffsetI); return false; }
- m_sBbTxCfg.TxOffsetI = tx_offset_i;
- text = edtCTOffsetQ->Text; if (!IsValidOffsetIQ(m_eBbTxCfgVer, text, tx_offset_q) ) { edtOffsetIQCheck(edtCTOffsetQ); return false; }
- m_sBbTxCfg.TxOffsetQ = tx_offset_q;
- text = edtCTTXCalbias->Text; if (!IsValidTxCalbias(m_eBbTxCfgVer, text, tx_cal_bias)) { edtBBTXCalbiasCheck(edtCTTXCalbias); return false; }
- m_sBbTxCfg.TxCalbias = tx_cal_bias;
- text = edtCTTXIQSwap->Text; if (!IsValidTxIQSwap(text, tx_iq_swap)) { edtBBTXIQSwapCheck(edtCTTXIQSwap); return false; }
- m_sBbTxCfg.TxIQSwap = tx_iq_swap;
- text = edtCTCMV->Text; if (!IsValidBBTXCommonModeVoltage(text, tx_cmv)) { edtBBTXCommonModeVoltageCheck(edtCTCMV); return false; }
- m_sBbTxCfg.TxCMV = tx_cmv;
- text = edtCTBBTXGain->Text; if (!IsValidBBTXGain(text, tx_gain) ) { edtBBTXGainCheck(edtCTBBTXGain); return false; }
- m_sBbTxCfg.TxGain = tx_gain;
- text = edtCTBBTXCalrcsel->Text; if (!IsValidBBTXCalrcsel(text, tx_calrcsel)) { edtCTBBTXCalrcselCheck(edtCTBBTXCalrcsel); return false; }
- m_sBbTxCfg.TxCalrcsel = tx_calrcsel;
- if (edtCTBBTXPhasesel->Visible)
- {
- text = edtCTBBTXPhasesel->Text; if (!IsValidBBTXPhasesel(m_eBbTxCfgVer, text, tx_phasesel)) { edtCTBBTXPhaseselCheck(edtCTBBTXPhasesel); return false; }
- m_sBbTxCfg.TxPhasesel = tx_phasesel;
- }
- return true;
- }
- //------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::CurrentPageReset( void )
- {
- cbxCTBand->Enabled = true;
- edtCTArfcn->Enabled = true;
- edtPCL->Enabled = true;
- // cbxCTPattern->Enabled = true;
- cbTXModulation->Enabled = true;
- rbCTAll0->Enabled = true;
- rbCTAll1->Enabled = true;
- rbCTAlternate->Enabled = true;
- rbCTRandom->Enabled = true;
- rbCTPattern->Enabled = true;
- edtCTPattern->Enabled = true;
- cbTXModulation->Enabled = true;
- edtCTTrimI->Enabled = true;
- edtCTTrimQ->Enabled = true;
- edtCTOffsetI->Enabled = true;
- edtCTOffsetQ->Enabled = true;
- edtCTTXCalbias->Enabled = true;
- edtCTTXIQSwap->Enabled = true;
- edtCTCMV->Enabled = true;
- edtCTBBTXGain->Enabled = true;
- edtCTBBTXCalrcsel->Enabled = true;
- edtCTBBTXPhasesel->Enabled = true;
- btnCTStart->Enabled = true;
- btnCTStart->Tag = 0;
- btnLoadFromReg->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::CurrentPageLock( void )
- {
- cbxCTBand->Enabled = false;
- edtCTArfcn->Enabled = false;
- edtPCL->Enabled = false;
- cbTXModulation->Enabled = false;
- rbCTAll0->Enabled = false;
- rbCTAll1->Enabled = false;
- rbCTAlternate->Enabled = false;
- rbCTRandom->Enabled = false;
- rbCTPattern->Enabled = false;
- edtCTPattern->Enabled = false;
- edtCTTrimI->Enabled = false;
- edtCTTrimQ->Enabled = false;
- edtCTOffsetI->Enabled = false;
- edtCTOffsetQ->Enabled = false;
- edtCTTXCalbias->Enabled = false;
- edtCTTXIQSwap->Enabled = false;
- edtCTCMV->Enabled = false;
- edtCTBBTXGain->Enabled = false;
- edtCTBBTXCalrcsel->Enabled = false;
- edtCTBBTXPhasesel->Enabled = false;
- btnCTStart->Enabled = false;
- btnCTStart->Tag = 1;
- btnLoadFromReg->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::ReDrawFields(void)
- {
- edtCTTrimI->Text = IntToStr(m_sBbTxCfg.TxTrimI);
- edtCTTrimQ->Text = IntToStr(m_sBbTxCfg.TxTrimQ);
- edtCTOffsetI->Text = IntToStr(m_sBbTxCfg.TxOffsetI);
- edtCTOffsetQ->Text = IntToStr(m_sBbTxCfg.TxOffsetQ);
- edtCTTXCalbias->Text = IntToStr(m_sBbTxCfg.TxCalbias);
- edtCTTXIQSwap->Text = IntToStr(m_sBbTxCfg.TxIQSwap);
- edtCTCMV->Text = IntToStr(m_sBbTxCfg.TxCMV);
- edtCTBBTXGain->Text = IntToStr(m_sBbTxCfg.TxGain);
- edtCTBBTXCalrcsel->Text = IntToStr(m_sBbTxCfg.TxCalrcsel);
- if (m_eBbTxCfgVer >= BBTXCFG_VER3)
- {
- edtCTBBTXPhasesel->Text = IntToStr(m_sBbTxCfg.TxPhasesel);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtArfcnCheck(TObject *Sender)
- {
- short sdata;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[][256] =
- {
- " value shall be 0~124 or 975~1023 ",
- " value shall be 512~885 ",
- " value shall be 512~810 ",
- " value shall be 128~251 ",
- };
- text = edit->Text;
- if (!IsValidARFCN(text, m_eCurBand, sdata))
- {
- edit->Text = IntToStr(Default_ARFCN[m_eCurBand]);
- ShowHintLabel(edit, hint[m_eCurBand]);
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::ShowHintLabel( TControl *sender, char* hint )
- {
- TPoint pt0 = this->ClientOrigin;
- TPoint pt1 = sender->ClientOrigin;
- lblHint->Left = (pt1.x-pt0.x);
- lblHint->Top = (pt1.y-pt0.y)+sender->Height+3;
- lblHint->Caption = hint;
- lblHint->Visible = true;
- HintTimer->Enabled = true;
- }
- //-----------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::HintTimerTimer(TObject *Sender)
- {
- HintTimer->Enabled = false;
- lblHint->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::cbxCTBandChange(TObject *Sender)
- {
- TEdit *edit;
- short sdata;
- if (!frmMainSel->cbGSM850->Checked)
- {
- if (BANDSEL_GSM850 == (E_BANDSEL) ((TComboBox*)Sender)->ItemIndex)
- {
- ((TComboBox*)Sender)->ItemIndex = 0;
- Application->MessageBox( "Please check GSM 850 on main menu", "FAILURE", MB_OK );
- }
- }
- m_eCurBand = (E_BANDSEL) ((TComboBox*)Sender)->ItemIndex;
- edit = edtCTArfcn;
- edtArfcnCheck( edit );
- if (!IsValidARFCN(edit->Text, m_eCurBand, sdata))
- {
- edit->Text = IntToStr(Default_ARFCN[m_eCurBand]);
- }
- }
- //---------------------------------------------------------------------------
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::btnLoadFromRegClick(TObject *Sender)
- {
- CurrentPageLock();
- m_pcRF_TXIQRUN_Obj->ConfirmCallback = ::ConfirmCallback_GetBBTxCfg;
- m_pcRF_TXIQRUN_Obj->REQ_GetBBTxCfg_Start(m_eBbTxCfgVer);
- }
- //---------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::ConfirmCallback_GetBBTxCfg( void )
- {
- E_METAAPP_RESULT_T state = m_pcRF_TXIQRUN_Obj->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- RfBBTXCfg4* p_bbtxcfg = m_pcRF_TXIQRUN_Obj->Get_BbTxCfg();
- m_sBbTxCfg = *p_bbtxcfg;
- ReDrawFields();
- sbCT->Panels->Items[0]->Text = (AnsiString)" Get BB TX run time setting successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Get BB TX run time setting fail";
- Application->MessageBox( "Execution Failure : Get BB TX run time setting", "FAILURE", MB_OK );
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Get BB TX run time setting timeout";
- Application->MessageBox( "Execution Timeout : Get BB TX run time setting", "TIMEOUT", MB_OK );
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbCT->Panels->Items[0]->Text = (AnsiString)" Get BB TX run time setting stop";
- }
- break;
- }
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::btnCTLoadFromFileClick(
- TObject *Sender)
- {
- char str[512];
- bool ok;
- float fdata;
- ok = OpenDialog->Execute();
- if (!ok)
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Load BB TX run time setting from file fail";
- Application->MessageBox("Execution Failure : Load BB TX run time setting from file", "FAILURE", MB_OK);
- return;
- }
- strcpy(str, OpenDialog->FileName.c_str());
- ok = m_pcRF_TXIQRUN_Obj->REQ_Read_From_File(str, m_eBbTxCfgVer);
- if (ok)
- {
- RfBBTXCfg4* p_bbtxcfg = m_pcRF_TXIQRUN_Obj->Get_BbTxCfg();
- m_sBbTxCfg = *p_bbtxcfg;
- ReDrawFields();
- sbCT->Panels->Items[0]->Text = (AnsiString) " Load BB TX run time setting from file successfully";
- }
- else
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Load BB TX run time setting from file fail";
- Application->MessageBox("Execution Failure : Load BB TX run time setting from file", "FAILURE", MB_OK);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtTrimIQCheck(TObject *Sender)
- {
- signed char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be -8~7 ";
- text = edit->Text;
- if( !IsValidTrimIQ( text, data ) )
- {
- ShowHintLabel( edit, hint );
- edit->Text = Default_TrimIQ;
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtOffsetIQCheck(TObject *Sender)
- {
- signed char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be -32~31 ";
- text = edit->Text;
- if( !IsValidOffsetIQ(m_eBbTxCfgVer, text, data ) )
- {
- ShowHintLabel( edit, hint );
- edit->Text = Default_OffsetIQ;
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtBBTXCalbiasCheck(
- TObject *Sender)
- {
- signed char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[2][256] = {" value shall be -16~15 ", " value shall be -8~7 "};
- text = edit->Text;
- if (!IsValidTxCalbias(m_eBbTxCfgVer, text, data))
- {
- if (BBTXCFG_VER2 == m_eBbTxCfgVer)
- {
- ShowHintLabel(edit, hint[0]);
- }
- else
- {
- ShowHintLabel(edit, hint[1]);
- }
- edit->Text = Default_TxCalbias;
- edit->SetFocus();
- return;
- }
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtBBTXIQSwapCheck(
- TObject *Sender)
- {
- char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~1 ";
- text = edit->Text;
- if( !IsValidTxIQSwap( text, data ) )
- {
- ShowHintLabel( edit, hint );
- edit->Text = Default_TxIQSwap;
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtBBTXCommonModeVoltageCheck(
- TObject *Sender)
- {
- signed char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[256] =
- { " value shall be -4 ~ 3 "
- };
- text = edit->Text;
- if( !IsValidBBTXCommonModeVoltage( text, data ) )
- {
- edit->Text = IntToStr( Default_BBTXCommonModeVoltage );
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtBBTXGainCheck(TObject *Sender)
- {
- signed char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[256] =
- { " value shall be -4 ~ 3 "
- };
- text = edit->Text;
- if( !IsValidBBTXGain( text, data ) )
- {
- edit->Text = IntToStr( Default_BBTXGain );
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtCTBBTXCalrcselCheck(
- TObject *Sender)
- {
- signed char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[256] =
- { " value shall be -4 ~ 3 "
- };
- text = edit->Text;
- if( !IsValidBBTXCalrcsel( text, data ) )
- {
- edit->Text = IntToStr( Default_BBTXCalrcsel );
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::btnCTSaveToFileClick(
- TObject *Sender)
- {
- char str[512];
- bool ok;
- if (!CheckBbTxCfgFields())
- {
- return;
- }
- ok = SaveDialog->Execute();
- if (!ok)
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Save BB TX run time setting to file fail";
- Application->MessageBox( "Execution Failure : Save BB TX run time setting to file", "FAILURE", MB_OK );
- return;
- }
- strcpy(str, SaveDialog->FileName.c_str());
- m_pcRF_TXIQRUN_Obj->Set_BbTxCfg(m_sBbTxCfg);
- ok = m_pcRF_TXIQRUN_Obj->REQ_Write_To_File(str, m_eBbTxCfgVer);
- if (!ok)
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Save BB TX run time setting to file fail";
- Application->MessageBox( "Execution Failure : Save BB TX run time setting to file", "FAILURE", MB_OK );
- }
- else
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Save BB TX run time setting to file successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::btnCTStopClick(TObject *Sender)
- {
- if (btnCTStart->Tag==1)
- {
- sbCT->Panels->Items[0]->Text = (AnsiString) " Continuous TX stop";
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- return;
- }
- }
- //-------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtCTBBTXPhaseselCheck(
- TObject *Sender)
- {
- signed char data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[256] =
- { " value shall be -3 ~ 3 "
- };
- text = edit->Text;
- if (!IsValidBBTXCalrcsel(text, data))
- {
- edit->Text = IntToStr(Default_BBTXPhasesel);
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtCTPatternCheck(
- TObject *Sender)
- {
- unsigned short data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[256] =
- { " binary format and length<=16 "
- };
- text = edit->Text;
- if( !IsValidMultiSlotTxPattern( text, data ) )
- { ShowHintLabel( edit, hint);
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmCTBBTXRunTimeSetting::edtPCLCheck(TObject *Sender)
- {
- int data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[][256] =
- { " value shall be 4~31 ",
- " value shall be 0~28 ",
- " value shall be 0~15 ",
- " value shall be 4~31 ",
- };
- text = edit->Text;
- if( text.AnsiCompare("") == 0 ) return;
- if( !IsValidPCL( text, m_eCurBand, data ) )
- { ShowHintLabel( edit, hint[m_eCurBand] );
- edit->Text = IntToStr( Default_PCL );
- edit->SetFocus();
- return;
- }
- }
- //============================================================================
- /////////////////////////// export information /////////////////////////
- //============================================================================
- void TfrmCTBBTXRunTimeSetting::Set_RF_CT_Obj(CRFCT* rf_ct_obj)
- {
- m_pcRF_CT_Obj = rf_ct_obj;
- }
- //----------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::Set_RF_TXIQRUN_Obj(CRFTXIQRUN* rf_txiqrun_obj)
- {
- m_pcRF_TXIQRUN_Obj = rf_txiqrun_obj;
- }
- //----------------------------------------------------------------------------
- void TfrmCTBBTXRunTimeSetting::Set_RF_STOP_Obj(CRFSTOP* rf_stop_obj)
- {
- m_pcRF_STOP_Obj = rf_stop_obj;
- }