form_RFApcProfile.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:92k
- /*****************************************************************************
- * 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_RFApcProfile.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF APC profile 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>
- #include <stdio.h>
- #pragma hdrstop
- //---------------------------------------------------------------------------
- // form
- #include "form_RFGUIApcProfile.h"
- #include "form_RFApcProfile.h"
- #include "form_RFTool.h"
- #include "form_main.h"
- #ifndef _FORM_RF8PSKAPCPROFILE_H_
- #include "form_RF8PskApcProfile.h"
- #endif
- // misc
- #include "misc.h"
- #include "man_fdm.h"
- // message
- #ifndef _META_LAB_MSG_H_
- #include "meta_lab_msg.h"
- #endif
- // thread
- #ifndef _RF_TADO_THRD_H_
- #include "rf_tado_thrd.h"
- #endif
- #ifndef _RF_SETRAMP_THRD_H_
- #include "rf_setramp_thrd.h"
- #endif
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TfrmApcProfile *frmApcProfile;
- //static bool init=true;
- extern TfrmMainSel *frmMainSel;
- // thread
- T_RFTADO* pt_rftado;
- T_RFSETRAMP* pt_rfsetramp;
- //===========================================================================
- //===========================================================================
- static void ConfirmCallback_TX( void )
- { frmApcProfile->ConfirmCallback_TX();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_RfSetRampTable( void )
- { frmApcProfile->ConfirmCallback_RfSetRampTable();
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadApcFromNVRAM( void )
- { frmApcProfile->UploadApcFromFlashDone();
- }
- //---------------------------------------------------------------------------
- //static void CNF_ReadWord3FromNVRAM( void )
- //{ frmApcProfile->UploadWord3FromFlashDone();
- //}
- //---------------------------------------------------------------------------
- static void CNF_ReadB5PFromNVRAM( void )
- { frmApcProfile->UploadB5PFromFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteApcToNVRAM( void )
- { frmApcProfile->DownloadApcToFlashDone();
- }
- //---------------------------------------------------------------------------
- //static void CNF_WriteWord3ToNVRAM( void )
- //{ frmApcProfile->DownloadWord3ToFlashDone();
- //}
- //---------------------------------------------------------------------------
- static void CNF_WriteB5PToNVRAM( void )
- { frmApcProfile->DownloadB5PToFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_SetB5PToReg( void )
- { frmApcProfile->CNF_SetB5PToReg();
- }
- //---------------------------------------------------------------------------
- static void CNF_SetW6sImmediateBSI( void )
- { frmApcProfile->CNF_SetW6sImmediateBSI();
- }
- //==============================================================================
- void _fastcall TfrmApcProfile::SubClassWndProc( Messages::TMessage &Message)
- {
- switch ( Message.Msg )
- {
- case WM_MF_QUERY_RFTWOAPCDOOFFSET_SUCCESS:
- m_bTADOSupport = true;
- lblLowApcDcOffset->Visible = true;
- edtLowApcDcOffset->Visible = true;
- lblAPCLowestPower->Visible = true;
- edtAPCLowestPower->Visible = true;
- Query_RfSetRampTable_Support();
- break;
- case WM_MF_QUERY_RFTWOAPCDOOFFSET_FAILED:
- m_bTADOSupport = false;
- lblLowApcDcOffset->Visible = false;
- edtLowApcDcOffset->Visible = false;
- lblAPCLowestPower->Visible = false;
- edtAPCLowestPower->Visible = false;
- Query_RfSetRampTable_Support();
- break;
-
- // case WM_ML_QUERY_RFSETRAMPTABLE_SUCCESS:
- // read_APC_files_setup( "MF_setup.txt", Application->ExeName );
- // UploadFromFlashStart(this);
- // break;
- // case WM_ML_QUERY_RFSETRAMPTABLE_FAILED:
- // read_APC_files_setup( "MF_setup.txt", Application->ExeName );
- // UploadFromFlashStart(this);
- // break;
-
- default:
- this->WndProc( Message );
- break;
- }
- }
- //===========================================================================
- __fastcall TfrmApcProfile::TfrmApcProfile(TComponent* Owner)
- : TForm(Owner)
- {
- for (E_BANDSEL band = BANDSEL_GSM900; band <= BANDSEL_GSM850; band++)
- {
- m_sRFCal_RamTable[band].rampData.lowest_power = 0;
- for (int i=0; i<16; i++)
- {
- m_sRFCal_RamTable[band].rampData.power[i] = 0;
- for (int j=0; j<16; j++)
- {
- m_sRFCal_RamTable[band].rampData.ramp[i].point[0][j] = 0;
- }
- }
- for (int i=0; i<11; i++)
- {
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].max_arfcn = -1;
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].mid_level = 10;
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].hi_weight = 0;
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].low_weight = 0;
- }
- }
- m_cTsc = 5;
- m_sAfcDac = 4100;
- m_eBurstType = NB_TX_RANDOM_WITH_TSC;
- m_eCurBand = BANDSEL_GSM900;
- m_iCurPCLIndex = 0;
- for (E_BANDSEL band = BANDSEL_GSM900; band <= BANDSEL_GSM850; band++)
- {
- m_usHighApcDcOffset[band] = 0;
- m_usLowApcDcOffset[band] = 0;
- }
- m_sTestArfcn[BANDSEL_GSM900 ] = 0;
- m_sTestArfcn[BANDSEL_DCS1800] = 512;
- m_sTestArfcn[BANDSEL_PCS1900] = 512;
- m_sTestArfcn[BANDSEL_GSM850] = 128;
- m_iApcLowestPower[BANDSEL_GSM900] = 5;
- m_iApcLowestPower[BANDSEL_DCS1800] = 0;
- m_iApcLowestPower[BANDSEL_PCS1900] = 0;
- m_iApcLowestPower[BANDSEL_GSM850] = 5;
- lastTabIndex = 0; // GSM 900
- RF_TX_Obj = 0;
- RF_APC_Obj = 0;
- edtPCLDAC[ 0]=edtPCLDAC00; btnPCL[ 0]=btnPCL00; edtRampUp[ 0]=edtRampUp00; edtRampDn[ 0]=edtRampDn00; edtWtARFCN[ 0]=edtWtARFCN00; edtWtHigh[ 0]=edtWtHigh00; edtWtLow[ 0]=edtWtLow00; edtWtPCL[ 0]=edtWtPCL00;
- edtPCLDAC[ 1]=edtPCLDAC01; btnPCL[ 1]=btnPCL01; edtRampUp[ 1]=edtRampUp01; edtRampDn[ 1]=edtRampDn01; edtWtARFCN[ 1]=edtWtARFCN01; edtWtHigh[ 1]=edtWtHigh01; edtWtLow[ 1]=edtWtLow01; edtWtPCL[ 1]=edtWtPCL01;
- edtPCLDAC[ 2]=edtPCLDAC02; btnPCL[ 2]=btnPCL02; edtRampUp[ 2]=edtRampUp02; edtRampDn[ 2]=edtRampDn02; edtWtARFCN[ 2]=edtWtARFCN02; edtWtHigh[ 2]=edtWtHigh02; edtWtLow[ 2]=edtWtLow02; edtWtPCL[ 2]=edtWtPCL02;
- edtPCLDAC[ 3]=edtPCLDAC03; btnPCL[ 3]=btnPCL03; edtRampUp[ 3]=edtRampUp03; edtRampDn[ 3]=edtRampDn03; edtWtARFCN[ 3]=edtWtARFCN03; edtWtHigh[ 3]=edtWtHigh03; edtWtLow[ 3]=edtWtLow03; edtWtPCL[ 3]=edtWtPCL03;
- edtPCLDAC[ 4]=edtPCLDAC04; btnPCL[ 4]=btnPCL04; edtRampUp[ 4]=edtRampUp04; edtRampDn[ 4]=edtRampDn04; edtWtARFCN[ 4]=edtWtARFCN04; edtWtHigh[ 4]=edtWtHigh04; edtWtLow[ 4]=edtWtLow04; edtWtPCL[ 4]=edtWtPCL04;
- edtPCLDAC[ 5]=edtPCLDAC05; btnPCL[ 5]=btnPCL05; edtRampUp[ 5]=edtRampUp05; edtRampDn[ 5]=edtRampDn05; edtWtARFCN[ 5]=edtWtARFCN05; edtWtHigh[ 5]=edtWtHigh05; edtWtLow[ 5]=edtWtLow05; edtWtPCL[ 5]=edtWtPCL05;
- edtPCLDAC[ 6]=edtPCLDAC06; btnPCL[ 6]=btnPCL06; edtRampUp[ 6]=edtRampUp06; edtRampDn[ 6]=edtRampDn06; edtWtARFCN[ 6]=edtWtARFCN06; edtWtHigh[ 6]=edtWtHigh06; edtWtLow[ 6]=edtWtLow06; edtWtPCL[ 6]=edtWtPCL06;
- edtPCLDAC[ 7]=edtPCLDAC07; btnPCL[ 7]=btnPCL07; edtRampUp[ 7]=edtRampUp07; edtRampDn[ 7]=edtRampDn07; edtWtARFCN[ 7]=edtWtARFCN07; edtWtHigh[ 7]=edtWtHigh07; edtWtLow[ 7]=edtWtLow07; edtWtPCL[ 7]=edtWtPCL07;
- edtPCLDAC[ 8]=edtPCLDAC08; btnPCL[ 8]=btnPCL08; edtRampUp[ 8]=edtRampUp08; edtRampDn[ 8]=edtRampDn08; edtWtARFCN[ 8]=edtWtARFCN08; edtWtHigh[ 8]=edtWtHigh08; edtWtLow[ 8]=edtWtLow08; edtWtPCL[ 8]=edtWtPCL08;
- edtPCLDAC[ 9]=edtPCLDAC09; btnPCL[ 9]=btnPCL09; edtRampUp[ 9]=edtRampUp09; edtRampDn[ 9]=edtRampDn09; edtWtARFCN[ 9]=edtWtARFCN09; edtWtHigh[ 9]=edtWtHigh09; edtWtLow[ 9]=edtWtLow09; edtWtPCL[ 9]=edtWtPCL09;
- edtPCLDAC[10]=edtPCLDAC10; btnPCL[10]=btnPCL10; edtRampUp[10]=edtRampUp10; edtRampDn[10]=edtRampDn10; edtWtARFCN[10]=edtWtARFCN10; edtWtHigh[10]=edtWtHigh10; edtWtLow[10]=edtWtLow10; edtWtPCL[10]=edtWtPCL10;
- edtPCLDAC[11]=edtPCLDAC11; btnPCL[11]=btnPCL11; edtRampUp[11]=edtRampUp11; edtRampDn[11]=edtRampDn11;
- edtPCLDAC[12]=edtPCLDAC12; btnPCL[12]=btnPCL12; edtRampUp[12]=edtRampUp12; edtRampDn[12]=edtRampDn12;
- edtPCLDAC[13]=edtPCLDAC13; btnPCL[13]=btnPCL13; edtRampUp[13]=edtRampUp13; edtRampDn[13]=edtRampDn13;
- edtPCLDAC[14]=edtPCLDAC14; btnPCL[14]=btnPCL14; edtRampUp[14]=edtRampUp14; edtRampDn[14]=edtRampDn14;
- edtPCLDAC[15]=edtPCLDAC15; btnPCL[15]=btnPCL15; edtRampUp[15]=edtRampUp15; edtRampDn[15]=edtRampDn15;
- // battery compensate
- edtBatteryCompensateArray[0][0] = edtBatteryCompensate00; edtBatteryCompensateArray[0][1] = edtBatteryCompensate01; edtBatteryCompensateArray[0][2] = edtBatteryCompensate02;
- edtBatteryCompensateArray[1][0] = edtBatteryCompensate10; edtBatteryCompensateArray[1][1] = edtBatteryCompensate11; edtBatteryCompensateArray[1][2] = edtBatteryCompensate12;
- edtBatteryCompensateArray[2][0] = edtBatteryCompensate20; edtBatteryCompensateArray[2][1] = edtBatteryCompensate21; edtBatteryCompensateArray[2][2] = edtBatteryCompensate22;
- for (E_BANDSEL band = BANDSEL_GSM900; band <= BANDSEL_GSM850; band++)
- {
- for (int i=0; i<3; i++)
- {
- for (int j=0; j<3; j++)
- {
- m_sRFCal_RamTable[band].rampData.battery_compensate[i][j] = BATTERY_COMPENSATE_SCALE;
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::FormCreate(TObject *Sender)
- {
- isSetCal3ModeTrigger = false;
- m_uiFinalRFID = 0;
- m_bFirstFormShow = true;
- WindowProc = SubClassWndProc;
- Init();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::FormShow(TObject *Sender)
- {
- if (m_bFirstFormShow)
- {
- //Query_TwoApcDcOffset_Support();
- Query_RfSetRampTable_Support();
- frmApcProfile->AutoScroll = true;
- read_APC_files_setup( "MF_setup.txt", Application->ExeName );
- m_bTADOSupport = frmMainSel->Get_TADO_Support( );
- DisplayTADOUI( m_bTADOSupport );
- ReDrawFields(DRAW_PCL|DRAW_RAMP|DRAW_WEIGHT|DRAW_BATTERY_COMPENSATE | DRAW_WORD3 | DRAW_BV );
- m_bFirstFormShow = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::FormHide(TObject *Sender)
- {
- if(btnTXStart->Tag==1)
- { btnTXStopClick(this);
- }
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::FormActivate(TObject *Sender)
- {
- if (m_bInit)
- {
- m_bInit = false;
- m_uiFinalRFID = frmMainSel->Get_FinalRFID();
- }
- }
- //--------------------------------------------------------------------------
- void TfrmApcProfile::DisplayTADOUI( bool b_tado_support )
- {
- if( b_tado_support )
- {
- lblLowApcDcOffset->Visible = true;
- edtLowApcDcOffset->Visible = true;
- lblAPCLowestPower->Visible = true;
- edtAPCLowestPower->Visible = true;
- }
- else
- {
- lblLowApcDcOffset->Visible = false;
- edtLowApcDcOffset->Visible = false;
- lblAPCLowestPower->Visible = false;
- edtAPCLowestPower->Visible = false;
- }
- }
- //===========================================================================
- ///////////////////////////// Query ////////////////////////////
- //===========================================================================
- void __fastcall TfrmApcProfile::on_QueryTwoApcDcOffset_Fail(TObject *Sender)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::on_QueryTwoApcDcOffset_TerminateSuccess(TObject *Sender)
- {
-
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Query_TwoApcDcOffset_Support( void )
- {
- t_RfTado.hPostMsgDestHandle = this->Handle;
- t_RfTado.ne_onTermSuccess = on_QueryTwoApcDcOffset_TerminateSuccess;
- pt_rftado = new T_RFTADO(
- true,
- &t_RfTado);
- if(pt_rftado != NULL)
- {
- pt_rftado->FreeOnTerminate = true;
- pt_rftado->OnTerminate = on_QueryTwoApcDcOffset_Fail;
- pt_rftado->Priority = tpHighest;
- pt_rftado->Resume();
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmApcProfile::on_QueryRfSetRampTableSupport_Fail(TObject *Sender)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::on_QueryRfSetRampTableSupport_TerminateSuccess(TObject *Sender)
- {
-
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Query_RfSetRampTable_Support( void )
- {
- t_RfSetRamp.hPostMsgDestHandle = this->Handle;
- t_RfSetRamp.ne_onTermSuccess = on_QueryRfSetRampTableSupport_TerminateSuccess;
- pt_rfsetramp = new T_RFSETRAMP(
- true,
- &t_RfSetRamp);
- if(pt_rfsetramp != NULL)
- {
- pt_rfsetramp->FreeOnTerminate = true;
- pt_rfsetramp->OnTerminate = on_QueryRfSetRampTableSupport_Fail;
- pt_rfsetramp->Priority = tpHighest;
- pt_rfsetramp->Resume();
- }
- }
- //------------------------------------------------------------------------------
- void TfrmApcProfile::ReDrawFields( int draw_mask )
- {
- int i, j;
- int band = m_eCurBand;
- char str[256];
- edtTestArfcn->Text = m_sTestArfcn[band];
- edtHighApcDcOffset->Text = m_usHighApcDcOffset[band];
- if( m_bTADOSupport )
- {
- edtLowApcDcOffset->Text = m_usLowApcDcOffset[band];
- edtAPCLowestPower->Text = m_iApcLowestPower[band];
- }
- if( band!=BANDSEL_GSM900 && band!=BANDSEL_GSM850)
- {
- edtPCLDAC[15]->Visible = true;
- btnPCL[15]->Visible = true;
- }
- else
- {
- edtPCLDAC[15]->Visible = false;
- btnPCL[15]->Visible = false;
- }
- if(draw_mask&DRAW_PCL)
- {
- for(i=0; i<16; i++)
- {
- edtPCLDAC[i]->Text = m_sRFCal_RamTable[band].rampData.power[i];
- btnPCL[i]->Caption = PCL_RANGE[band][i];
- }
- }
- if(draw_mask&DRAW_RAMP)
- {
- sprintf(str, "PCL %d Profile", PCL_RANGE[m_eCurBand][m_iCurPCLIndex]);
- pnlProfileTItle->Caption = str;
- for(i=0; i<16; i++)
- {
- edtRampUp[i]->Text = m_sRFCal_RamTable[band].rampData.ramp[m_iCurPCLIndex].point[0][i];
- edtRampDn[i]->Text = m_sRFCal_RamTable[band].rampData.ramp[m_iCurPCLIndex].point[1][i];
- }
- }
- if (draw_mask & DRAW_WEIGHT)
- {
- for(i=0; i<11; i++)
- {
- edtWtARFCN[i]->Text = m_sRFCal_RamTable[band].rampData.arfcn_weight[i].max_arfcn;
- edtWtPCL[i]->Text = m_sRFCal_RamTable[band].rampData.arfcn_weight[i].mid_level;
- edtWtHigh[i]->Text = (long)(m_sRFCal_RamTable[band].rampData.arfcn_weight[i].hi_weight*1.0/WEIGHT_SCALE*1000+0.5)/1000.0;
- edtWtLow[i]->Text = (long)(m_sRFCal_RamTable[band].rampData.arfcn_weight[i].low_weight*1.0/WEIGHT_SCALE*1000+0.5)/1000.0;
- }
- }
- if(draw_mask&DRAW_BATTERY_COMPENSATE)
- {
- for(i=0; i<3; i++)
- {
- for(j=0; j<3; j++)
- {
- edtBatteryCompensateArray[i][j]->Text = (long) (m_sRFCal_RamTable[band].rampData.battery_compensate[i][j]*1.0 / BATTERY_COMPENSATE_SCALE*1000+0.5)/1000.0 ;
- }
- }
- }
- if(draw_mask & DRAW_TX_AFC_OFFSET)
- {
- edtTxAfcOffset->Text = IntToStr( m_sRFCal_RamTable[band].rampData.tx_afc_offset );
- }
- if(draw_mask & DRAW_WORD3 )
- {
- //Display_RenesasUI( tctlAPC->TabIndex );
- Display_Word3();
- }
- if(draw_mask & DRAW_BV)
- {
- // Display_RenesasUI( tctlAPC->TabIndex );
- Display_Word6s( tctlAPC->TabIndex );
- }
- edtTestArfcn->Text = m_sTestArfcn[m_eCurBand];
- }
- //===========================================================================
- void TfrmApcProfile::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;
- }
- //---------------------------------------------------------------------------
- bool TfrmApcProfile::CheckFields( void )
- {
- int i, j;
- int idata;
- short sdata;
- unsigned char ucdata;
- unsigned short usdata;
- E_BANDSEL band = m_eCurBand;
- AnsiString text;
- for(i=0; i<16; i++)
- {
- if (edtPCLDAC[i]->Visible)
- {
- text = edtPCLDAC[i]->Text; if( !IsValidPCLDac( text, usdata ) ) { edtPCLDACCheck(edtPCLDAC[i]); return(false); }
- m_sRFCal_RamTable[band].rampData.power[i] = usdata;
- }
- text = edtRampUp[i]->Text; if( !IsValidRamp( text, ucdata) ) { edtRampUpCheck(edtRampUp[i]); return(false); }
- m_sRFCal_RamTable[band].rampData.ramp[m_iCurPCLIndex].point[0][i] = ucdata;
- text = edtRampDn[i]->Text; if( !IsValidRamp( text, ucdata) ) { edtRampDnCheck(edtRampDn[i]); return(false); }
- m_sRFCal_RamTable[band].rampData.ramp[m_iCurPCLIndex].point[1][i] = ucdata;
- }
- for(i=0; i<11; i++)
- {
- text = edtWtARFCN[i]->Text; if( !IsValidARFCN2( text, band, sdata ) ) { edtWtARFCNCheck(edtWtARFCN[i]); return(false); }
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].max_arfcn = sdata;
- if (-1 == idata) break;
- text = edtWtPCL[i]->Text; if( !IsValidPCL( text, band, idata ) ) { edtWtPCLCheck(edtWtPCL[i]); return(false); }
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].mid_level = idata;
- text = edtWtHigh[i]->Text; if (!IsValidWeight(text, m_uiFinalRFID, usdata)) { edtWtHighCheck(edtWtHigh[i]); return(false); }
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].hi_weight = usdata;
- text = edtWtLow[i]->Text; if (!IsValidWeight(text, m_uiFinalRFID, usdata)) { edtWtLowCheck(edtWtLow[i]); return(false); }
- m_sRFCal_RamTable[band].rampData.arfcn_weight[i].low_weight = usdata;
- }
- for(i=0; i<3; i++)
- {
- for( j=0; j<3; j++ )
- {
- text = edtBatteryCompensateArray[i][j]->Text; if( !IsValidBatteryCompensate( text, usdata ) ) { edtBatteryCompensateCheck(edtBatteryCompensateArray[i][j]); return(false); }
- m_sRFCal_RamTable[band].rampData.battery_compensate[i][j] = usdata;
- }
- }
- text = edtTestArfcn->Text; if( !IsValidARFCN( text, band, m_sTestArfcn[band] ) ) { edtTestArfcnCheck(edtTestArfcn); return(false); }
- text = edtHighApcDcOffset->Text; if( !IsValidPCLDac( text, m_usHighApcDcOffset[band] ) ) { edtHighApcDcOffsetCheck(edtHighApcDcOffset); return(false); }
- if( m_bTADOSupport )
- {
- text = edtLowApcDcOffset->Text; if( !IsValidPCLDac( text, m_usLowApcDcOffset[band] ) ) { edtHighApcDcOffsetCheck(edtLowApcDcOffset); return(false); }
- text = edtAPCLowestPower->Text; if( !IsValidApcLowestPower( text, m_eCurBand, m_iApcLowestPower[band] ) ) { edtAPCLowestPowerCheck(edtAPCLowestPower); return(false); }
- }
- text = edtTxAfcOffset->Text; if( !IsValidTxAfcOffset( text, tx_afc_offset[band] ) ) { edtTxAfcOffsetCheck(edtTxAfcOffset); return(false); }
- m_sRFCal_RamTable[band].rampData.tx_afc_offset = tx_afc_offset[band];
- return(true);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtPCLDACCheck(TObject *Sender)
- {
- unsigned short usdata;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~1023 ";
- text = edit->Text;
- if (!IsValidPCLDac(text, usdata))
- {
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.power[edit->Tag] = usdata;
- if ((14 == edit->Tag) || (!edtPCLDAC15->Visible))
- {
- m_sRFCal_RamTable[m_eCurBand].rampData.power[15] = usdata;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtRampUpCheck(TObject *Sender)
- {
- unsigned char ucdata;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidRamp( text, ucdata ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.ramp[m_iCurPCLIndex].point[0][edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtRampDnCheck(TObject *Sender)
- {
- unsigned char ucdata;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~255 ";
- text = edit->Text;
- if( !IsValidRamp( text, ucdata ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.ramp[m_iCurPCLIndex].point[1][edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtWtARFCNCheck(TObject *Sender)
- {
- short sdata;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[][256] =
- {
- " value shall be 0~124 or 975~1023 or -1 ",
- " value shall be 512~885 or -1 ",
- " value shall be 512~810 or -1 ",
- " value shall be 128~251 or -1 ",
- };
- text = edit->Text;
- if (!IsValidARFCN2(text, m_eCurBand, sdata))
- {
- edit->Text = IntToStr(Default_ARFCN[m_eCurBand]);
- ShowHintLabel(edit, hint[m_eCurBand]);
- edit->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.arfcn_weight[edit->Tag].max_arfcn = sdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtWtPCLCheck(TObject *Sender)
- {
- int i;
- 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->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.arfcn_weight[edit->Tag].mid_level = data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtWtHighCheck(TObject *Sender)
- {
- unsigned short us_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0.0~4.0 ";
- text = edit->Text;
- if (!IsValidWeight(text, m_uiFinalRFID, us_data))
- {
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.arfcn_weight[edit->Tag].hi_weight = us_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtWtLowCheck(TObject *Sender)
- {
- unsigned short us_data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0.0~3.99 ";
- text = edit->Text;
- if (!IsValidWeight(text, m_uiFinalRFID, us_data))
- {
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.arfcn_weight[edit->Tag].low_weight = us_data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtTestArfcnCheck(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;
- }
- m_sTestArfcn[m_eCurBand] = sdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtHighApcDcOffsetCheck(TObject *Sender)
- {
- unsigned short usdata;
- int band = m_eCurBand;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~1023 ";
- text = edit->Text;
- if (!IsValidPCLDac(text, usdata))
- {
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- m_usHighApcDcOffset[band] = usdata;
- }
- //===========================================================================
- void __fastcall TfrmApcProfile::tctlAPCChange(TObject *Sender)
- {
- if (!frmMainSel->cbGSM850->Checked)
- {
- if (BANDSEL_GSM850 == (E_BANDSEL) tctlAPC->TabIndex)
- {
- tctlAPC->TabIndex = lastTabIndex;
- Application->MessageBox( "Please check GSM 850 on main menu", "FAILURE", MB_OK );
- return;
- }
- }
- if( !CheckFields() )
- {
- tctlAPC->TabIndex = m_eCurBand;
- return;
- }
- if(btnTXStart->Tag==1)
- { btnTXStartClick(this);
- }
- m_eCurBand = (E_BANDSEL) tctlAPC->TabIndex;
- lastTabIndex = tctlAPC->TabIndex;
- m_iCurPCLIndex = 0;
- ReDrawFields( DRAW_PCL | DRAW_RAMP | DRAW_WEIGHT | DRAW_BATTERY_COMPENSATE | DRAW_TX_AFC_OFFSET |
- DRAW_WORD3 | DRAW_BV);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::OnBtnPclClick(TObject *Sender)
- {
- if(btnTXStart->Tag==1)
- { btnTXStartClick(this);
- }
- m_iCurPCLIndex = (*(TComponent*)Sender).Tag;
- ReDrawFields( DRAW_RAMP );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnLeftClick(TObject *Sender)
- {
- TButton *button = (TButton*)Sender;
- int up_down = button->Tag;
- int i;
- for(i=0; i<15; i++)
- {
- m_sRFCal_RamTable[m_eCurBand].rampData.ramp[m_iCurPCLIndex].point[up_down][i] =
- m_sRFCal_RamTable[m_eCurBand].rampData.ramp[m_iCurPCLIndex].point[up_down][i+1];
- }
- ReDrawFields( DRAW_RAMP );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnRightClick(TObject *Sender)
- {
- TButton *button = (TButton*)Sender;
- int up_down = button->Tag;
- int i;
- for(i=15; i>=1; i--)
- {
- m_sRFCal_RamTable[m_eCurBand].rampData.ramp[m_iCurPCLIndex].point[up_down][i] =
- m_sRFCal_RamTable[m_eCurBand].rampData.ramp[m_iCurPCLIndex].point[up_down][i-1];
- }
- ReDrawFields( DRAW_RAMP );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnTXStartClick(TObject *Sender)
- {
- if(btnTXStart->Tag==0)
- {
- AnsiString text;
- // btnTXStart->Kind = bkNo;
- // btnTXStart->Caption = "Stop";
- btnTXStart->Enabled = false;
- btnTXStart->Tag = 1;
- m_cTsc = cbxTsc->ItemIndex;
- text = edtAfc->Text; if( !IsValidAFC( text, m_sAfcDac ) ) { edtAfcDacCheck(edtAfc); return; }
- m_eBurstType = NB_TX_RANDOM_WITH_TSC;
- if (!CheckFields())
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Burst TX fail";
- Application->MessageBox( "Execution Failure : Burst TX", "FAILURE", MB_OK );
- return;
- }
- frmRFTool->Force_RF_Stop();
- CurrentPageLock();
- frmRFTool->CurrentPageLock();
- // frmRFTool->btnTXStart->Enabled = false;
- frmRFTool->pctlToolSel->Enabled = false;
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX progressing";
- if( t_RfSetRamp.rf_setramp.SetRampTableSupport )
- {
- int total_band_num;
- int band;
- if(frmMainSel->cbGSM850->Checked)
- { total_band_num = 4;
- }
- else
- { total_band_num = 3;
- }
- for(band=0; band<total_band_num; band++)
- {
- RF_APC_Obj->Set_HighApcDcOffset( band, m_usHighApcDcOffset[band] );
- if( m_bTADOSupport )
- {
- RF_APC_Obj->Set_LowApcDcOffset( band, m_usLowApcDcOffset[band] );
- RF_APC_Obj->Set_ApcLowestPower( band, m_iApcLowestPower[band] );
- }
- RF_APC_Obj->Set_ApcProfile( band, m_sRFCal_RamTable[band] );
- }
-
- RF_APC_Obj->ConfirmCallback = ::ConfirmCallback_RfSetRampTable;
- RF_APC_Obj->REQ_RfSetRampTable_Start(m_uiFinalRFID, m_bTADOSupport, m_eCurBand );
- }
- else
- {
- S_RFTX rf_tx;
- rf_tx.e_bandsel = m_eCurBand;
- rf_tx.s_RfNbTxReq.arfcn = m_sTestArfcn[m_eCurBand];
- rf_tx.s_RfNbTxReq.bsic = m_cTsc;
- rf_tx.s_RfNbTxReq.power = PCL_RANGE[m_eCurBand][m_iCurPCLIndex];
- rf_tx.s_RfNbTxReq.frames = -99;
- rf_tx.s_RfNbTxReq.dacValue = m_sAfcDac;
- rf_tx.s_RfNbTxReq.burstTypeNB = m_eBurstType;
- RF_TX_Obj->ConfirmCallback = ::ConfirmCallback_TX;
- RF_TX_Obj->REQ_Start(rf_tx);
- }
- }
- else
- {
- #if 0
- frmRFTool->Force_RF_Stop();
- // btnTXStart->Kind = bkRetry;
- // btnTXStart->Caption = "Start";
- btnTXStart->Enabled = true;
- btnTXStart->Tag = 0;
- frmRFTool->pctlToolSel->Enabled = true;
- frmRFTool->btnTXStart->Enabled = true;
- //CurrentPageReset();
- frmRFTool->CurrentPageReset();
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX stop";
- #endif
- return;
- }
- }
- //-----------------------------------------------
- void TfrmApcProfile::ConfirmCallback_RfSetRampTable(void)
- {
- E_METAAPP_RESULT_T state = RF_TX_Obj->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX progressing";
- }
- break;
- case METAAPP_FAIL:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX fail";
- Application->MessageBox("Execution failure : Set ramp table", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX timeout";
- Application->MessageBox("Execution Timeout : Set ramp table", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set ramp table stop";
- }
- break;
- }
- S_RFTX rf_tx;
- rf_tx.e_bandsel = m_eCurBand;
- rf_tx.s_RfNbTxReq.arfcn = m_sTestArfcn[m_eCurBand];
- rf_tx.s_RfNbTxReq.bsic = m_cTsc;
- rf_tx.s_RfNbTxReq.power = PCL_RANGE[m_eCurBand][m_iCurPCLIndex];
- rf_tx.s_RfNbTxReq.frames = -99;
- rf_tx.s_RfNbTxReq.dacValue = m_sAfcDac;
- rf_tx.s_RfNbTxReq.burstTypeNB = m_eBurstType;
- RF_TX_Obj->ConfirmCallback = ::ConfirmCallback_TX;
- RF_TX_Obj->REQ_Start(rf_tx);
- }
- //-----------------------------------------------
- void TfrmApcProfile::ConfirmCallback_TX(void)
- {
- E_METAAPP_RESULT_T state = RF_TX_Obj->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX progressing";
- }
- break;
- case METAAPP_FAIL:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX fail";
- Application->MessageBox("Execution failure : Burst TX", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX timeout";
- Application->MessageBox("Execution Timeout : Burst TX", "TIMEOUT", MB_OK);
- }
- break;
- case METAAPP_STOP:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX stop";
- }
- break;
- }
- }
- //===========================================================================
- void __fastcall TfrmApcProfile::UploadFromFlashStart(TObject *Sender)
- {
- if( ! NVRAMMan->Get_IsInit() )
- {
- frmMainSel->mnuFDMDatabaseClick(Sender);
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialization fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialization fail", "FAILURE", MB_OK );
- return;
- }
- stNVRAMDB->Caption = frmMainSel->Get_NVRAMDBFileName();
- }
- RF_APC_Obj->ConfirmCallback = ::CNF_ReadApcFromNVRAM;
- RF_APC_Obj->REQ_Read_APC_From_NVRAM_Start(m_uiFinalRFID, m_bTADOSupport);
- CurrentPageLock();
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload APC profile setting from flash progressing";
- }
- //-----------------------------------------------
- void TfrmApcProfile::UploadApcFromFlashDone( void )
- {
- E_METAAPP_RESULT_T state = RF_APC_Obj->Get_ConfirmState();
- int band;
- int total_band_num;
- if( state==METAAPP_SUCCESS )
- {
- if (frmMainSel->cbGSM850->Checked)
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for(band=0; band<total_band_num; band++)
- {
- m_usHighApcDcOffset[band] = RF_APC_Obj->Get_HighApcDcOffset(band);
- if( m_bTADOSupport )
- {
- m_usLowApcDcOffset[band] = RF_APC_Obj->Get_LowApcDcOffset(band);
- m_iApcLowestPower[band] = RF_APC_Obj->Get_ApcLowestPower(band);
- }
- l1cal_rampTable_T* p_ramp_table = RF_APC_Obj->Get_ApcProfile(band);
- m_sRFCal_RamTable[band] = *p_ramp_table;
- }
- if( RF_ID_BRIGHT5P == m_uiFinalRFID )
- {
- RF_APC_Obj->ConfirmCallback = ::CNF_ReadB5PFromNVRAM;
- RF_APC_Obj->REQ_Read_B5P_From_NVRAM();
- return;
- }
- else
- {
- ReDrawFields(DRAW_PCL | DRAW_RAMP | DRAW_WEIGHT | DRAW_BATTERY_COMPENSATE | DRAW_TX_AFC_OFFSET);
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload APC profile setting from flash successfully";
- }
- }
- else if( state==METAAPP_FAIL )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload APC profile setting from flash fail";
- Application->MessageBox( "Execution Failure : Upload APC profile from flash, please check 1.GSM850 support, 2. The version of load and NVRAM database are same. ", "FAILURE", MB_OK );
- }
- else if( state==METAAPP_TIMEOUT )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload APC profile setting from flash timeout";
- Application->MessageBox( "Execution Timeout : Upload APC profile from flash", "TIMEOUT", MB_OK );
- }
- else if( state==METAAPP_STOP )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload APC profile setting from flash stop";
- }
- CurrentPageReset();
- }
- #if 0
- //-----------------------------------------------
- void TfrmApcProfile::UploadWord3FromFlashDone( void )
- {
- int state = RF_APC_Obj->ConfirmState;
- int band;
- int total_band_num;
- if( state==METAAPP_SUCCESS )
- {
- RF_APC_Obj->ConfirmCallback = ::CNF_ReadBvFromNVRAM;
- RF_APC_Obj->REQ_Read_BV_From_NVRAM();
- }
- else if( state==METAAPP_FAIL )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload WORD3 mode setting from flash fail";
- Application->MessageBox( "Execution Failure : Upload WORD3 mode setting from flash, please check 1.GSM850 support, 2. The version of load and NVRAM database are same. ", "FAILURE", MB_OK );
- }
- else if( state==METAAPP_TIMEOUT )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload WORD3 mode setting from flash timeout";
- Application->MessageBox( "Execution Timeout : Upload WORD3 mode setting from flash", "TIMEOUT", MB_OK );
- }
- else if( state==METAAPP_STOP )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload WORD3 mode setting from flash stop";
- Application->MessageBox( "Execution Timeout : Upload WORD3 mode setting from flash", "STOP", MB_OK );
- }
- }
- #endif
- //-----------------------------------------------
- void TfrmApcProfile::UploadB5PFromFlashDone(void)
- {
- E_METAAPP_RESULT_T state = RF_APC_Obj->Get_ConfirmState();
- int band;
- int total_band_num;
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (m_bDownloadTrigger)
- {
- m_bDownloadTrigger = false;
- ComposeRenesasField();
- RF_APC_Obj->Set_RenesasCoef(b5p_coef);
- RF_APC_Obj->ConfirmCallback = ::CNF_WriteB5PToNVRAM;
- RF_APC_Obj->REQ_Write_B5P_To_NVRAM();
- return;
- }
- else
- {
- RF_APC_Obj->Get_RenesasCoef(b5p_coef);
- DeComposeRenesasField();
- ReDrawFields(DRAW_PCL | DRAW_RAMP | DRAW_WEIGHT | DRAW_BATTERY_COMPENSATE | DRAW_TX_AFC_OFFSET |
- DRAW_WORD3 | DRAW_BV );
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload APC profile, WORD3 and BV setting from flash successfully";
- }
- }
- break;
- case METAAPP_FAIL:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload WORD3 setting from flash fail";
- Application->MessageBox("Execution Failure : Upload WORD3 setting from flash, please check 1.GSM850 support, 2. The version of load and NVRAM database are same. ", "FAILURE", MB_OK);
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload WORD3 setting from flash timeout";
- Application->MessageBox( "Execution Timeout : Upload WORD3 setting from flash", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Upload WORD3 setting from flash stop";
- Application->MessageBox( "Execution Timeout : Upload WORD3 setting from flash", "STOP", MB_OK );
- }
- break;
- }
- CurrentPageReset();
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void __fastcall TfrmApcProfile::DownloadToFlashStart(TObject *Sender)
- {
- int band;
- int total_band_num;
- if( !CheckFields() )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download APC profile setting to flash fail";
- Application->MessageBox( "Execution Failure : Download APC profile to flash", "FAILURE", MB_OK );
- return;
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- frmMainSel->mnuFDMDatabaseClick(Sender);
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialization fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialization fail", "FAILURE", MB_OK );
- return;
- }
- stNVRAMDB->Caption = frmMainSel->Get_NVRAMDBFileName();
- }
- if(frmMainSel->cbGSM850->Checked)
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for (band=0; band<total_band_num; band++)
- {
- RF_APC_Obj->Set_HighApcDcOffset( band, m_usHighApcDcOffset[band] );
- if( m_bTADOSupport )
- {
- RF_APC_Obj->Set_LowApcDcOffset( band, m_usLowApcDcOffset[band] );
- RF_APC_Obj->Set_ApcLowestPower( band, m_iApcLowestPower[band] );
- }
- RF_APC_Obj->Set_ApcProfile( band, m_sRFCal_RamTable[band] );
- }
- RF_APC_Obj->ConfirmCallback = ::CNF_WriteApcToNVRAM;
- RF_APC_Obj->REQ_Write_APC_To_NVRAM_Start(m_uiFinalRFID, m_bTADOSupport);
- m_bDownloadTrigger = true;
- CurrentPageLock();
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download APC profile setting to flash progressing";
- }
- //-----------------------------------------------
- void TfrmApcProfile::DownloadApcToFlashDone( void )
- {
- E_METAAPP_RESULT_T state = RF_APC_Obj->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (RF_ID_BRIGHT5P == m_uiFinalRFID)
- {
- if (m_bDownloadTrigger)
- {
- RF_APC_Obj->ConfirmCallback = ::CNF_ReadB5PFromNVRAM;
- RF_APC_Obj->REQ_Read_B5P_From_NVRAM();
- return;
- }
- }
- else
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download APC profile setting to flash successfully";
- }
- }
- break;
- case METAAPP_FAIL:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download APC profile setting to flash fail";
- Application->MessageBox( "Execution Failure : Download APC profile to flash, please check 1.GSM850 support. 2. The version of load and NVRAM database are same. ", "FAILURE", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download APC profile setting to flash timeout";
- Application->MessageBox( "Execution Timeout : Download APC profile to flash", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download APC profile setting to flash stop";
- }
- break;
- case METAAPP_NVRAM_LID_VER_NOT_SUPPORT:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version";
- Application->MessageBox("Execution Warning : NVRAM_EF_L1_RAMPTABLE_xxx_LID version is not support, please update META to latest version", "WARNING", MB_OK);
- }
- break;
- default:
- {
- }
- break;
- }
- CurrentPageReset();
- }
- #if 0
- //-----------------------------------------------
- void TfrmApcProfile::DownloadWord3ToFlashDone( void )
- {
- E_METAAPP_RESULT_T state = RF_APC_Obj->ConfirmState;
- CurrentPageReset();
- if( state==METAAPP_SUCCESS )
- {
- // copy BV
- RF_APC_Obj->ConfirmCallback = ::CNF_WriteBvToNVRAM;
- RF_APC_Obj->REQ_Write_BV_To_NVRAM();
- }
- else if( state==METAAPP_FAIL )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download WORD3 setting to flash fail";
- Application->MessageBox( "Execution Failure : Download WORD3 to flash, please check 1.GSM850 support. 2. The version of load and NVRAM database are same. ", "FAILURE", MB_OK );
- }
- else if( state==METAAPP_TIMEOUT )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download WORD3 setting to flash timeout";
- Application->MessageBox( "Execution Timeout : Download WORD3 to flash", "TIMEOUT", MB_OK );
- }
- else if( state==METAAPP_STOP )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download WORD3 setting to flash stop";
- // Application->MessageBox( "Execution Stop : Download WORD3 to flash", "STOP", MB_OK );
- }
- }
- #endif
- //-----------------------------------------------
- void TfrmApcProfile::DownloadB5PToFlashDone(void)
- {
- E_METAAPP_RESULT_T state = RF_APC_Obj->Get_ConfirmState();
- CurrentPageReset();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download APC profile, WORD3 and BV setting to flash successfully";
- }
- break;
- case METAAPP_FAIL:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download BV setting to flash fail";
- Application->MessageBox( "Execution Failure : Download BV to flash, please check 1.GSM850 support. 2. The version of load and NVRAM database are same. ", "FAILURE", MB_OK );
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download BV setting to flash timeout";
- Application->MessageBox( "Execution Timeout : Download BV to flash", "TIMEOUT", MB_OK );
- }
- break;
- case METAAPP_STOP:
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Download BV setting to flash stop";
- }
- break;
- }
- }
- //===========================================================================
- void __fastcall TfrmApcProfile::btnLoadFromFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- int band;
- ok = OpenDialog->Execute();
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Load APC profile setting from file fail";
- Application->MessageBox( "Execution Failure : Load APC profile from file", "FAILURE", MB_OK );
- return;
- }
- strcpy( str, OpenDialog->FileName.c_str() );
- for(band=0; band<MAX_SUPPORT_BAND_NUM; band++)
- {
- if( RF_APC_Obj->ApcSectionExist( str, band ) )
- {
- ok = RF_APC_Obj->REQ_Read_APC_From_File_Single_Band(str, m_uiFinalRFID, band, m_bTADOSupport);
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Load APC profile setting from file fail";
- Application->MessageBox( "Execution Failure : Load APC profile from file", "FAILURE", MB_OK );
- return;
- }
- m_usHighApcDcOffset[band] = RF_APC_Obj->Get_HighApcDcOffset(band);
- if( m_bTADOSupport )
- {
- m_usLowApcDcOffset[band] = RF_APC_Obj->Get_LowApcDcOffset(band);
- m_iApcLowestPower[band] = RF_APC_Obj->Get_ApcLowestPower(band);
- }
- l1cal_rampTable_T* p_ramp_table = RF_APC_Obj->Get_ApcProfile(band);
- m_sRFCal_RamTable[band] = *p_ramp_table;
- }
- }
- if( m_uiFinalRFID == RF_ID_BRIGHT5P )
- {
- if( RF_APC_Obj->RenesasWord3SectionExist(str) )
- {
- ok = RF_APC_Obj->REQ_Read_Word3_From_File( str );
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Load WORD3 setting from file fail";
- Application->MessageBox( "Execution Failure : Load WORD3 from file", "FAILURE", MB_OK );
- return;
- }
- }
- if( RF_APC_Obj->RenesasWord6sSectionExist(str) )
- {
- ok = RF_APC_Obj->REQ_Read_Word6s_From_File( str );
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Load BV mode setting from file fail";
- Application->MessageBox( "Execution Failure : Load BV mode from file", "FAILURE", MB_OK );
- return;
- }
- }
- // get C3, BV
- RF_APC_Obj->Get_RenesasCoef( b5p_coef );
- DeComposeRenesasField();
- ReDrawFields( DRAW_PCL | DRAW_RAMP | DRAW_WEIGHT | DRAW_BATTERY_COMPENSATE | DRAW_TX_AFC_OFFSET |
- DRAW_WORD3 | DRAW_BV );
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Load APC profile, WORD3 and BV setting from file successfully";
- }
- else
- {
- ReDrawFields( DRAW_PCL | DRAW_RAMP | DRAW_WEIGHT | DRAW_BATTERY_COMPENSATE | DRAW_TX_AFC_OFFSET );
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Load APC profile setting from file successfully";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnSaveToFileClick(TObject *Sender)
- {
- char str[512];
- bool ok;
- int band;
- int total_band_num;
- ok = CheckFields();
- if(!ok)
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Save APC profile setting to file fail";
- Application->MessageBox( "Execution Failure : Save APC profile to file", "FAILURE", MB_OK );
- return;
- }
- ok = SaveDialog->Execute();
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Save APC profile setting to file fail";
- Application->MessageBox( "Execution Failure : Save APC profile to file", "FAILURE", MB_OK );
- return;
- }
- strcpy( str, SaveDialog->FileName.c_str() );
- // frmMainSel->Get_FinalBandSupport( band_support );
-
- if( frmMainSel->cbGSM850->Checked )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for(band=0; band<total_band_num; band++)
- {
- RF_APC_Obj->Set_HighApcDcOffset( band, m_usHighApcDcOffset[band] );
- if( m_bTADOSupport )
- {
- RF_APC_Obj->Set_LowApcDcOffset( band, m_usLowApcDcOffset[band] );
- RF_APC_Obj->Set_ApcLowestPower(band, m_iApcLowestPower[band]);
- }
- RF_APC_Obj->Set_ApcProfile( band, m_sRFCal_RamTable[band] );
- ok = RF_APC_Obj->REQ_Write_APC_To_File_Single_Band(str, m_uiFinalRFID, band, m_bTADOSupport);
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Save APC profile setting to file fail";
- Application->MessageBox( "Execution Failure : Save APC profile to file", "FAILURE", MB_OK );
- return;
- }
- }
- if( m_uiFinalRFID == RF_ID_BRIGHT5P )
- {
- // Renesas
- ComposeRenesasField();
- RF_APC_Obj->Set_RenesasCoef( b5p_coef );
- ok = RF_APC_Obj->REQ_Write_Word3_To_File( str );
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Save WORD3 setting to file fail";
- Application->MessageBox( "Execution Failure : Save WORD3 setting to file", "FAILURE", MB_OK );
- return;
- }
- ok = RF_APC_Obj->REQ_Write_Word6s_To_File( str );
- if( !ok )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Save bias Word6s to file fail";
- Application->MessageBox( "Execution Failure : Save bias Word6s to file", "FAILURE", MB_OK );
- return;
- }
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Save APC profile, Word3 and Word6s setting to file successfully";
- return;
- }
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Save APC profile setting to file successfully";
- }
- //===========================================================================
- void __fastcall TfrmApcProfile::HintTimerTimer(TObject *Sender)
- {
- HintTimer->Enabled = false;
- lblHint->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtBatteryCompensateCheck(TObject *Sender)
- {
- int i;
- unsigned short data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0.1 ~ 1.9 ";
- text = edit->Text;
- if( !IsValidBatteryCompensate( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- row = edit->Tag / 3;
- col = edit->Tag % 3;
- m_sRFCal_RamTable[m_eCurBand].rampData.battery_compensate[row][col] = data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnChangeDBClick(TObject *Sender)
- {
- frmMainSel->mnuFDMDatabaseClick(Sender);
- if( ! NVRAMMan->Get_IsInit())
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialization fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialization fail", "FAILURE", MB_OK );
- return;
- }
- stNVRAMDB->Caption = frmMainSel->Get_NVRAMDBFileName();
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString) " Change NVRAM database file successfully";
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnGUIRampClick(TObject *Sender)
- {
- frmGUIApcProfile->Top = 1;
- frmGUIApcProfile->Left = 77;
- frmGUIApcProfile->Show();
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::CurrentPageLock( void )
- {
- int i;
- // button
- // btnTXStart->Kind = bkNo;
- // btnTXStart->Caption = "Stop";
- btnTXStart->Enabled = false;
- btnTXStart->Tag = 1;
- btnUpLeft->Enabled = false;
- btnDnLeft->Enabled = false;
- btnUpRight->Enabled = false;
- btnDnRight->Enabled = false;
- btnUploadFromFlash->Enabled = false;
- btnDownloadToFlash->Enabled = false;
- btnChangeDB->Enabled = false;
- btnLoadFromFile->Enabled = false;
- btnSaveToFile->Enabled = false;
- btnSetCAL3ModeToRegister->Enabled = false;
-
- // for(i=0; i<TOTAL_PCL_DAC_NUM; i++ )
- // {
- // btnPCL[i]->Enabled = false;
- // }
- // editor
- // edtApcDcOffset->Enabled = false;
- // edtTestArfcn->Enabled = false;
-
- // PCL DAC
- // for( i=0; i<TOTAL_PCL_DAC_NUM; i++ )
- // { edtPCLDAC[i]->Enabled = false;
- // }
- // Ramp up, ramp down
- // for( i=0; i<TOTAL_RAMP_DOWN_NUM; i++ )
- // {
- // edtRampUp[i]->Enabled = false;
- // edtRampDn[i]->Enabled = false;
- // }
- // sub band weighting
- // for( i=0; i<TOTAL_SUBBAND_WEIGHT_NUM; i++ )
- // {
- // edtWtARFCN[i]->Enabled = false;
- // edtWtPCL[i]->Enabled = false;
- // edtWtHigh[i]->Enabled = false;
- // edtWtLow[i]->Enabled = false;
- // }
- // battery compensate
- // for( i=0; i<3; i++ )
- // {
- // for(int j=0; j<3; j++)
- // {
- // edtBatteryCompensateArray[i][j]->Enabled = false;
- // }
- // }
- // Tx AFC offset
- // pnlTxAfcOffset->Enabled = false;
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::CurrentPageReset( void )
- {
- int i;
- // button
- // btnTXStart->Kind = bkRetry;
- // btnTXStart->Caption = "Start";
- btnTXStart->Enabled = true;
- btnTXStart->Tag = 0;
- btnUpLeft->Enabled = true;
- btnDnLeft->Enabled = true;
- btnUpRight->Enabled = true;
- btnDnRight->Enabled = true;
- btnUploadFromFlash->Enabled = true;
- btnDownloadToFlash->Enabled = true;
- btnChangeDB->Enabled = true;
- btnLoadFromFile->Enabled = true;
- btnSaveToFile->Enabled = true;
- btnSetCAL3ModeToRegister->Enabled = true;
- #if 0
- for(i=0; i<TOTAL_PCL_DAC_NUM; i++ )
- {
- btnPCL[i]->Enabled = true;
- }
- // editor
- edtApcDcOffset->Enabled = true;
- edtTestArfcn->Enabled = true;
-
- // PCL DAC
- for( i=0; i<TOTAL_PCL_DAC_NUM; i++ )
- { edtPCLDAC[i]->Enabled = true;
- }
- // Ramp up, ramp down
- for( i=0; i<TOTAL_RAMP_DOWN_NUM; i++ )
- {
- edtRampUp[i]->Enabled = true;
- edtRampDn[i]->Enabled = true;
- }
- // sub band weighting
- for( i=0; i<TOTAL_SUBBAND_WEIGHT_NUM; i++ )
- {
- edtWtARFCN[i]->Enabled = true;
- edtWtPCL[i]->Enabled = true;
- edtWtHigh[i]->Enabled = true;
- edtWtLow[i]->Enabled = true;
- }
- // battery compensate
- for( i=0; i<3; i++ )
- {
- for(int j=0; j<3; j++)
- {
- edtBatteryCompensateArray[i][j]->Enabled = true;
- }
- }
- #endif
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtTxAfcOffsetCheck(TObject *Sender)
- {
- short sdata;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be -65536 ~ 65535 ";
- text = edit->Text;
- if (!IsValidTxAfcOffset(text, sdata))
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- m_sRFCal_RamTable[m_eCurBand].rampData.tx_afc_offset = sdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnTXStopClick(TObject *Sender)
- {
- if (START_TAG == btnTXStart->Tag)
- {
- frmRFTool->Force_RF_Stop();
- btnTXStart->Caption = "Start";
- btnTXStart->Tag = 0;
- frmRFTool->pctlToolSel->Enabled = true;
- frmRFTool->btnTXStart->Enabled = true;
- CurrentPageReset();
- frmRFTool->CurrentPageReset();
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Burst TX stop";
- }
- }
- //---------------------------------------------------------------------------
- //////////////////////////////// IP2 ////////////////////////////////
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Compose_C3Reg(int tn, int to, int pm, int &c3reg)
- {
- c3reg = tn << 11 | to << 7 | pm << 3 | 0x03;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::DeCompose_C3Reg(int c3reg, int &tn, int &to, int &pm)
- {
- tn = (c3reg >> 11) & 0x3F;
- to = (c3reg >> 7) & 0x0F;
- pm = (c3reg >> 3) & 0x0F;
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_RenesasUI( int band_mode )
- {
- m_uiFinalRFID = frmMainSel->Get_FinalRFID();
- if (RF_ID_BRIGHT5P == m_uiFinalRFID)
- {
- int bv=RF_APC_Obj->Get_BvMode();
- stBvmode->Caption = bv;
- btnSetCAL3ModeToRegister->Visible = true;
- pnlCAL3ModeHeader->Visible = true;
- pnlCAL3Mode->Visible = true;
- if( b5p_coef.tx.c3mode )
- {
- cbC3ModeEnable->Checked = true;
- lblTN->Visible = true;
- edtTN->Visible = true;
- lblTO->Visible = true;
- edtTO->Visible = true;
- Display_C3WordEditor();
- }
- else
- {
- cbC3ModeEnable->Checked = false;
- lblTN->Visible = false;
- edtTN->Visible = false;
- lblTO->Visible = false;
- edtTO->Visible = false;
- }
- pnlCAL3ModeHeader->Visible = true;
- pnlCAL3Mode->Visible = true;
- btnSetCAL3ModeToRegister->Visible = true;
- switch( band_mode )
- {
- case BANDSEL_GSM850:
- {
- Display_BVW64();
- }
- break;
- case BANDSEL_GSM900:
- {
- if( bv == 0 )
- {
- Display_BVW64();
- }
- else
- {
- Display_BVW65();
- }
- }
- break;
- case BANDSEL_DCS1800:
- {
- if( bv == 0 )
- {
- Display_BVW65();
- }
- else
- {
- Display_BVW66();
- }
- }
- break;
- case BANDSEL_PCS1900:
- {
- if( bv == 0 )
- {
- Display_BVW65();
- }
- else
- {
- Display_BVW67();
- }
- }
- break;
- }
- }
- else
- {
- btnSetCAL3ModeToRegister->Visible = false;
- //pnlWord3Header->Visible = false;
- //pnlWord3->Visible = false;
- pnlCAL3ModeHeader->Visible = false;
- pnlCAL3Mode->Visible = false;
- }
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_Word3(void)
- {
- m_uiFinalRFID = frmMainSel->Get_FinalRFID();
- if (RF_ID_BRIGHT5P == m_uiFinalRFID)
- {
- btnSetCAL3ModeToRegister->Visible = true;
- pnlCAL3ModeHeader->Visible = true;
- pnlCAL3Mode->Visible = true;
- if( b5p_coef.tx.c3mode )
- {
- cbC3ModeEnable->Checked = true;
- lblTN->Visible = true;
- edtTN->Visible = true;
- lblTO->Visible = true;
- edtTO->Visible = true;
- Display_C3WordEditor();
- }
- else
- {
- cbC3ModeEnable->Checked = false;
- lblTN->Visible = false;
- edtTN->Visible = false;
- lblTO->Visible = false;
- edtTO->Visible = false;
- }
- }
- else
- {
- btnSetCAL3ModeToRegister->Visible = false;
- pnlCAL3ModeHeader->Visible = false;
- pnlCAL3Mode->Visible = false;
- }
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_Word6s(int band_mode)
- {
- m_uiFinalRFID = frmMainSel->Get_FinalRFID();
- if (RF_ID_BRIGHT5P == m_uiFinalRFID)
- {
- int bv=RF_APC_Obj->Get_BvMode();
- stBvmode->Caption = bv;
- btnSetCAL3ModeToRegister->Visible = true;
- pnlCAL3ModeHeader->Visible = true;
- pnlCAL3Mode->Visible = true;
- switch (band_mode)
- {
- case BANDSEL_GSM850:
- {
- // Display_BVW64();
- if( bv == 0 )
- {
- Display_BVW66();
- }
- else
- {
- Display_BVW64();
- }
- }
- break;
- case BANDSEL_GSM900:
- {
- if( bv == 0 )
- {
- // Display_BVW64();
- Display_BVW66();
- }
- else
- {
- Display_BVW65();
- }
- }
- break;
- case BANDSEL_DCS1800:
- {
- if( bv == 0 )
- {
- // Display_BVW65();
- Display_BVW67();
- }
- else
- {
- Display_BVW66();
- }
- }
- break;
- case BANDSEL_PCS1900:
- {
- if( bv == 0 )
- {
- // Display_BVW65();
- Display_BVW67();
- }
- else
- {
- Display_BVW67();
- }
- }
- break;
- }
- }
- else
- {
- btnSetCAL3ModeToRegister->Visible = false;
- pnlCAL3ModeHeader->Visible = false;
- pnlCAL3Mode->Visible = false;
- }
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_C3WordEditor( void )
- {
- edtTN->Text = c3mode.uc_tn;
- edtTO->Text = c3mode.uc_to;
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_BVW64( void )
- {
- lblBVReg->Caption = "W6-4-0";
- edtAP->Text = bvw640.uc_ap;
- edtAS->Text = bvw640.uc_as;
- edtAO->Text = bvw640.uc_ao;
- edtBD->Text = bvw640.uc_bd;
- // edtAOF->Text = "0000000";
- // lblBVW12->Caption = "KSG";
- // lblBVW13->Caption = "KAG";
- // lblAOF->Visible = true;
- // edtAOF->Visible = true;
- // lblBVW12->Visible = true;
- // edtBVW12->Visible = true;
- // lblBVW13->Visible = true;
- // edtBVW13->Visible = true;
- // lblBVW14->Visible = false;
- // edtBVW14->Visible = false;
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_BVW65( void )
- {
- lblBVReg->Caption = "W6-5-0";
- edtAP->Text = bvw650.uc_ap;
- edtAS->Text = bvw650.uc_as;
- edtAO->Text = bvw650.uc_ao;
- edtBD->Text = bvw650.uc_bd;
- // edtAOF->Text = "0000000";
- // lblBVW12->Caption = "KSD";
- // lblBVW13->Caption = "KAD";
- // lblAOF->Visible = true;
- // edtAOF->Visible = true;
- // lblBVW12->Visible = true;
- // edtBVW12->Visible = true;
- // lblBVW13->Visible = true;
- // edtBVW13->Visible = true;
- // lblBVW14->Visible = false;
- // edtBVW14->Visible = false;
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_BVW66( void )
- {
- lblBVReg->Caption = "W6-6-0";
- edtAP->Text = bvw660.uc_ap;
- edtAS->Text = bvw660.uc_as;
- edtAO->Text = bvw660.uc_ao;
- edtBD->Text = bvw660.uc_bd;
- // lblBVW12->Caption = "ARE";
- // lblBVW13->Caption = "VOF";
- // lblBVW14->Caption = "VRE";
- // lblAOF->Visible = true;
- // edtAOF->Visible = true;
- // lblBVW12->Visible = true;
- // edtBVW12->Visible = true;
- // lblBVW13->Visible = true;
- // edtBVW13->Visible = true;
- // lblBVW14->Visible = true;
- // edtBVW14->Visible = true;
- }
- //----------------------------------------------------------------------------
- void TfrmApcProfile::Display_BVW67( void )
- {
- lblBVReg->Caption = "W6-7-0";
- edtAP->Text = bvw670.uc_ap;
- edtAS->Text = bvw670.uc_as;
- edtAO->Text = bvw670.uc_ao;
- edtBD->Text = bvw670.uc_bd;
- // lblAOF->Visible = false;
- // edtAOF->Visible = false;
- // lblBVW12->Visible = false;
- // edtBVW12->Visible = false;
- // lblBVW13->Visible = false;
- // edtBVW13->Visible = false;
- // lblBVW14->Visible = false;
- // edtBVW14->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::cbBVClick(TObject *Sender)
- {
- ReDrawFields(DRAW_BV);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtAPCheck(TObject *Sender)
- {
- int i;
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0 ~ 7 ";
- text = edit->Text;
- if( !IsValidBVAP( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( lblBVReg->Caption.AnsiCompareIC("W6-4-0") == 0 )
- {
- bvw640.uc_ap = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-5-0") == 0 )
- {
- bvw650.uc_ap = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6-0") == 0 )
- {
- bvw660.uc_ap = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-7-0") == 0 )
- {
- bvw670.uc_ap = data;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtASCheck(TObject *Sender)
- {
- int i;
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0 ~ 7 ";
- text = edit->Text;
- if( !IsValidBVAS( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( lblBVReg->Caption.AnsiCompareIC("W6-4-0") == 0 )
- {
- bvw640.uc_as = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-5-0") == 0 )
- {
- bvw650.uc_as = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6-0") == 0 )
- {
- bvw660.uc_as = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-7-0") == 0 )
- {
- bvw670.uc_as = data;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtAOCheck(TObject *Sender)
- {
- int i;
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0 ~ 63 ";
- text = edit->Text;
- if( !IsValidBVAO( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( lblBVReg->Caption.AnsiCompareIC("W6-4-0") == 0 )
- {
- bvw640.uc_ao = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-5-0") == 0 )
- {
- bvw650.uc_ao = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6-0") == 0 )
- {
- bvw660.uc_ao = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-7-0") == 0 )
- {
- bvw670.uc_ao = data;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtBDCheck(TObject *Sender)
- {
- int i;
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0 ~ 31 ";
- text = edit->Text;
- if( !IsValidBVBD( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- if( lblBVReg->Caption.AnsiCompareIC("W6-4-0") == 0 )
- {
- bvw640.uc_bd = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-5-0") == 0 )
- {
- bvw650.uc_bd = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6-0") == 0 )
- {
- bvw660.uc_bd = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-7-0") == 0 )
- {
- bvw670.uc_bd = data;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtAOFCheck(TObject *Sender)
- {
- #if 0
- int i;
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( lblBVReg->Caption.AnsiCompareIC("W6-4") == 0 ||
- lblBVReg->Caption.AnsiCompareIC("W6-5") == 0
- )
- {
- char hint[] = " value shall be 0 ~ 1 ";
- if( ! (edtAOF->Text.AnsiCompareIC("0") ==0 || edtAOF->Text.AnsiCompareIC("1") ==0) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6") == 0 )
- {
- char hint[] = " value shall be 0 ~ 127 ";
- if( !IsValidBVAOF( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- }
- bvw2[m_eCurBand].i_aof = data;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtBVW12Check(TObject *Sender)
- {
- #if 0
- int i;
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( lblBVReg->Caption.AnsiCompareIC("W6-4") == 0 )
- {
- char hint[] = " value shall be 0 ~ 15 ";
- if( !IsValidBVKSG( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- bvw2[m_eCurBand].i_ksg = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-5") == 0 )
- {
- char hint[] = " value shall be 0 ~ 15 ";
- if( !IsValidBVKSD( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- bvw2[m_eCurBand].i_ksd = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6") == 0 )
- {
- char hint[] = " value shall be 0 ~ 1 ";
- if( !IsValidBVARE( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- bvw2[m_eCurBand].i_are = data;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtBVW13Check(TObject *Sender)
- {
- #if 0
- int i;
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( lblBVReg->Caption.AnsiCompareIC("W6-4") == 0 )
- {
- char hint[] = " value shall be 0 ~ 31 ";
- if( !IsValidBVKAG( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- bvw2[m_eCurBand].i_kag = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-5") == 0 )
- {
- char hint[] = " value shall be 0 ~ 31 ";
- if( !IsValidBVKAD( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- bvw2[m_eCurBand].i_kad = data;
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6") == 0 )
- {
- char hint[] = " value shall be 0 ~ 127 ";
- if( !IsValidBVVOF( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- bvw2[m_eCurBand].i_vof = data;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtBVW14Check(TObject *Sender)
- {
- #if 0
- int data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( lblBVReg->Caption.AnsiCompareIC("W6-6") == 0 )
- {
- char hint[] = " value shall be 0 ~ 1 ";
- if( !IsValidBVVRE( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- bvw2[m_eCurBand].i_vre = data;
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtTNCheck(TObject *Sender)
- {
- unsigned char data;
- int row, col;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( cbC3ModeEnable->Checked )
- {
- if( !IsValidC3TN( text, data ) )
- {
- char hint[] = " value shall be 0 ~ 63 ";
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- c3mode.uc_tn = data;
- }
- // else
- // {
- // if( !IsValidC3TA( text, data ) )
- // {
- // char hint[] = " value shall be 0 ~ 7 ";
- // ShowHintLabel( edit, hint );
- // edit->SetFocus();
- // return;
- // }
- // c3[m_eCurBand].i_ta = data;
- // }
-
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtTOCheck(TObject *Sender)
- {
- unsigned char data;
- int row, col;
- char hint[] = " value shall be 0 ~ 15 ";
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( !IsValidC3TO( text, data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- c3mode.uc_to = data;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtPMCheck(TObject *Sender)
- {
- unsigned char ucdata;
- int row, col;
- char hint[] = " value shall be 0 ~ 15 ";
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if (!IsValidC3PM(text, ucdata))
- {
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- c3mode.uc_pm = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::cbC3ModeEnableClick(TObject *Sender)
- {
- if( cbC3ModeEnable->Checked )
- {
- // lblTC->Visible = false;
- // lblTB->Visible = false;
- // lblTATN->Caption = "TN";
- // lblTN->Visible = true;
- // edtTN->Visible = true;
- // lblTO->Visible = true;
- // edtTO->Visible = true;
- b5p_coef.tx.c3mode = 1;
- }
- else
- {
- // lblTC->Visible = true;
- // lblTB->Visible = true;
- // lblTATN->Caption = "TA";
- // lblTN->Visible = false;
- /// edtTN->Visible = false;
- // lblTO->Visible = false;
- // edtTO->Visible = false;
- b5p_coef.tx.c3mode = 0;
- }
- ReDrawFields( DRAW_WORD3 );
- ComposeRenesasField();
- isSetCal3ModeTrigger = false;
- RF_APC_Obj->ConfirmCallback = ::CNF_WriteApcToNVRAM;
- RF_APC_Obj->Req_SetB5PToReg( b5p_coef );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtTCCheck(TObject *Sender)
- {
- #if 0
- int data;
- int row, col;
- char hint[] = " value shall be 0 ~ 7 ";
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( !IsValidC3TC( text, data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- c3mode.uc_tc = data;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtTBCheck(TObject *Sender)
- {
- #if 0
- int data;
- int row, col;
- char hint[] = " value shall be 0 ~ 7 ";
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- text = edit->Text;
- if( !IsValidC3TB( text, data ) )
- {
- ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
- c3[m_eCurBand].i_tb = data;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::btnSetCAL3ModeToRegisterClick(TObject *Sender)
- {
- bool ok;
- unsigned int CurW6s;
- CurrentPageLock();
- ComposeRenesasField();
- isSetCal3ModeTrigger = true;
- RF_APC_Obj->ConfirmCallback = ::CNF_SetB5PToReg;
- RF_APC_Obj->Req_SetB5PToReg( b5p_coef );
- // if(!ok)
- // {
- // sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set CAL3 mode to register fail";
- /// Application->MessageBox( "Execution Fail : Set CAL3 mode to register", "FAIL", MB_OK );
- // return;
- // }
- // Get_CurrentWord6s( CurW6s );
- // ok = RF_APC_Obj->Set_W6sImmediateBSI( CurW6s );
- //
- // if(!ok)
- // {
- // sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set word6s to register fail";
- // Application->MessageBox( "Execution Fail : Set word6s to register", "FAIL", MB_OK );
- // return;
- //}
- //sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set word3, word6s to register successfully";
- //CurrentPageReset();
- }
- //-----------------------------------------------
- void TfrmApcProfile::CNF_SetB5PToReg( void )
- {
- // int state = RF_APC_Obj->ConfirmState;
- int state = RF_APC_Obj->Get_ConfirmState();
- unsigned int CurW6s;
- if( state==METAAPP_SUCCESS )
- {
- if( isSetCal3ModeTrigger )
- {
- Get_CurrentWord6s( CurW6s );
- RF_APC_Obj->ConfirmCallback = ::CNF_SetW6sImmediateBSI;
- RF_APC_Obj->REQ_SetW6sImmediateBSI_Start( CurW6s );
- return;
- }
- }
- else if( state==METAAPP_FAIL )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set CAL3 mode to register fail";
- Application->MessageBox( "Execution Fail : Set CAL3 mode to register", "FAIL", MB_OK );
- }
- else if( state==METAAPP_TIMEOUT )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set CAL3 mode to register timeout";
- Application->MessageBox( "Execution Timeout : Set CAL3 mode to register", "TIMEOUT", MB_OK );
- }
- else if( state==METAAPP_STOP )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set CAL3 mode to register stop";
- }
- CurrentPageReset();
- }
- //-----------------------------------------------
- void TfrmApcProfile::CNF_SetW6sImmediateBSI( void )
- {
- int state = RF_APC_Obj->Get_ConfirmState();
- if( state==METAAPP_SUCCESS )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set CAL3 mode to register successfully";
- }
- else if( state==METAAPP_FAIL )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set word6s to register fail";
- Application->MessageBox( "Execution Fail : Set word6s to register", "FAIL", MB_OK );
- }
- else if( state==METAAPP_TIMEOUT )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set word6s to register timeout";
- Application->MessageBox( "Execution Timeout : Set word6s to register", "TIMEOUT", MB_OK );
- }
- else if( state==METAAPP_STOP )
- {
- sbAPCProfile->Panels->Items[0]->Text = (AnsiString)" Set word6s to register stop";
- // Application->MessageBox( "Execution Stop : Set word6s to register", "STOP", MB_OK );
- }
- CurrentPageReset();
- }
- //-------------------------------------------------------------------------
- bool TfrmApcProfile::ComposeRenesasField( void )
- {
- if( cbC3ModeEnable->Checked )
- {
- b5p_coef.tx.c3mode = 1;
- }
- else
- {
- b5p_coef.tx.c3mode = 0;
- }
- RF_APC_Obj->Compose_wordC3( c3mode, b5p_coef.tx.wordC3);
- RF_APC_Obj->Compose_word6_4_0(bvw640, b5p_coef.tx.word6_4_0);
- RF_APC_Obj->Compose_word6_5_0(bvw650, b5p_coef.tx.word6_5_0);
- RF_APC_Obj->Compose_word6_6_0(bvw660, b5p_coef.tx.word6_6_0);
- RF_APC_Obj->Compose_word6_7_0(bvw670, b5p_coef.tx.word6_7_0);
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmApcProfile::DeComposeRenesasField( void )
- {
- RF_APC_Obj->DeCompose_wordC3( b5p_coef.tx.wordC3, c3mode );
- c3mode.c3mode = b5p_coef.tx.c3mode;
- RF_APC_Obj->DeCompose_word6_x_0(b5p_coef.tx.word6_4_0, bvw640);
- RF_APC_Obj->DeCompose_word6_x_0(b5p_coef.tx.word6_5_0, bvw650);
- RF_APC_Obj->DeCompose_word6_x_0(b5p_coef.tx.word6_6_0, bvw660);
- RF_APC_Obj->DeCompose_word6_x_0(b5p_coef.tx.word6_7_0, bvw670);
- return true;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::read_APC_files_setup( AnsiString asSetupFile, AnsiString asExeName )
- {
- AnsiString as_NVRAM_DB_File;
- AnsiString asPath;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- TIniFile *ini;
- try
- {
- ini = new TIniFile( asSetupFile );
- if(ini != NULL)
- {
- //stNVRAMDB->Caption = ini->ReadString("RF tool","NVRAM database file", "");
- // if ( stNVRAMDB->Caption.Length() >0)
- // {
- // read_APC_db_file( stNVRAMDB->Caption );
- // }
- as_NVRAM_DB_File = ini->ReadString("RF tool","NVRAM database file", "");
- if( read_db_file( as_NVRAM_DB_File ) )
- {
- UpdateDBFileCaption(as_NVRAM_DB_File);
- frmRFTool->UpdateDBFileCaption(as_NVRAM_DB_File);
- //frm8PskApcProfile->UpdateDBFileCaption(as_NVRAM_DB_File);
- }
- delete ini;
- ini = NULL;
- }
- }
- catch (...)
- {
- AnsiString as_warning_msg;
- as_warning_msg = " RF tool : read setup file : " + asSetupFile + " error ";
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- }
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::read_APC_db_file( AnsiString asFileName )
- {
- unsigned long nvram_idb;
- if( ! NVRAMMan->Get_IsInit() )
- {
- frmMainSel->FDMDatabaseInit( asFileName.c_str());
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- MessageBox(NULL, "Open NVRAM database error", NULL, MB_OK);
- }
- else
- {
- stNVRAMDB->Caption = asFileName;
-
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmApcProfile::read_db_file( AnsiString asFileName )
- {
- unsigned long nvram_idb;
- if(! NVRAMMan->Get_IsInit() || asFileName.AnsiCompareIC(NVRAMMan->Get_NVRAM_DB_File()) )
- {
- frmMainSel->FDMDatabaseInit( asFileName.c_str());
- }
- if(! NVRAMMan->Get_IsInit() )
- {
- Application->MessageBox( " Initialize NVRAM database fail", "Fail", MB_OK );
- return false;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::UpdateDBFileCaption(AnsiString asFileName)
- {
- stNVRAMDB->Caption = asFileName;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::write_APC_files_setup( AnsiString asSetupFile, AnsiString asExeName )
- {
- AnsiString asPath;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- TIniFile *ini;
- try
- {
- ini = new TIniFile( asSetupFile );
- if(ini != NULL)
- {
- ini->WriteString("RF tool","NVRAM database file", stNVRAMDB->Caption );
- delete ini;
- ini = NULL;
- }
- }
- catch (...)
- {
- AnsiString as_warning_msg;
- as_warning_msg = " RF tool : write setup file : " + asSetupFile + " error ";
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::FormClose(TObject *Sender,
- TCloseAction &Action)
- {
- if( stNVRAMDB->Caption.AnsiCompareIC("") != 0 )
- {
- write_APC_files_setup( "MF_setup.txt", Application->ExeName );
- }
- if( btnTXStart->Tag == 1)
- {
- btnTXStopClick(this);
- }
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Get_CurrentWord6s( unsigned int &cur_w6s )
- {
- if( lblBVReg->Caption.AnsiCompareIC("W6-4-0")==0 )
- {
- RF_APC_Obj->Compose_word6_4_0( bvw640, cur_w6s);
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-5-0")==0 )
- {
- RF_APC_Obj->Compose_word6_5_0( bvw650, cur_w6s);
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-6-0")==0 )
- {
- RF_APC_Obj->Compose_word6_6_0( bvw660, cur_w6s);
- }
- else if( lblBVReg->Caption.AnsiCompareIC("W6-7-0")==0 )
- {
- RF_APC_Obj->Compose_word6_7_0( bvw670, cur_w6s);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtAfcDacCheck(TObject *Sender)
- {
- short sdata;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~8191 ";
- text = edit->Text;
- if (!IsValidAFC(text, sdata))
- {
- ShowHintLabel(edit, hint);
- edit->Text = IntToStr(Default_AFC);
- edit->SetFocus();
- return;
- }
- }
- //---------------------------------------------------------------------------
- //===========================================================================
- //////////////////////////////// Global information /////////////////////////
- //===========================================================================
- void TfrmApcProfile::Set_RF_APC_Obj( CRFAPC *rf_apc_obj )
- {
- RF_APC_Obj = rf_apc_obj;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Set_RF_TX_Obj( CRFTX *rf_tx_obj )
- {
- RF_TX_Obj = rf_tx_obj;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Init(void)
- {
- m_bInit = true;
- m_bTADOSupport = false;
- CurrentPageReset();
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Set_Tsc( int tsc )
- {
- m_cTsc = tsc;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Set_AfcDac( int afc_dac )
- {
- m_sAfcDac = afc_dac;
- }
- //---------------------------------------------------------------------------
- void TfrmApcProfile::Set_BurstType(APCTxPattern burst_type)
- {
- m_eBurstType = burst_type;
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtLowApcDcOffsetCheck(TObject *Sender)
- {
- unsigned short usdata;
- int band = m_eCurBand;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[] = " value shall be 0~1023 ";
- text = edit->Text;
- if (!IsValidPCLDac(text, usdata))
- {
- ShowHintLabel(edit, hint);
- edit->SetFocus();
- return;
- }
- m_usLowApcDcOffset[band] = usdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmApcProfile::edtAPCLowestPowerCheck(TObject *Sender)
- {
- int i_data;
- int band = m_eCurBand;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[][256] =
- {
- " value shall be 0~36 ",
- " value shall be 0~33 ",
- " value shall be 0~33 ",
- " value shall be 0~36 ",
- };
- text = edit->Text;
- if( !IsValidApcLowestPower( text, m_eCurBand, i_data ) )
- { ShowHintLabel( edit, hint[m_eCurBand] );
- edit->SetFocus();
- return;
- }
- m_iApcLowestPower[band] = i_data;
- }
- //---------------------------------------------------------------------------