rf_EpskInterSlotRampProfile.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) 2001
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * rf_EpskInterSlotRampProfile.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * RF EPSK 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)
- #ifndef _RF_EPSKINTERSLOTRAMPPROFILE_H_
- #include "rf_epskinterslotrampprofile.h"
- #endif
- static const EPSK_INTER_RAMP_NUM=4;
- //===========================================================================
- static CRFEPSKINTERSLOTRAMP* rf_epsk_inter_slot_ramp_ptr;
- static bool g_bIsRunning = false;
- extern TfrmMainSel *frmMainSel;
- //===========================================================================
- static void REQ_ReadFromNVRAM( void )
- { rf_epsk_inter_slot_ramp_ptr->REQ_ReadFromNVRAM( );
- }
- //---------------------------------------------------------------------------
- static void CNF_ReadFromNVRAM( void )
- { rf_epsk_inter_slot_ramp_ptr->CNF_ReadFromNVRAM();
- }
- //---------------------------------------------------------------------------
- static void REQ_WriteToNVRAM( void )
- { rf_epsk_inter_slot_ramp_ptr->REQ_WriteToNVRAM( );
- }
- //---------------------------------------------------------------------------
- static void CNF_WriteToNVRAM( void )
- { rf_epsk_inter_slot_ramp_ptr->CNF_WriteToNVRAM( );
- }
- //---------------------------------------------------------------------------
- static void REQ_TimeOut( void )
- { rf_epsk_inter_slot_ramp_ptr->REQ_TimeOut();
- }
- //---------------------------------------------------------------------------
- static void REQ_Finish( void )
- { rf_epsk_inter_slot_ramp_ptr->REQ_Finish();
- }
- //===========================================================================
- CRFEPSKINTERSLOTRAMP::CRFEPSKINTERSLOTRAMP(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- EpskInterRampBufSize = 0;
- EpskInterRampBuf = NULL;
- }
- //---------------------------------------------------------------------------
- CRFEPSKINTERSLOTRAMP::~CRFEPSKINTERSLOTRAMP()
- {
- g_bIsRunning = false;
- ConfirmCallback = 0;
- if(EpskInterRampBuf)
- {
- delete [] EpskInterRampBuf;
- EpskInterRampBuf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFEPSKINTERSLOTRAMP::REQ_Finish( void )
- {
- if(!g_bIsRunning) return;
- Confirm( METAAPP_SUCCESS );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFEPSKINTERSLOTRAMP::REQ_Stop( void )
- {
- if(!g_bIsRunning) return;
- NVRAMMan->REQ_Stop();
- Confirm( METAAPP_STOP );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFEPSKINTERSLOTRAMP::REQ_TimeOut( void )
- {
- if(!g_bIsRunning) return;
- NVRAMMan->REQ_Stop();
- Confirm( METAAPP_TIMEOUT );
- g_bIsRunning = false;
- }
- //---------------------------------------------------------------------------
- void CRFEPSKINTERSLOTRAMP::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if(!g_bIsRunning) return;
- if(ConfirmCallback==0) return;
- m_eConfirmState = 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 CRFEPSKINTERSLOTRAMP::REQ_Read_From_NVRAM( void )
- {
- rf_epsk_inter_slot_ramp_ptr = this;
- g_bIsRunning = true;
- CurWRBand = BANDSEL_GSM900;
- ActiveMan->SetActiveFunction( ::REQ_ReadFromNVRAM );
- }
- //-------------------------------------
- void CRFEPSKINTERSLOTRAMP::REQ_ReadFromNVRAM( void )
- {
- if(!g_bIsRunning) return;
- int band = CurWRBand;
- if (NULL == EpskInterRampBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_GSM850_LID", &EpskInterRampBufSize);
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- EpskInterRampBuf = new char[EpskInterRampBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM;
- switch(band)
- {
- case BANDSEL_GSM850:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_GSM850_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- case BANDSEL_GSM900:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_GSM900_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- case BANDSEL_DCS1800:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_DCS1800_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- case BANDSEL_PCS1900:
- NVRAMMan->REQ_ReadNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_PCS1900_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- }
- }
- //-------------------------------------
- void CRFEPSKINTERSLOTRAMP::CNF_ReadFromNVRAM( void )
- {
- if(!g_bIsRunning) return;
- int band = CurWRBand;
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- if(state==METAAPP_SUCCESS)
- {
- int i;
- int idata;
- META_RESULT MetaResult = META_NVRAM_Decompose_EPSK_interRampData( &EPSK_Inter_RamTable[band],
- EpskInterRampBuf,
- EpskInterRampBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- if(band==BANDSEL_GSM850)
- { ActiveMan->SetActiveFunction( ::REQ_Finish );
- }
- else
- {
- CurWRBand++;
- ActiveMan->SetActiveFunction( ::REQ_ReadFromNVRAM );
- }
- }
- else
- { Confirm(state);
- }
- }
- //===========================================================================
- void CRFEPSKINTERSLOTRAMP::REQ_Write_To_NVRAM( void )
- {
- rf_epsk_inter_slot_ramp_ptr = this;
- g_bIsRunning = true;
- m_bSingleBand = false;
- CurWRBand = BANDSEL_GSM900;
- ActiveMan->SetActiveFunction( ::REQ_WriteToNVRAM );
- }
- //-------------------------------------
- void CRFEPSKINTERSLOTRAMP::REQ_Write_To_NVRAM_Single_Band( int band )
- {
- rf_epsk_inter_slot_ramp_ptr = this;
- g_bIsRunning = true;
- m_bSingleBand = true;
- CurWRBand = band;
- ActiveMan->SetActiveFunction( ::REQ_WriteToNVRAM );
- }
- //-------------------------------------
- void CRFEPSKINTERSLOTRAMP::REQ_WriteToNVRAM( void )
- {
- if(!g_bIsRunning) return;
- int i;
- int idata;
- int band = CurWRBand;
- META_RESULT MetaResult;
- if (NULL == EpskInterRampBuf)
- {
- MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_GSM850_LID", &EpskInterRampBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- EpskInterRampBuf = new char[EpskInterRampBufSize];
- }
- MetaResult = META_NVRAM_Compose_EPSK_interRampData( &EPSK_Inter_RamTable[band],
- EpskInterRampBuf,
- EpskInterRampBufSize );
- if(MetaResult!=META_SUCCESS)
- { Confirm( METAAPP_FAIL ); return; }
- NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM;
- switch(band)
- {
- case BANDSEL_GSM850:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_GSM850_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- case BANDSEL_GSM900:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_GSM900_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- case BANDSEL_DCS1800:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_DCS1800_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- case BANDSEL_PCS1900:
- NVRAMMan->REQ_WriteNVRAM_Start( "NVRAM_EF_L1_EPSK_INTERSLOT_RAMP_PCS1900_LID",
- 1, // only 1 record
- EpskInterRampBufSize,
- EpskInterRampBuf );
- break;
- }
- }
- //-------------------------------------
- void CRFEPSKINTERSLOTRAMP::CNF_WriteToNVRAM( void )
- {
- if(!g_bIsRunning) return;
- int band = CurWRBand;
- 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
- {
- Confirm(state);
- }
- }
- //===========================================================================
- static const char SUBBAND_NAME[][32] =
- {
- "GSM900 EPSK inter slot ramp",
- "DCS1800 EPSK inter slot ramp",
- "PCS1900 EPSK inter slot ramp",
- "GSM850 EPSK inter slot ramp",
- };
- //-------------------------------------------------------------------------
- static const char SECTION_NAME[][32] =
- {
- "GMSK GMSK inter slot ramp",
- "GMSK EPSK inter slot ramp",
- "EPSK GMSK inter slot ramp",
- "EPSK EPSK inter slot ramp",
- };
- //-------------------------------------------------------------------------
- bool CRFEPSKINTERSLOTRAMP::REQ_Read_From_File( char *filename )
- {
- TIniFile *ini_file;
- int band;
- AnsiString as_data;
- unsigned char ucdata[16];
- int i, section;
- 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( section=0; section<EPSK_INTER_RAMP_NUM; section++ )
- {
- as_data = ini_file->ReadString( SUBBAND_NAME[band],
- SECTION_NAME[section],
- "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");
- strcpy( str, as_data.c_str() );
- String_To_Array_UnsignedChar( str, ucdata, 16 );
- for( i=0; i<16; i++ )
- { EPSK_Inter_RamTable[band].EPSK_interRampData[section][i] = ucdata[i]; }
- }
- }
- delete ini_file;
- }
- return true;
- }
- //===========================================================================
- bool CRFEPSKINTERSLOTRAMP::REQ_Write_To_File( char *filename)
- {
- TIniFile *ini_file;
- int i, band, section;
- unsigned char ucdata[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( section=0; section<EPSK_INTER_RAMP_NUM; section++ )
- {
- for( i=0; i<16; i++ )
- {
- ucdata[i] = EPSK_Inter_RamTable[band].EPSK_interRampData[section][i];
- }
- Array_To_String_UnsignedChar( str, ucdata, 16, ',' );
- ini_file->WriteString( SUBBAND_NAME[band],
- SECTION_NAME[section],
- 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 ///////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CRFEPSKINTERSLOTRAMP::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void CRFEPSKINTERSLOTRAMP::Set_InterSlotRamp(int band_idx, l1cal_EPSK_interRampData_T epsk_inter_ramp )
- {
- EPSK_Inter_RamTable[band_idx] = epsk_inter_ramp;
- }
- //---------------------------------------------------------------------------
- l1cal_EPSK_interRampData_T CRFEPSKINTERSLOTRAMP::Get_InterSlotRamp(int band_idx )
- {
- return EPSK_Inter_RamTable[band_idx];
- }