form_InterSlotRampSetting.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:39k
源码类别:
MTK
开发平台:
C++ Builder
- /*****************************************************************************
- * 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_InterSlotRampSetting.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Inter slot ramp setting 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
- #include "form_InterSlotRampSetting.h"
- //#include "form_RFApcProfile.h"
- #include "form_main.h"
- #include "misc.h"
- #include "man_fdm.h"
- #ifndef _RF_COMMON_H_
- #include "rf_common.h"
- #endif
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TfrmInterSlotRampSetting *frmInterSlotRampSetting;
- HANDLE p_MultiTxStop_Event;
- //=============================================================================
- static void CNF_WriteToNVRAM( void )
- { frmInterSlotRampSetting->DownloadToFlashDone();
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadFromNVRAM( void )
- { frmInterSlotRampSetting->UploadFromFlashDone();
- }
- //---------------------------------------------------------------------------
- static void ConfirmCallback_MultiSlotTX( void )
- {
- frmInterSlotRampSetting->ConfirmCallback_MultiSlotTX();
- }
- //--------------------------------------------------------------------------
- static void ConfirmCallback_QueryRfMsCapability( void )
- {
- frmRFTool->ConfirmCallback_QueryRfMsCapability();
- }
- //=============================================================================
- void TfrmInterSlotRampSetting::Init(void)
- {
- m_bInit = true;
- }
- //----------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::FormCreate(TObject *Sender)
- {
- isInterRampCircleOnDrag = false;
- isDragTrigger = false;
- Init();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::FormActivate(TObject *Sender)
- {
- if (m_bInit)
- {
- m_bInit = false;
- m_bMultiSlotTxExSupport = frmRFTool->Get_MultiSlotTxExSupport();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::ConfirmCallback_MultiSlotTX( void )
- {
- E_METAAPP_RESULT_T state = RF_MULTI_SLOT_TX_Obj->Get_ConfirmState();
- if (isDragTrigger)
- {
- imRampProfile->Enabled = true;
- isDragTrigger = false;
- }
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Multi slot TX progressing";
- }
- break;
- case METAAPP_FAIL:
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Multi slot TX fail";
- Application->MessageBox( "Execution Failure : Multi slot TX", "FAILURE", MB_OK );
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_TIMEOUT:
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Multi slot TX timeout";
- Application->MessageBox("Execution Timeout : Multi slot TX", "TIMEOUT", MB_OK);
- frmRFTool->Force_RF_Stop();
- CurrentPageReset();
- }
- break;
- case METAAPP_STOP:
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Multi slot TX stop";
- }
- break;
- default:
- {
- }
- break;
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmInterSlotRampSetting::CheckFields( void )
- {
- int i;
- unsigned char ucdata[16];
- int band = m_eCurBand;
- AnsiString text;
- for(i=0; i<16; i++)
- {
- text = edtInterRamp[i]->Text; if( !IsValidRamp( text, ucdata[i] ) ) { edtInterRampCheck(edtInterRamp[i]); return(false); }
- }
- for(i=0; i<16; i++)
- {
- Inter_RamTable[band].interRampData[i] = ucdata[i];
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::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;
- }
- //---------------------------------------------------------------------------
- __fastcall TfrmInterSlotRampSetting::TfrmInterSlotRampSetting(TComponent* Owner)
- : TForm(Owner)
- {
- m_sTestArfcn[BANDSEL_GSM900 ] = 0;
- m_sTestArfcn[BANDSEL_DCS1800] = 512;
- m_sTestArfcn[BANDSEL_PCS1900] = 512;
- m_sTestArfcn[BANDSEL_GSM850] = 128;
- lastTabIndex = 0; // GSM 900
- edtInterRamp[ 0]=edtInterRamp00;
- edtInterRamp[ 1]=edtInterRamp01;
- edtInterRamp[ 2]=edtInterRamp02;
- edtInterRamp[ 3]=edtInterRamp03;
- edtInterRamp[ 4]=edtInterRamp04;
- edtInterRamp[ 5]=edtInterRamp05;
- edtInterRamp[ 6]=edtInterRamp06;
- edtInterRamp[ 7]=edtInterRamp07;
- edtInterRamp[ 8]=edtInterRamp08;
- edtInterRamp[ 9]=edtInterRamp09;
- edtInterRamp[10]=edtInterRamp10;
- edtInterRamp[11]=edtInterRamp11;
- edtInterRamp[12]=edtInterRamp12;
- edtInterRamp[13]=edtInterRamp13;
- edtInterRamp[14]=edtInterRamp14;
- edtInterRamp[15]=edtInterRamp15;
- lblVertical[0] = lblVertical0;
- lblVertical[1] = lblVertical1;
- lblVertical[2] = lblVertical2;
- lblVertical[3] = lblVertical3;
- lblVertical[4] = lblVertical4;
- lblVertical[5] = lblVertical5;
- lblVertical[6] = lblVertical6;
- lblVertical[7] = lblVertical7;
- lblVertical[8] = lblVertical8;
- lblVertical[9] = lblVertical9;
- lblRampH[0] = lblRampH0;
- lblRampH[1] = lblRampH1;
- lblRampH[2] = lblRampH2;
- lblRampH[3] = lblRampH3;
- lblRampH[4] = lblRampH4;
- lblRampH[5] = lblRampH5;
- lblRampH[6] = lblRampH6;
- lblRampH[7] = lblRampH7;
- lblRampH[8] = lblRampH8;
- lblRampH[9] = lblRampH9;
- lblRampH[10] = lblRampH10;
- lblRampH[11] = lblRampH11;
- lblRampH[12] = lblRampH12;
- lblRampH[13] = lblRampH13;
- lblRampH[14] = lblRampH14;
- lblRampH[15] = lblRampH15;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnLoadFromFileClick(
- TObject *Sender)
- {
- char str[512];
- bool ok;
- int band;
- int total_band_num;
- ok = OpenDialog->Execute();
- if( !ok )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Load inter slot ramp profile from file fail";
- return;
- }
- strcpy( str, OpenDialog->FileName.c_str() );
- ok = RF_INTER_SLOT_RAMP_Obj.REQ_Read_From_File( str );
- if( ok )
- {
- if(frmMainSel->cbGSM850->Checked)
- //frmMainSel->Get_FinalBandSupport( band_support );
- //if( band_support.GSM850 )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for(band=0; band<total_band_num; band++)
- { Inter_RamTable[band] = RF_INTER_SLOT_RAMP_Obj.Inter_RamTable[band];
- }
- ReDrawFields(DRAW_INTER_RAMP);
- sbISR->Panels->Items[0]->Text = (AnsiString) " Load inter slot ramp profile from file successfully";
- }
- else
- { Application->MessageBox( "Execution Failure : Load APC profile from file", "FAILURE", MB_OK );
- sbISR->Panels->Items[0]->Text = (AnsiString) " Load inter slot ramp profile from file fail";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnSaveToFileClick(
- TObject *Sender)
- {
- char str[512];
- bool ok;
- int band, i;
- int total_band_num;
- ok = CheckFields();
- if(!ok)
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Save inter slot ramp profile to file fail";
- Application->MessageBox( "Execution Failure : Save inter slot ramp profile to file", "FAILURE", MB_OK );
- return;
- }
- ok = SaveDialog->Execute();
- if( !ok )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Save inter slot ramp profile to file fail";
- return;
- }
- if(frmMainSel->cbGSM850->Checked)
- //frmMainSel->Get_FinalBandSupport( band_support );
- //if( band_support.GSM850 )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for(band=0; band<total_band_num; band++)
- {
- for(i=0; i<16; i++)
- {
- RF_INTER_SLOT_RAMP_Obj.Inter_RamTable[band].interRampData[i] = Inter_RamTable[band].interRampData[i];
- }
- }
- strcpy( str, SaveDialog->FileName.c_str() );
- ok = RF_INTER_SLOT_RAMP_Obj.REQ_Write_To_File( str );
- if( !ok )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Save inter slot ramp profile to file fail";
- Application->MessageBox( "Execution Failure : Save Inter slot ramp profile to file", "FAILURE", MB_OK );
- return;
- }
- sbISR->Panels->Items[0]->Text = (AnsiString) " Save inter slot ramp profile to file successfully";
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::ReDrawFields( int draw_mask )
- {
- int i;
- int band = m_eCurBand;
- char str[256];
- if(draw_mask&DRAW_INTER_RAMP)
- {
- for(i=0; i<16; i++)
- {
- edtInterRamp[i]->Text = Inter_RamTable[band].interRampData[i];
- }
- }
- }
- //------------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::FormShow(TObject *Sender)
- {
- static bool init=true;
- if(init)
- {
- ReDrawFields(DRAW_RAMP);
- init = false;
- }
- PlotCurve( PLOT_INTER_RAMP_GRID | PLOT_INTER_RAMP_PROFILE_CURVE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::tclInterSlotRampSettingChange(
- TObject *Sender)
- {
- if (!frmMainSel->cbGSM850->Checked)
- {
- if (BANDSEL_GSM850 == (E_BANDSEL) tclInterSlotRampSetting->TabIndex)
- {
- tclInterSlotRampSetting->TabIndex = lastTabIndex;
- Application->MessageBox( "Please check GSM 850 on main menu", "FAILURE", MB_OK );
- return;
- }
- }
- if( !CheckFields() )
- {
- tclInterSlotRampSetting->TabIndex = m_eCurBand;
- return;
- }
- m_eCurBand = (E_BANDSEL) tclInterSlotRampSetting->TabIndex;
- lastTabIndex = tclInterSlotRampSetting->TabIndex;
- if (BTN_TAG_START == btnTXStart->Tag)
- {
- btnTXStopClick(this);
- }
- ReDrawFields( DRAW_INTER_RAMP );
- PlotCurve( PLOT_INTER_RAMP_GRID | PLOT_INTER_RAMP_PROFILE_CURVE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::edtInterRampCheck(
- 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;
- }
- Inter_RamTable[m_eCurBand].interRampData[edit->Tag] = ucdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::HintTimerTimer(TObject *Sender)
- {
- HintTimer->Enabled = false;
- lblHint->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnRightClick(TObject *Sender)
- {
- int i;
- for(i=15; i>=1; i--)
- {
- Inter_RamTable[m_eCurBand].interRampData[i] =
- Inter_RamTable[m_eCurBand].interRampData[i-1];
- OldInter_RamTable[m_eCurBand].interRampData[i] =
- OldInter_RamTable[m_eCurBand].interRampData[i-1];
- }
- ReDrawFields( DRAW_INTER_RAMP );
- PlotCurve( PLOT_INTER_RAMP_GRID | PLOT_INTER_RAMP_PROFILE_CURVE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnLeftClick(TObject *Sender)
- {
- //TButton *button = (TButton*)Sender;
- int i;
- for(i=0; i<15; i++)
- {
- Inter_RamTable[m_eCurBand].interRampData[i] =
- Inter_RamTable[m_eCurBand].interRampData[i+1];
- OldInter_RamTable[m_eCurBand].interRampData[i] =
- OldInter_RamTable[m_eCurBand].interRampData[i+1];
- }
- ReDrawFields( DRAW_INTER_RAMP );
- PlotCurve( PLOT_INTER_RAMP_GRID | PLOT_INTER_RAMP_PROFILE_CURVE );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnDownloadToFlashClick(TObject *Sender)
- {
- int band, i;
- int total_band_num;
- if( !CheckFields() ) return;
- if( ! NVRAMMan->Get_IsInit() )
- { frmMainSel->mnuFDMDatabaseClick(Sender);
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialize fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialize fail", "FAILURE", MB_OK );
- return;
- }
- if(frmMainSel->cbGSM850->Checked)
- //frmMainSel->Get_FinalBandSupport( band_support );
- //if( band_support.GSM850 )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for(band=0; band<total_band_num; band++)
- {
- for(i=0; i<16; i++)
- {
- RF_INTER_SLOT_RAMP_Obj.Inter_RamTable[band].interRampData[i] = Inter_RamTable[band].interRampData[i];
- }
- }
- RF_INTER_SLOT_RAMP_Obj.ConfirmCallback = ::CNF_WriteToNVRAM;
- RF_INTER_SLOT_RAMP_Obj.REQ_Write_To_NVRAM();
- btnUploadFromFlash->Enabled = false;
- btnDownloadToFlash->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnUploadFromFlashClick(
- TObject *Sender)
- {
- if( ! NVRAMMan->Get_IsInit() )
- { frmMainSel->mnuFDMDatabaseClick(Sender);
- }
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialize fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialize fail", "FAILURE", MB_OK );
- return;
- }
- RF_INTER_SLOT_RAMP_Obj.ConfirmCallback = ::CNF_ReadFromNVRAM;
- RF_INTER_SLOT_RAMP_Obj.REQ_Read_From_NVRAM();
- btnUploadFromFlash->Enabled = false;
- btnDownloadToFlash->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::DownloadToFlashDone( void )
- {
- int state = RF_INTER_SLOT_RAMP_Obj.Get_ConfirmState();
- btnUploadFromFlash->Enabled = true;
- btnDownloadToFlash->Enabled = true;
- if( state==STATE_INTER_SLOT_RAMP_OK )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Download inter slot ramp profile to flash successfully";
- // ReDrawFields(DRAW_RAMP);
- if( isDragTrigger )
- {
- btnTXStartClick( this );
- //SetEvent(p_TxStart_Event);
- }
- }
- else if( state==STATE_INTER_SLOT_RAMP_FAIL )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Download inter slot ramp profile to flash fail, please check the version of load and NVRAM database are same.";
- Application->MessageBox( "Execution Failure : Download inter slot ramp profile to flash, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
- }
- else if( state==STATE_INTER_SLOT_RAMP_TIMEOUT )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Download inter slot ramp profile to flash timeout";
- Application->MessageBox( "Execution Timeout : Download inter slot ramp profile to flash", "TIMEOUT", MB_OK );
- }
- else if( state==STATE_INTER_SLOT_RAMP_STOP )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Download inter slot ramp profile to flash stop";
- }
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::UploadFromFlashDone( void )
- {
- int state = RF_INTER_SLOT_RAMP_Obj.Get_ConfirmState();
- int band, i;
- btnUploadFromFlash->Enabled = true;
- btnDownloadToFlash->Enabled = true;
- if( state==STATE_INTER_SLOT_RAMP_OK )
- {
- int total_band_num;
- if(frmMainSel->cbGSM850->Checked)
- //frmMainSel->Get_FinalBandSupport( band_support );
- //if( band_support.GSM850 )
- { total_band_num = 4;
- }
- else
- {
- total_band_num = 3;
- }
- for(band=0; band<total_band_num; band++)
- {
- // for(i=0; i<16; i++)
- // {
- // Inter_RamTable[band].interRampData[i] = RF_INTER_SLOT_RAMP_Obj.Inter_RamTable[band].interRampData[i];
- // }
- Inter_RamTable[band] = RF_INTER_SLOT_RAMP_Obj.Inter_RamTable[band];
- }
- if( InterRampDataChange( &Inter_RamTable[m_eCurBand], &OldInter_RamTable[m_eCurBand] ) )
- {
- for(band=0; band<total_band_num; band++)
- {
- OldInter_RamTable[band] = Inter_RamTable[band];
- }
- PlotCurve( PLOT_INTER_RAMP_GRID | PLOT_INTER_RAMP_PROFILE_CURVE );
- }
- ReDrawFields(DRAW_INTER_RAMP);
- sbISR->Panels->Items[0]->Text = (AnsiString) " Upload inter slot ramp profile from flash successfully";
- }
- else if( state==STATE_INTER_SLOT_RAMP_FAIL )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Upload inter slot ramp profile from flash fail, please check the version of load and NVRAM database are same.";
- Application->MessageBox( "Execution Failure : Upload APC profile from flash, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
- }
- else if( state==STATE_INTER_SLOT_RAMP_TIMEOUT )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Upload inter slot ramp profile from flash timeout";
- Application->MessageBox( "Execution Timeout : Upload APC profile from flash", "TIMEOUT", MB_OK );
- }
- else if( state==STATE_INTER_SLOT_RAMP_STOP )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " Upload inter slot ramp profile from flash stop";
- }
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnChangeDBClick(TObject *Sender)
- {
- frmMainSel->mnuFDMDatabaseClick(Sender);
- if( ! NVRAMMan->Get_IsInit() )
- {
- sbISR->Panels->Items[0]->Text = (AnsiString) " NVRAM database file initialization fail";
- Application->MessageBox( "Execution Failure : NVRAM database file initialization fail", "FAILURE", MB_OK );
- return;
- }
- sbISR->Panels->Items[0]->Text = (AnsiString) " Change NVRAM database file successfully";
- }
- //---------------------------------------------------------------------------
- //==============================================================================
- void TfrmInterSlotRampSetting::ClearImage( void )
- {
- imRampProfile->Canvas->Brush->Color = clWhite;
- imRampProfile->Canvas->Brush->Style = bsSolid;
- imRampProfile->Canvas->FillRect(Rect(0,0,imRampProfile->Width,imRampProfile->Height));
- }
- //--------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::PlotCurve( int plot_mask )
- {
- // plot grid
- double min_y, max_y;
- if( plot_mask & PLOT_INTER_RAMP_GRID )
- {
- PlotGrid( 0, 32, 0, 255);
- }
- // plot ramp profile curve
- if( plot_mask & PLOT_INTER_RAMP_PROFILE_CURVE )
- {
- PlotRampProfileCurve();
- PlotRampProfileCircle();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::PlotGrid(int min_x, int max_x, int min_y, int max_y)
- {
- int i;
- double range;
- ClearImage();
- max_y_grid = max_y;
- min_y_grid = min_y - 40;
- range = max_y_grid - min_y_grid;
- for( i=1; i<=100; i++ )
- {
- vScale = i*INTER_RAMP_VSCALE_UNIT;
- if( vScale * 8 > range)
- {
- break;
- }
- }
- vDistance = imRampProfile->Height / (range +10) * vScale;
- Segments = (range / vScale) + 1;
- imRampProfile->Canvas->Pen->Color = clBlack;
- imRampProfile->Canvas->Pen->Width = 1;
- imRampProfile->Canvas->Pen->Style = psDot;
- // plot horizotal grid & label
- for( i=0; i<Segments && i<INTER_RAMP_VERTICAL_LABEL_NUM; i++ )
- {
- if( (i*vDistance + vStart) > imRampProfile->Height || (i*vScale) > MAX_INTER_RAMP_DATA_VALUE )
- {
- lblVertical[i]->Visible = true;
- lblVertical[i]->Top = imRampProfile->Top + imRampProfile->Height - vDistance*(1.0*MAX_INTER_RAMP_DATA_VALUE/vScale) - vStart - 5 ;
- lblVertical[i]->Left = imRampProfile->Left - 20;
- lblVertical[i]->Caption = (AnsiString) "255";
- imRampProfile->Canvas->MoveTo( 1, imRampProfile->Height - vDistance*(1.0*MAX_INTER_RAMP_DATA_VALUE/vScale) - vStart );
- imRampProfile->Canvas->LineTo( 1 + imRampProfile->Width, imRampProfile->Height - vDistance*(1.0*MAX_INTER_RAMP_DATA_VALUE/vScale) - vStart );
- Segments = i;
- break;
- }
- lblVertical[i]->Visible = true;
- lblVertical[i]->Top = imRampProfile->Top + imRampProfile->Height - i*vDistance - vStart - 5 ;
- lblVertical[i]->Left = imRampProfile->Left - 20;
- lblVertical[i]->Caption = IntToStr( i*vScale );
- imRampProfile->Canvas->MoveTo( 1, imRampProfile->Height - i*vDistance - vStart );
- imRampProfile->Canvas->LineTo( 1 + imRampProfile->Width, imRampProfile->Height - i*vDistance - vStart );
- }
- for(i=Segments+1; i<INTER_RAMP_VERTICAL_LABEL_NUM; i++)
- {
- lblVertical[i]->Visible = false;
- }
- // plot vertical grid
- lblRampH[0]->Left = imRampProfile->Left - 5;
- lblRampH[0]->Top = imRampProfile->Top + imRampProfile->Height + 5;
- lblRampH[0]->Caption = IntToStr(0);
- hDistance = imRampProfile->Width / INTER_RAMP_SAMPLE_NUM ;
- for( i=1; i<INTER_RAMP_SAMPLE_NUM; i++ )
- {
- imRampProfile->Canvas->MoveTo( i * hDistance, 1 );
- imRampProfile->Canvas->LineTo( i * hDistance, imRampProfile->Height );
- if( i<INTER_RAMP_SAMPLE_NUM) // ramp
- {
- lblRampH[i]->Left = imRampProfile->Left + i * hDistance - 5;
- lblRampH[i]->Top = imRampProfile->Top + imRampProfile->Height + 5;
- lblRampH[i]->Caption = IntToStr(i);
- }
- }
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::PlotRampProfileCurve( void )
- {
- int i;
- // isOrgCurvePlot = true;
- imRampProfile->Canvas->Pen->Color = clBlue;
- imRampProfile->Canvas->Pen->Width = 1;
- imRampProfile->Canvas->Pen->Style = psSolid;
- // ramp
- imRampProfile->Canvas->MoveTo( 1, imRampProfile->Height - vDistance*(1.0*(Inter_RamTable[m_eCurBand].interRampData[0])/vScale) - vStart ) ;
- for( i=0; i<INTER_RAMP_SAMPLE_NUM; i++)
- {
- InterRampPoint.x[i] = hDistance*i;
- InterRampPoint.y[i] = imRampProfile->Height - vDistance*(1.0*( Inter_RamTable[m_eCurBand].interRampData[i])/vScale )- vStart;
- imRampProfile->Canvas->LineTo( InterRampPoint.x[i], InterRampPoint.y[i] );
- }
- // midamble
- // imRampProfile->Canvas->Pen->Color = clPurple;
- // imRampProfile->Canvas->Pen->Width = 1;
- // imRampProfile->Canvas->Pen->Style = psSolid;
- // imRampProfile->Canvas->MoveTo( hDistance*(INTER_RAMP_SAMPLE_NUM-1), imRampProfile->Height - vDistance*(1.0*MAX_INTER_RAMP_DATA_VALUE/vScale )- vStart );
- // imRampProfile->Canvas->LineTo( hDistance*(INTER_RAMP_SAMPLE_NUM-1), imRampProfile->Height - vDistance*(1.0*MAX_INTER_RAMP_DATA_VALUE/vScale )- vStart );
- }
- //------------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::PlotRampProfileCircle( void )
- {
- imRampProfile->Canvas->Brush->Color = clLime;
- // ramp
- for(int i=0; i<INTER_RAMP_SAMPLE_NUM; i++)
- {
- imRampProfile->Canvas->Ellipse(InterRampPoint.x[i]-INTER_RAMP_CIRCLE_RADIOUS, InterRampPoint.y[i]-INTER_RAMP_CIRCLE_RADIOUS, InterRampPoint.x[i]+INTER_RAMP_CIRCLE_RADIOUS, InterRampPoint.y[i]+INTER_RAMP_CIRCLE_RADIOUS);
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmInterSlotRampSetting::InterRampDataChange(l1cal_interRampData_T *p_Inter_RamTable1, l1cal_interRampData_T *p_Inter_RamTable2)
- {
- for(int i=0; i<INTER_RAMP_SAMPLE_NUM; i++)
- {
- if( p_Inter_RamTable1->interRampData[i] != p_Inter_RamTable2->interRampData[i] )
- {
- return true;
- }
- }
- return false;
- }
- //------------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::imRampProfileDragOver(
- TObject *Sender, TObject *Source, int X, int Y, TDragState State,
- bool &Accept)
- {
- if( State == dsDragEnter )
- {
- CheckFields( );
- // char buf[20];
- // sprintf(buf, " (x=%d, y=%d) ", X, Y);
- // sbAudioCal->Panels->Items[0]->Text = (AnsiString) buf;
- // ramp
- for(int i=0; i<INTER_RAMP_SAMPLE_NUM; i++)
- {
- if( InterRampPoint.x[i]-INTER_RAMP_CIRCLE_RADIOUS<=X && X<=InterRampPoint.x[i]+INTER_RAMP_CIRCLE_RADIOUS &&
- InterRampPoint.y[i]-INTER_RAMP_CIRCLE_RADIOUS<=Y && Y<=InterRampPoint.y[i]+INTER_RAMP_CIRCLE_RADIOUS )
- {
- isInterRampCircleOnDrag = true;
- RampCircleOnDragIndex = i;
- if( btnTXStart->Tag == BTN_TAG_START )
- {
- p_MultiTxStop_Event = CreateEvent(NULL, TRUE, FALSE, NULL);
- ResetEvent( p_MultiTxStop_Event );
- btnTXStopClick( this ); // stop TX burst
- WaitForSingleObject( p_MultiTxStop_Event, 5000 );
- }
- return;
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::imRampProfileEndDrag(
- TObject *Sender, TObject *Target, int X, int Y)
- {
- if( isInterRampCircleOnDrag )
- {
- int result;
- if( X == 0 && Y == 0 ) // outside image
- {
- Application->MessageBox( " Destination coordinates is outside image range", "Warning", MB_OK );
- return;
- }
- result = ImageRangeCheck(X, Y);
- if( result == OUT_OF_TOP_RANGE )
- {
- Y = imRampProfile->Height - vDistance*(1.0*(255)/vScale) - vStart;
- }
- else if( result == OUT_OF_BOTTOM_RANGE )
- {
- Y = imRampProfile->Height - vStart;
- }
- if( isInterRampCircleOnDrag ) // ramp up
- {
- InterRampPoint.y[RampCircleOnDragIndex] = Y;
- UpdateInterRampdata( RampCircleOnDragIndex );
- isInterRampCircleOnDrag = false;
- }
- PlotCurve( PLOT_INTER_RAMP_GRID | PLOT_INTER_RAMP_PROFILE_CURVE );
- ReDrawFields( DRAW_INTER_RAMP );
- isDragTrigger = true;
- imRampProfile->Enabled = false;
- //p_TxStart_Event = CreateEvent(NULL, TRUE, FALSE, NULL);
- // ResetEvent( p_TxStart_Event );
- btnDownloadToFlashClick( this );
- //WaitForSingleObject( p_TxStart_Event, 5000 );
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnTXStartClick(TObject *Sender)
- {
- AnsiString text;
- if (1 == btnTXStart->Tag)
- {
- return;
- }
- frmRFTool->Force_RF_Stop();
- TimeSlotMask = 0; // initial value
- if (frmRFTool->cbTimeSlot0->Checked)
- {
- TimeSlotMask = TimeSlotMask | 0x01;
- }
- if (frmRFTool->cbTimeSlot1->Checked)
- {
- TimeSlotMask = TimeSlotMask | 0x02;
- }
- if (frmRFTool->cbTimeSlot2->Checked)
- {
- TimeSlotMask = TimeSlotMask | 0x04;
- }
- if (frmRFTool->cbTimeSlot3->Checked)
- {
- TimeSlotMask = TimeSlotMask | 0x08;
- }
- m_eCurBand = (E_BANDSEL) frmRFTool->cbxMultiSlotTxBand->ItemIndex;
- Tsc = frmRFTool->cbxMultiSlotTxTSC->ItemIndex;
- CS[0] = frmRFTool->cbxCSTS0->ItemIndex + 1;
- CS[1] = frmRFTool->cbxCSTS1->ItemIndex + 1;
- CS[2] = frmRFTool->cbxCSTS2->ItemIndex + 1;
- CS[3] = frmRFTool->cbxCSTS3->ItemIndex + 1;
- // text = edtTestArfcn->Text; if( !IsValidARFCN( text, m_eCurBand, arfcn ) ) { edtArfcnCheck(edtTestArfcn); return; }
- text = frmRFTool->edtPCLTS0->Text; if( !IsValidPCL( text, m_eCurBand, PCL[0] ) ) { PCL[0]=10; return; }
- text = frmRFTool->edtPCLTS1->Text; if( !IsValidPCL( text, m_eCurBand, PCL[1] ) ) { PCL[1]=10; return; }
- text = frmRFTool->edtPCLTS2->Text; if( !IsValidPCL( text, m_eCurBand, PCL[2] ) ) { PCL[2]=10; return; }
- text = frmRFTool->edtPCLTS3->Text; if( !IsValidPCL( text, m_eCurBand, PCL[3] ) ) { PCL[3]=10; return; }
- text = frmRFTool->edtMultiSlotTxAFC->Text; if( !IsValidAFC( text, m_sAfcDac ) ) { m_sAfcDac = 4100; return; }
- text = frmRFTool->edtMultiSlotTxTA->Text; if( !IsValidTA( text, TA ) ) { TA = 0; return; }
- if( frmRFTool->gbMultiSlotTxBurstType->Visible )
- {
- isEDGEsupport = true;
- if( frmRFTool->rbMultiSlotTxNBAll0->Checked ) Pattern = NB_TX_ALL_ZEROS_WITHOUT_TSC;
- else if( frmRFTool->rbMultiSlotTxNBAll1->Checked ) Pattern = NB_TX_ALL_ONES_WITHOUT_TSC;
- else if( frmRFTool->rbMultiSlotTxNB->Checked ) Pattern = NB_TX_RANDOM_WITH_TSC;
- else Pattern = NB_TX_PATTERN_WITHOUT_TSC;
- if( frmRFTool->rbMultiSlotTxPattern->Checked )
- {
- text = frmRFTool->edtMultiSlotTxPattern->Text; if( !IsValidMultiSlotTxPattern( text, Pattern_data ) ) { Pattern_data = 0101010101010101; return; }
- }
- }
- else
- {
- isEDGEsupport = false;
- }
- CurrentPageLock();
- frmRFTool->CurrentPageLock();
- S_MULTI_SLOT_TX_T multi_slot_tx;
- multi_slot_tx.b_MultiSlotTXExSupport = m_bMultiSlotTxExSupport;
- multi_slot_tx.e_bandsel = (E_BANDSEL)m_eCurBand;
- multi_slot_tx.req.arfcn = m_sTestArfcn[m_eCurBand];
- multi_slot_tx.req.bsic = Tsc;
- multi_slot_tx.req.timeSlotmask = TimeSlotMask;
- for (int i=0; i<4; i++)
- {
- multi_slot_tx.req.powerLev[i] = PCL[i];
- multi_slot_tx.req.cs[i] = (CodingScheme) CS[i];
- }
- multi_slot_tx.req.ta = TA;
- multi_slot_tx.req.frames = -99;
- multi_slot_tx.req.dacValue = m_sAfcDac;
- multi_slot_tx.req.pattern = (APCTxPattern) Pattern;
- multi_slot_tx.req.pattern_data = Pattern_data;
- RF_MULTI_SLOT_TX_Obj->ConfirmCallback = ::ConfirmCallback_MultiSlotTX;
- RF_MULTI_SLOT_TX_Obj->REQ_Start(multi_slot_tx);
- sbISR->Panels->Items[0]->Text = (AnsiString) " Multi slot TX progressing";
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::btnTXStopClick(TObject *Sender)
- {
- if(btnTXStart->Tag==BTN_TAG_START)
- {
- frmRFTool->Force_RF_Stop();
- frmRFTool->pctlToolSel->Enabled = true;
- frmRFTool->btnTXStart->Enabled = true;
- btnTXStart->Tag = 0;
- CurrentPageReset();
- frmRFTool->CurrentPageReset();
- sbISR->Panels->Items[0]->Text = (AnsiString) " Multi slot TX stop";
- }
- }
- //---------------------------------------------------------------------------
- //==============================================================================
- int TfrmInterSlotRampSetting::ImageRangeCheck( int X, int Y )
- {
- sRfImageRange ImageRange;
- getImageValidRange(&ImageRange);
- if( Y <= ImageRange.LeftTop.y )
- {
- return OUT_OF_TOP_RANGE;
- }
- else if( Y >= ImageRange.RightBottom.y )
- {
- return OUT_OF_BOTTOM_RANGE;
- }
- return IN_RANGE;
- }
- //==============================================================================
- void TfrmInterSlotRampSetting::UpdateInterRampdata( int idx )
- {
- if( idx >= 0 )
- {
- Inter_RamTable[m_eCurBand].interRampData[idx] = 1.0*(imRampProfile->Height -InterRampPoint.y[idx] - vStart)*vScale/vDistance;
- OldInter_RamTable[m_eCurBand].interRampData[idx] = Inter_RamTable[m_eCurBand].interRampData[idx];
- }
- }
- //-------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::getImageValidRange( sRfImageRange *p_ImageRange )
- {
- p_ImageRange->LeftTop.x = 1;
- p_ImageRange->LeftTop.y = imRampProfile->Height - vDistance*(1.0*MAX_INTER_RAMP_DATA_VALUE/vScale) - vStart;
- p_ImageRange->RightBottom.x = (INTER_RAMP_SAMPLE_NUM-1)*hDistance;
- p_ImageRange->RightBottom.y = imRampProfile->Height - vStart;
- }
- //==============================================================================
- void TfrmInterSlotRampSetting::CurrentPageLock( void )
- {
- int i;
- // button
- btnTXStart->Enabled = false;
- btnTXStart->Tag = BTN_TAG_START;
- btnLeft->Enabled = false;
- btnRight->Enabled = false;
- btnUploadFromFlash->Enabled = false;
- btnDownloadToFlash->Enabled = false;
- btnChangeDB->Enabled = false;
- btnLoadFromFile->Enabled = false;
- btnSaveToFile->Enabled = false;
- for(i=0; i<INTER_RAMP_SAMPLE_NUM; i++ )
- {
- edtInterRamp[i]->Enabled = false;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::CurrentPageReset( void )
- {
- int i;
- // button
- btnTXStart->Enabled = true;
- btnTXStart->Tag = BTN_TAG_STOP;
- btnLeft->Enabled = true;
- btnRight->Enabled = true;
- btnUploadFromFlash->Enabled = true;
- btnDownloadToFlash->Enabled = true;
- btnChangeDB->Enabled = true;
- btnLoadFromFile->Enabled = true;
- btnSaveToFile->Enabled = true;
- for(i=0; i<INTER_RAMP_SAMPLE_NUM; i++ )
- {
- edtInterRamp[i]->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmInterSlotRampSetting::Set_RF_MULTI_SLOT_TX_Obj( CRFMULTISLOTTX *rf_multi_slot_tx_obj)
- {
- RF_MULTI_SLOT_TX_Obj = rf_multi_slot_tx_obj;
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::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))
- {
- ShowHintLabel(edit, hint[m_eCurBand]);
- edit->SetFocus();
- return;
- }
- m_sTestArfcn[m_eCurBand] = sdata;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmInterSlotRampSetting::FormClose(TObject *Sender,
- TCloseAction &Action)
- {
- if( btnTXStart->Tag == 1)
- {
- btnTXStopClick(this);
- }
- }
- //---------------------------------------------------------------------------