rf_InterSlotRampProfile.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:16k
源码类别:
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:
- * ---------
- * rf_InterSlotRampProfile.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF inter slot ramp profile 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 <IniFiles.hpp>
- #pragma hdrstop
- #include "form_RFTool.h"
- #include "form_Main.h"
- #include "rf_InterSlotRampProfile.h"
- #include "man_fdm.h"
- #include "man_active.h"
- // misc
- #include "misc.h"
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //#include "meta2.h"
- //===========================================================================
- static CRFINTERSLOTRAMP* rf_inter_slot_ramp_ptr;
- extern TfrmMainSel *frmMainSel;
- //===========================================================================
- static void REQ_ReadFromNVRAM( void )
- {
- rf_inter_slot_ramp_ptr->REQ_ReadFromNVRAM( );
- }
- static void CNF_ReadFromNVRAM( void )
- {
- rf_inter_slot_ramp_ptr->CNF_ReadFromNVRAM();
- }
- static void REQ_WriteToNVRAM( void )
- {
- rf_inter_slot_ramp_ptr->REQ_WriteToNVRAM( );
- }
- static void CNF_WriteToNVRAM( void )
- {
- rf_inter_slot_ramp_ptr->CNF_WriteToNVRAM( );
- }
- static void REQ_TimeOut( void )
- { rf_inter_slot_ramp_ptr->REQ_TimeOut();
- }
- static void REQ_Finish( void )
- { rf_inter_slot_ramp_ptr->REQ_Finish();
- }
- //===========================================================================
- CRFINTERSLOTRAMP::CRFINTERSLOTRAMP(void)
- {
- IsRunning = false;
- ConfirmCallback = 0;
- InterRampBufSize = 0;
- InterRampBuf = NULL;
- }
- //---------------------------------------------------------------------------
- CRFINTERSLOTRAMP::~CRFINTERSLOTRAMP()
- {
- IsRunning = false;
- ConfirmCallback = 0;
- if(InterRampBuf)
- {
- delete [] InterRampBuf;
- InterRampBuf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFINTERSLOTRAMP::REQ_Finish( void )
- {
- if(!IsRunning) return;
- Confirm( STATE_INTER_SLOT_RAMP_OK );
- IsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFINTERSLOTRAMP::REQ_Stop( void )
- {
- if(!IsRunning) return;
- NVRAMMan->REQ_Stop();
- Confirm( STATE_INTER_SLOT_RAMP_STOP );
- IsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFINTERSLOTRAMP::REQ_TimeOut( void )
- {
- if(!IsRunning) return;
- NVRAMMan->REQ_Stop();
- Confirm( STATE_INTER_SLOT_RAMP_TIMEOUT );
- IsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFINTERSLOTRAMP::Confirm( int confirm_state )
- {
- if(!IsRunning) return;
- if(ConfirmCallback==0) return;
- ConfirmState = confirm_state;
- ActiveMan->SetActiveFunction( ConfirmCallback );
- }
- //===========================================================================
- //static int NVRAM_APC_LOWEST_POWER[] =
- //{ 5, 0, 0, 5 };
- //static char NVRAM_RAMPNAME[][32] =
- //{
- // "L1_RAMPTABLE_GSM900",
- // "L1_RAMPTABLE_DCS1800",
- // "L1_RAMPTABLE_PCS1900",
- // "L1_RAMPTABLE_GSM9850",
- //};
- //---------------------------------------------------------------------------
- void CRFINTERSLOTRAMP::REQ_Read_From_NVRAM( void )
- {
- rf_inter_slot_ramp_ptr = this;
- IsRunning = true;
- CurWRBand = BANDSEL_GSM900;
- ActiveMan->SetActiveFunction( ::REQ_ReadFromNVRAM );
- }
- //-------------------------------------
- void CRFINTERSLOTRAMP::REQ_ReadFromNVRAM( void )
- { int band = CurWRBand;
- if(!IsRunning) return;
- if(InterRampBuf==0)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_INTERSLOT_RAMP_GSM850_LID", &InterRampBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( STATE_INTER_SLOT_RAMP_FAIL ); return; }
- InterRampBuf = new char[InterRampBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM;
- switch(band)
- {
- case BANDSEL_GSM850:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_GSM850_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- case BANDSEL_GSM900:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_GSM900_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- case BANDSEL_DCS1800:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_DCS1800_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- case BANDSEL_PCS1900:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_PCS1900_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- }
- }
- //-------------------------------------
- void CRFINTERSLOTRAMP::CNF_ReadFromNVRAM( void )
- {
- int band = CurWRBand;
- if(!IsRunning) return;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if(state==METAAPP_SUCCESS)
- { int i;
- int idata;
- MetaResult = META_NVRAM_Decompose_interRampData( &Inter_RamTable[band],
- InterRampBuf,
- InterRampBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( STATE_INTER_SLOT_RAMP_FAIL ); return; }
- if(band==BANDSEL_GSM850)
- { ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- { CurWRBand++;
- ActiveMan->SetActiveFunction( ::REQ_ReadFromNVRAM );
- }
- }
- else if(state==METAAPP_TIMEOUT)
- { Confirm( STATE_INTER_SLOT_RAMP_TIMEOUT );
- }
- else if(state==METAAPP_STOP)
- { Confirm( STATE_INTER_SLOT_RAMP_STOP );
- }
- else
- { Confirm( STATE_INTER_SLOT_RAMP_FAIL );
- }
- }
- //===========================================================================
- void CRFINTERSLOTRAMP::REQ_Write_To_NVRAM( void )
- {
- rf_inter_slot_ramp_ptr = this;
- IsRunning = true;
- m_bSingleBand = false;
- CurWRBand = BANDSEL_GSM900;
- ActiveMan->SetActiveFunction( ::REQ_WriteToNVRAM );
- }
- //-------------------------------------
- void CRFINTERSLOTRAMP::REQ_Write_To_NVRAM_Single_Band( int band )
- {
- rf_inter_slot_ramp_ptr = this;
- IsRunning = true;
- m_bSingleBand = true;
- CurWRBand = band;
- ActiveMan->SetActiveFunction( ::REQ_WriteToNVRAM );
- }
- //-------------------------------------
- void CRFINTERSLOTRAMP::REQ_WriteToNVRAM( void )
- {
- int i;
- int idata;
- int band = CurWRBand;
- if(!IsRunning) return;
- if(InterRampBuf==0)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_INTERSLOT_RAMP_GSM850_LID", &InterRampBufSize);
- if(MetaResult!=META_SUCCESS)
- { Confirm( STATE_INTER_SLOT_RAMP_FAIL ); return; }
- InterRampBuf = new char[InterRampBufSize];
- }
- MetaResult = META_NVRAM_Compose_interRampData( &Inter_RamTable[band],
- InterRampBuf,
- InterRampBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( STATE_INTER_SLOT_RAMP_FAIL ); return; }
- NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM;
- switch(band)
- {
- case BANDSEL_GSM850:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_GSM850_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- case BANDSEL_GSM900:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_GSM900_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- case BANDSEL_DCS1800:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_DCS1800_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- case BANDSEL_PCS1900:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_INTERSLOT_RAMP_PCS1900_LID",
- 1, // only 1 record
- InterRampBufSize,
- InterRampBuf );
- break;
- }
- }
- //-------------------------------------
- void CRFINTERSLOTRAMP::CNF_WriteToNVRAM( void )
- { int band = CurWRBand;
- if(!IsRunning) return;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if(state==METAAPP_SUCCESS)
- {
- if( (band==BANDSEL_GSM850)||(m_bSingleBand) )
- { ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- { CurWRBand++;
- ActiveMan->SetActiveFunction( ::REQ_WriteToNVRAM );
- }
- }
- else if(state==METAAPP_TIMEOUT)
- { Confirm( STATE_INTER_SLOT_RAMP_TIMEOUT );
- }
- else if(state==METAAPP_STOP)
- { Confirm( STATE_INTER_SLOT_RAMP_STOP );
- }
- else
- { Confirm( STATE_INTER_SLOT_RAMP_FAIL );
- }
- }
- //===========================================================================
- static const char SUBBAND_NAME[][32] =
- {
- "GSM900 inter slot ramp",
- "DCS1800 inter slot ramp",
- "PCS1900 inter slot ramp",
- "GSM850 inter slot ramp",
- };
- //-------------------------------------------------------------------------
- bool CRFINTERSLOTRAMP::REQ_Read_From_File( char *filename )
- {
- TIniFile *ini_file;
- int band;
- AnsiString data;
- int idata[16], i;
- int total_band_num;
- char str[2048];
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if(ini_file != NULL)
- {
- 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++)
- {
- data = ini_file->ReadString( SUBBAND_NAME[band],
- "inter slot ramp profile",
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, data.c_str() );
- String_To_Array_int( str, idata, 16 );
- for( i=0; i<16; i++ )
- { Inter_RamTable[band].interRampData[i] = idata[i]; }
- }
- delete ini_file;
- }
- return true;
- }
- //===========================================================================
- bool CRFINTERSLOTRAMP::REQ_Write_To_File( char *filename)
- {
- TIniFile *ini_file;
- int i, band;
- int idata[16];
- int total_band_num;
- char str[2048];
- ini_file = new TIniFile( filename );
- if( ini_file == NULL ) return false;
- if(ini_file != NULL)
- {
- 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++ )
- {
- idata[i] = Inter_RamTable[band].interRampData[i];
- }
- Array_To_String_int( str, idata, 16, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- "inter slot ramp profile",
- str);
- }
- delete ini_file;
- }
- return true;
- }
- //===========================================================================
- static const char BAND_NAME1[MAX_SUPPORT_BAND_NUM][12] =
- { "GSM",
- "DCS",
- "PCS",
- "GSM"
- };
- static const char BAND_NAME2[MAX_SUPPORT_BAND_NUM][12] =
- { "GSM900",
- "DCS1800",
- "PCS1900",
- "GSM850"
- };
- static const int LOWEST_POWER[MAX_SUPPORT_BAND_NUM] =
- { 5, 0, 0, 5 };
- static const char BAND_PCL_COMMENT[MAX_SUPPORT_BAND_NUM][128] =
- { " /* 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 dBm */n",
- " /* 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 dBm */n",
- " /* 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 dBm */n",
- " /* 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35 dBm */n",
- };
- //===========================================================================
- //////////////////////////// Global information ///////////////////////////
- //===========================================================================
- int CRFINTERSLOTRAMP::Get_ConfirmState( void )
- {
- return ConfirmState;
- }