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

📄 statisticspage.cpp

📁 atmel usb 无线网卡驱动程序
💻 CPP
字号:
/* StatisticsPage.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 "StatisticsPage.h"#include "Decls.h"#include "WinterData.h"#include "WinterModel.h"#include "WinterTimer.h"#include "Accessor.h"#include "WinterFrame.h"#include "Device.h"#include "WinterDebug.h"BEGIN_EVENT_TABLE( CStatisticsPage, wxPanel )	EVT_BUTTON( ID_BT_CLEAR, CStatisticsPage::OnBtClear )END_EVENT_TABLE( )CStatisticsPage::CStatisticsPage( wxWindow *parent, int id, const wxPoint &pos, const wxSize &size, long style ) : CWinterPage( parent, id, pos ){	//statistics page setup	wxBoxSizer *sz_line;	int border = 8;	wxSize page2_labelsize( 150, -1 );	int field = 12;	int width = 150;	wxStaticBox *sb_DataPackets = new wxStaticBox( this, ID_SB_DATAPACKETS, _( "Data Packets " ) );	wxStaticBox *sb_MgmtPackets = new wxStaticBox( this, ID_SB_MGMTPACKETS, _( "Mgmt Packets" ) );	wxStaticBox *sb_RejectedPackets = new wxStaticBox( this, ID_SB_REJECTEDPACKETS, _( "Rejected Packets" ) );	//Data Packets Group		wxStaticBoxSizer *sz_DataPackets = new wxStaticBoxSizer( sb_DataPackets, wxVERTICAL ); 		//tx/rx		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( width, 10, 0, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_DP_TX, wxT( "Tx" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_DP_RX, wxT( "Rx" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_DataPackets->Add( sz_line, 0, wxEXPAND | wxALL, border ); 		//Successfull		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( new wxStaticText( this, ID_ST_DP_SUCCESSFULL, _( "SuccessFull" ), wxDefaultPosition, page2_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_DP_TX_SUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_DP_RX_SUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_DataPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );		//Unsuccessfull		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( new wxStaticText( this, ID_ST_DP_UNSUCCESSFULL, _( "Unsuccessfull" ), wxDefaultPosition, page2_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_DP_TX_UNSUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_DP_RX_UNSUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_DataPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );	//Mgmt Packets Group		wxStaticBoxSizer *sz_MgmtPackets = new wxStaticBoxSizer( sb_MgmtPackets, wxVERTICAL );		//tx/rx		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( width, 10, 0, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_TX, wxT( "Tx" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_RX, wxT( "Rx" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_MgmtPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );		//Successfull		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_SUCCESSFULL, _( "SuccessFull" ), wxDefaultPosition, page2_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_TX_SUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_RX_SUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_MgmtPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );		//Unsuccessfull		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_UNSUCCESSFULL, _( "UnsuccessFull" ), wxDefaultPosition, page2_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_TX_UNSUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_MGMT_RX_UNSUCCESSFULL, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_MgmtPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );	//Rejected Packets Group		wxStaticBoxSizer *sz_RejectedPackets = new wxStaticBoxSizer( sb_RejectedPackets, wxVERTICAL );		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( new wxStaticText( this, ID_ST_RESOURCES, _( "Resources" ), wxDefaultPosition, page2_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_RP_RESOURCES, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_RejectedPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );			sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( new wxStaticText( this, ID_ST_NOTREADY, _( "Not Ready" ), wxDefaultPosition, page2_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_RP_NOTREADY, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_RejectedPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );		sz_line = new wxBoxSizer( wxHORIZONTAL );		sz_line->Add( new wxStaticText( this, ID_ST_LOST, _( "Lost" ), wxDefaultPosition, page2_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 );		sz_line->Add( new wxStaticText( this, ID_ST_RP_LOST, wxT( "0" ), wxDefaultPosition, wxDefaultSize ), field, wxALIGN_CENTER_VERTICAL, 0 );		sz_RejectedPackets->Add( sz_line, 0, wxEXPAND | wxALL, border );		//sizer of Statistics Page		wxBoxSizer *sz_page_statistics = new wxBoxSizer( wxVERTICAL );		sz_page_statistics->Add( sz_DataPackets, 4, wxEXPAND | wxALL, 5 );		sz_page_statistics->Add( sz_MgmtPackets, 4 , wxEXPAND | wxALL, 5 );		sz_page_statistics->Add( sz_RejectedPackets, 4, wxEXPAND | wxALL, 5 );		sz_page_statistics->Add( new wxButton( this, ID_BT_CLEAR, _( "Clear" ), wxDefaultPosition, wxDefaultSize ), 0, wxALIGN_RIGHT | wxRIGHT, 5 );		sz_page_statistics->Add( 1, 10, 1, 0 );		SetSizer( sz_page_statistics );		SetAutoLayout( true );}CStatisticsPage::~CStatisticsPage( ){}void CStatisticsPage::OnBtClear( wxCommandEvent &event ){	DEACTIVATE_TIMER( );	ClearPackets( );	( ( wxStaticText * )FindWindowById( ID_ST_DP_TX_SUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_DP_RX_SUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_DP_TX_UNSUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_DP_RX_UNSUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_MGMT_TX_SUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_MGMT_RX_SUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_MGMT_TX_UNSUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_MGMT_RX_UNSUCCESSFULL ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_RP_NOTREADY ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_RP_RESOURCES ) )->SetLabel( wxT( "0" ) );	( ( wxStaticText * )FindWindowById( ID_ST_RP_LOST ) )->SetLabel( wxT( "0" ) );	ACTIVATE_TIMER( );	return;}void CStatisticsPage::ClearPackets( ){	CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE );	if( device == NULL )	{		::wxMessageBox( _( "No device." ), wxT( "Winter" ), wxICON_HAND, ( CWinterFrame * ) CAccessor::Access( AID_FRAME ) );		return;	}		device->ClearPackets( );	return;}void CStatisticsPage::OnUpdateStats( ){	UpdateWinterPage( );	return;}// Higher update levelvoid CStatisticsPage::UpdateWinterPage( ){	CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE );	CStatisticsData *data = ( CStatisticsData * ) model->GetChild( MC_STATISTICSDATA );	if( device->GetStatistics( data ) == false )	{		CWinterRuf ruf;		ruf.Log( wxT( "Failed to read statistics data." ) );		return;	}	TransferToControls( );	return;}int CStatisticsPage::TestControlValues( ){	return 0;}int CStatisticsPage::TransferToControls( CWinterModel *model ){	if( model == NULL )	{		model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL );	}	CStatisticsData *stats_data = ( CStatisticsData * ) model->GetChild( MC_STATISTICSDATA );	( ( wxStaticText * ) FindWindowById( ID_ST_DP_TX_SUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetTxDataPacketsOk( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_DP_TX_UNSUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetTxDataPacketsError( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_DP_RX_SUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetRxDataPacketsOk( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_DP_RX_UNSUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetRxDataPacketsError( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_MGMT_TX_SUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetTxMgmtPacketsOk( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_MGMT_RX_SUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetRxMgmtPacketsOk( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_MGMT_TX_UNSUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetTxMgmtPacketsError( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_MGMT_RX_UNSUCCESSFULL ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetRxMgmtPacketsError( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_RP_NOTREADY ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetTxPacketsRejectedNotReady( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_RP_RESOURCES ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetTxPacketsRejectedResources( ) ) );	( ( wxStaticText * ) FindWindowById( ID_ST_RP_LOST ) )->SetLabel( wxString::Format( wxT( "%d" ), stats_data->GetRxLost( ) ) );	return 0;}

⌨️ 快捷键说明

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