⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 advancedpage.cpp

📁 atmel芯片的Linux驱动程序。很多802.11协议的无限网卡都使用该芯片
💻 CPP
字号:
/* AdvancedPage.cpp *//*******************************************************************************************	Copyright 2002-2003 ATMEL Corporation.	This file is part of ATMEL Wireless LAN Drivers.	ATMEL Wireless LAN Drivers is free software; you can redistribute it and/or modify	it under the terms of the GNU General Public License as published by	the Free Software Foundation; either version 2 of the License, or	(at your option) any later version.	ATMEL Wireless LAN Drivers is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	GNU General Public License for more details.	You should have received a copy of the GNU General Public License	along with ATMEL Wireless LAN Drivers; if not, write to the Free Software	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*******************************************************************************************/#include "AdvancedPage.h"#include "Decls.h"#include "WinterModel.h"#include "Accessor.h"#include "WinterFrame.h"#include "WinterTimer.h"#include "WinterData.h"#include "Device.h"#include "WinterSetup.h"#include <wx/radiobut.h>#include <wx/spinctrl.h>BEGIN_EVENT_TABLE( CAdvancedPage, wxPanel )	EVT_IDLE( CAdvancedPage::OnIdle )	EVT_BUTTON( ID_BT_ADVANCEDPAGE_SUBMIT, CAdvancedPage::OnBtAdvancedPageSubmit )END_EVENT_TABLE( )CAdvancedPage::CAdvancedPage(  wxWindow *parent, int id, const wxPoint &pos, const wxSize &size, long style ) : CWinterPage( parent, id, pos ){	//The Advanced Page setup	wxBoxSizer *sz_curline;	int border = 4;	int border_2 = 1;	int field = 0;	int lenght = 200;	int width = 40;	wxSize page4_labelsize( 200, -1 );	wxSize page4_labelsize_2( 220, -1 );	wxStaticBox *sb_firstbox = new wxStaticBox( this, ID_SB_FIRSTADVPAGEBOX, wxT( "" ) );	wxStaticBox *sb_secondbox = new wxStaticBox( this, ID_SB_SECONDADVPAGEBOX, wxT( "") );	wxStaticBox *sb_thirdbox = new wxStaticBox( this, ID_SB_THIRDADVPAGEBOX, wxT( "" ) );	//The first AdvancedPage box group	wxStaticBoxSizer *sz_firstbox = new wxStaticBoxSizer( sb_firstbox, wxVERTICAL );	//Preamble Type	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_firstbox->Add( lenght, 10, 0, 1 );	sz_curline->Add( new wxStaticText( this, ID_ST_FIRSTADVPAGEBOX_PREAMBLE_TYPE, wxT( "Preamble Type " ), wxDefaultPosition, page4_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );	sz_curline->Add( new wxRadioButton( this, ID_RB_FIRSTADVPAGEBOX_PREAMBLE_TYPE_LONG, _( "Long" ), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ), 1, wxALIGN_CENTER_VERTICAL, 0 );	sz_firstbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );	//RadioButton short	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_curline->Add( lenght, 10, 0, 1);	sz_curline->Add( new wxRadioButton( this, ID_RB_FIRSTADVPAGEBOX_PREAMBLE_TYPE_SHORT, _( "Short" ), wxDefaultPosition,  wxDefaultSize, 0 ), 1, wxALIGN_CENTER_VERTICAL, 0 );	sz_firstbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );	//The second AdvancedPage box group	wxStaticBoxSizer *sz_secondbox = new wxStaticBoxSizer( sb_secondbox, wxVERTICAL );	//Power Mode	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_secondbox->Add( lenght, 10, 0, 1 );	sz_curline->Add( new wxStaticText( this, ID_ST_SECONDADVPAGEBOX_POWER_MODE, _( "Power Mode" ), wxDefaultPosition, page4_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );	sz_curline->Add( new wxRadioButton( this, ID_RB_SECONDADVPAGEBOX_POWER_MODE_ACTIVE, _( "Active" ), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ), 1, wxALIGN_CENTER_VERTICAL, 0 );	sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );	//RadioButton Power save	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_curline->Add( lenght, 10, 0, 1 );	sz_curline->Add( new wxRadioButton( this, ID_RB_SECONDADVPAGEBOX_POWER_MODE_POWERSAVE, _( "Power Save" ), wxDefaultPosition, wxDefaultSize, 0 ), 1, wxALIGN_CENTER_VERTICAL, 0 );	sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );	//RadioButton Smart Power Save	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_curline->Add( lenght, 10, 0, 1 );	sz_curline->Add( new wxRadioButton( this, ID_RB_SECONDADVPAGEBOX_POWER_MODE_SMARTSAVE,_( "Smart Power Save" ), wxDefaultPosition, wxDefaultSize, 0 ), 1, wxALIGN_CENTER_VERTICAL, 0 );	sz_secondbox->Add( sz_curline, 0, wxEXPAND | wxALL, border );	//The third AdvancedPage box group	wxStaticBoxSizer *sz_thirdbox = new wxStaticBoxSizer( sb_thirdbox, wxVERTICAL );	//Fragmentation	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_thirdbox->Add( lenght, 10, 0, 1 );	sz_curline->Add( new wxStaticText( this, ID_ST_THIRDADVPAGEBOX_FRAQMENTATION, _( "Fragmentation Threshold" ), wxDefaultPosition, page4_labelsize_2 ), 0, wxALIGN_CENTER_VERTICAL, 0 );	sz_curline->Add( new wxSpinCtrl( this, ID_SP_THIRDADVPAGEBOX_FRAQMENTATION, "", wxDefaultPosition, wxDefaultSize , wxSP_ARROW_KEYS, 256, 2346, 256 ), field, wxALIGN_CENTER_VERTICAL, 0 );	sz_curline->Add( width, 10, 0, 1 );	sz_thirdbox->Add( sz_curline, 0, wxEXPAND | wxALL, border_2 );	//fraq disabled	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_curline->Add( new wxStaticText( this, ID_ST_THIRDADVPAGEBOX_FRAQ_DISABLED, _("( Disabled )" ), wxDefaultPosition, wxDefaultSize ), 0, wxALIGN_CENTER_VERTICAL, 0 );	sz_thirdbox->Add( sz_curline, 0, wxEXPAND | wxALL, border_2 );	//rts/cts	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_thirdbox->Add( lenght, 10, 0, 1 );	sz_curline->Add( new wxStaticText( this, ID_ST_THIRDADVPAGEBOX_RTS, _( "Rts/Cts Threshold" ), wxDefaultPosition, page4_labelsize_2 ), 0, wxALIGN_CENTER_VERTICAL, 0 );	sz_curline->Add( new wxSpinCtrl( this, ID_SP_THIRDADVPAGEBOX_RTS, "", wxDefaultPosition, wxDefaultSize , wxSP_ARROW_KEYS, 1, 2347, 1 ), field, wxALIGN_CENTER_VERTICAL, 0 );	sz_curline->Add( width, 10, 0, 1 );	sz_thirdbox->Add( sz_curline, 0, wxEXPAND | wxALL, border_2 );	//rts/cts disabled	sz_curline = new wxBoxSizer( wxHORIZONTAL );	sz_curline->Add( new wxStaticText( this, ID_ST_THIRDADVPAGEBOX_RTS_DISABLED, _( "(Disabled)" ), wxDefaultPosition, wxDefaultSize ), 0, wxALIGN_CENTER_VERTICAL, 0 );	sz_thirdbox->Add( sz_curline, 0, wxEXPAND | wxALL, border_2 );	//Advanced page sizer	wxBoxSizer *sz_page_advanced = new wxBoxSizer( wxVERTICAL );	sz_page_advanced->Add( sz_firstbox, 3, wxEXPAND | wxALL, 5 );	sz_page_advanced->Add( sz_secondbox, 3, wxEXPAND | wxALL, 5 );	sz_page_advanced->Add( sz_thirdbox, 4, wxEXPAND | wxALL, 5 );	sz_page_advanced->Add( new wxButton( this, ID_BT_ADVANCEDPAGE_SUBMIT, _( "&Submit" ), wxDefaultPosition, wxDefaultSize ), 0, wxALIGN_RIGHT | wxRIGHT, 5 );	sz_page_advanced->Add( 1, 10, 1, 0 );	SetSizer( sz_page_advanced );	SetAutoLayout( true );}CAdvancedPage::~CAdvancedPage( ){}void CAdvancedPage::UpdateSpinFragLabel(  ){	int fraq_value = ( ( wxSpinCtrl * ) FindWindowById( ID_SP_THIRDADVPAGEBOX_FRAQMENTATION ) )->GetValue( ); 	wxStaticText *stfraq = ( (wxStaticText *) FindWindowById( ID_ST_THIRDADVPAGEBOX_FRAQ_DISABLED ) );	wxString dsbld = _( "( Disabled )" );	wxString enbld = _( "( Enabled )" );	if( fraq_value == 2346 && stfraq->GetLabel( ) != dsbld )	{		stfraq->SetLabel( dsbld );	}	if( fraq_value != 2346 && stfraq->GetLabel( ) != enbld )	{		stfraq->SetLabel( enbld );	}	return;}void CAdvancedPage::UpdateSpinRtsLabel( ){	int rts_value = ( ( wxSpinCtrl * ) FindWindowById( ID_SP_THIRDADVPAGEBOX_RTS ) )->GetValue( ); 	wxStaticText *strts = ( (wxStaticText *) FindWindowById(ID_ST_THIRDADVPAGEBOX_RTS_DISABLED) );	wxString dsbld = _( "( Disabled )" );	wxString enbld = _( "( Enabled )" );	if( rts_value == 2347 && strts->GetLabel( ) != dsbld )	{		strts->SetLabel( dsbld );	}	if( rts_value != 2347 && strts->GetLabel( ) != enbld )	{		strts->SetLabel( enbld );	}	return;		 }void CAdvancedPage::OnIdle( wxIdleEvent &event ){	UpdateSpinFragLabel( );	UpdateSpinRtsLabel( );	event.Skip( );	return;}void CAdvancedPage::OnBtAdvancedPageSubmit( wxCommandEvent &event ){#if ( USE_BUSY_INFO == 1 )// Once again some more ifdef's!	wxBusyInfo busy( _( "Configuring device..." ) );#endif // USE_BUSY_INFO == 1	DEACTIVATE_TIMER( );#if ( USE_BUSY_INFO == 0 )	::wxBeginBusyCursor( );#endif  // USE_BUSY_INFO == 0	SubmitAdvancedPageData( );#if ( DELAY_AFTER_SUBMIT == 1 )	::wxSleep( 1 );#endif // DELAY_AFTER_SUBMIT == 1	UpdateWinterPage( );#if ( USE_BUSY_INFO == 0 )	::wxEndBusyCursor( );#endif  // USE_BUSY_INFO == 0	ACTIVATE_TIMER( );	return;}void CAdvancedPage::SubmitAdvancedPageData( ){	TransferToModel( );	CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE );	CDeviceConfigurationData *data = ( CDeviceConfigurationData * ) model->GetChild( MC_DEVICECONFIGURATIONDATA );	if( device == NULL )	{		::wxMessageBox( _( "No device." ), wxT( "Winter" ), wxICON_INFORMATION, ( CWinterFrame * ) CAccessor::Access( AID_FRAME ) );		return;	}	if( device->SetDeviceConfig( data ) == true )	{	}	return;}// Higher update levelvoid CAdvancedPage::UpdateWinterPage( ){	CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE );		CDeviceConfigurationData *data = ( CDeviceConfigurationData * ) model->GetChild( MC_DEVICECONFIGURATIONDATA );	if( device->GetDeviceConfig( data ) == false )	{		::wxMessageBox( _( "Failed to read configuration." ), wxT( "Winter" ), wxICON_INFORMATION, ( CWinterFrame * ) CAccessor::Access( AID_FRAME ) );		return;	}	TransferToControls( );	return;}int CAdvancedPage::TestControlValues( ){	return 0;}int CAdvancedPage::TransferToControls( CWinterModel *model ){	if( model == NULL )	{		model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	}	CDeviceConfigurationData *device_data = ( CDeviceConfigurationData * ) model->GetChild( MC_DEVICECONFIGURATIONDATA );	//PreambleType	int preamble_type = device_data->GetPreambleType( );	switch( preamble_type )	{		case 0:			( ( wxRadioButton * ) FindWindow( ID_RB_FIRSTADVPAGEBOX_PREAMBLE_TYPE_LONG ) )->SetValue( true );			break;		case 1:			( ( wxRadioButton * ) FindWindow( ID_RB_FIRSTADVPAGEBOX_PREAMBLE_TYPE_SHORT ) )->SetValue( true );			break;		default:			::wxMessageBox( _( "You have found a bug!" ) );			wxASSERT( 0 );			break;	}//PowerMode	int power_mode = device_data->GetPowerMgmtMode( );	switch( power_mode )	{		case 0:			( ( wxRadioButton * ) FindWindow( ID_RB_SECONDADVPAGEBOX_POWER_MODE_ACTIVE ) )->SetValue( true );			break;		case 1:			( ( wxRadioButton * ) FindWindow( ID_RB_SECONDADVPAGEBOX_POWER_MODE_POWERSAVE ) )->SetValue( true );			break;		case 2:			( ( wxRadioButton * ) FindWindow( ID_RB_SECONDADVPAGEBOX_POWER_MODE_SMARTSAVE ) )->SetValue( true );			break;		default:			::wxMessageBox( _( "You have found a bug!" ) );			wxASSERT( 0 );			break;	}//FragThreshold	( ( wxSpinCtrl * ) FindWindow( ID_SP_THIRDADVPAGEBOX_FRAQMENTATION ) )->SetValue( device_data->GetFragmentationThreshold( ) );//Rts/Cts	( ( wxSpinCtrl * ) FindWindow( ID_SP_THIRDADVPAGEBOX_RTS ) )->SetValue( device_data->GetRtsCtsThreshold( ) );	return 0;}int CAdvancedPage::TransferToModel( CWinterModel *model ){	if( model == NULL )	{		model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	}		CDeviceConfigurationData *device_data = ( CDeviceConfigurationData * ) model->GetChild( MC_DEVICECONFIGURATIONDATA );//FragThreshold	device_data->SetFragmentationThreshold( ( ( wxSpinCtrl * ) FindWindow( ID_SP_THIRDADVPAGEBOX_FRAQMENTATION ) )->GetValue( ) );//Rts/Cts	device_data->SetRtsCtsThreshold( ( ( wxSpinCtrl * ) FindWindow( ID_SP_THIRDADVPAGEBOX_RTS ) )->GetValue( ) );//PreambleType	if( ( ( wxRadioButton * ) FindWindowById( ID_RB_FIRSTADVPAGEBOX_PREAMBLE_TYPE_LONG ) )->GetValue( ) == true )	{		device_data->SetPreambleType( 0 );	}	else	{		device_data->SetPreambleType( 1 );	}//PowerMode	if( ( ( wxRadioButton * ) FindWindowById( ID_RB_SECONDADVPAGEBOX_POWER_MODE_ACTIVE ) )->GetValue( ) == true )	{		device_data->SetPowerMgmtMode( 0 ); 	}	else if( ( ( wxRadioButton * ) FindWindowById( ID_RB_SECONDADVPAGEBOX_POWER_MODE_POWERSAVE ) )->GetValue( ) == true )	{		device_data->SetPowerMgmtMode( 1 ); 	}	else	{		device_data->SetPowerMgmtMode( 2 );	}	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -