📄 monitorpage.cpp
字号:
/* MonitorPage.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 "MonitorPage.h"#include "ChoiceCtrl.h"#include "Decls.h"#include "Accessor.h"#include "WinterFrame.h"#include "WinterTimer.h"#include "WinterDebug.h"#include "HRStrings.h"#include "Device.h"#include "WinterSetup.h"#include <stdlib.h>#include <wx/busyinfo.h>BEGIN_EVENT_TABLE( CMonitorPage, wxPanel ) EVT_BUTTON( ID_BT_MONITORPAGE_CHANGE, CMonitorPage::OnBtChange ) EVT_BUTTON( ID_BT_MONITORPAGE_SUBMIT, CMonitorPage::OnBtSubmit ) EVT_BUTTON( ID_BT_MONITORPAGE_CANCEL, CMonitorPage::OnBtCancel ) EVT_CHOICE( ID_CH_INROAMING, CMonitorPage::OnChIntRoamingChanged ) EVT_IDLE( CMonitorPage::OnIdle )END_EVENT_TABLE( )CMonitorPage::CMonitorPage( wxWindow *parent, int id, const wxPoint &pos, const wxSize &size, long style ) : CWinterPage( parent, id, pos ){ mIsDirty = false; mInChangeMode = false; mStationState = -1; // Page setup wxSize page1_labelsize( 130, -1 ); int bt_w = 80; // This is the width of the buttons. int field_weight = 3; int sizer_border = 15; wxBoxSizer *sz_currentline; wxStaticBox *sb_settings = new wxStaticBox( this, ID_SB_SETTINGS, _( "Settings" ) ); wxStaticBox *sb_monitor = new wxStaticBox( this, ID_SB_MONITOR, _( "Monitor" ) ); // The settings control group wxStaticBoxSizer *sz_settings = new wxStaticBoxSizer( sb_settings, wxVERTICAL ); // Operating mode sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_OPERATINGMODE, _( "Operating Mode :" ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new CAutoChoice( this, ID_CH_OPERATINGMODE ), field_weight, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( 1, 10, 1, 0 ); sz_currentline->Add( bt_w, 10, 0, 0 ); sz_settings->Add( sz_currentline, 0, wxEXPAND | wxALL, sizer_border ); // Channel sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_CHANNEL, _( "Channel : " ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new CAutoChoice( this, ID_CH_CHANNEL ), field_weight, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( 1, 10, 1, 0 ); sz_currentline->Add( new wxButton( this, ID_BT_MONITORPAGE_CHANGE, _( "C&hange" ), wxDefaultPosition, wxSize( bt_w, -1 ) ), 0, wxALIGN_RIGHT, 0 ); sz_settings->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // ESSID sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_ESSID, wxT( "ESSID : " ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new CHistoryCombo( this, ID_CB_ESSID, "", wxDefaultPosition, wxDefaultSize , 0, NULL, wxCB_DROPDOWN ), field_weight, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( 1, 10, 1, 0 ); sz_currentline->Add( new wxButton( this, ID_BT_MONITORPAGE_SUBMIT, _( "&Submit" ), wxDefaultPosition, wxSize( bt_w, -1 ) ),0,wxALIGN_CENTER_VERTICAL,0 ); sz_settings->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // Radio on/off sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_RADIOONOFF, _( "Radio On/Off :" ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new CAutoChoice( this, ID_CH_RADIOONOFF ), field_weight, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( 1, 10, 1, 0 ); sz_currentline->Add( new wxButton( this, ID_BT_MONITORPAGE_CANCEL, _( "&Cancel" ), wxDefaultPosition, wxSize( bt_w, -1 ) ), 0, wxALIGN_CENTER_VERTICAL,0 ); sz_settings->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // Int Roaming sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_INROAMING, _( "Int. Roaming :" ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new CAutoChoice( this, ID_CH_INROAMING ), field_weight, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( 1, 10, 1, 0 ); sz_currentline->Add( bt_w, 10, 0, 0 ); sz_settings->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // Transmit rate sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_TRANSMITRATE, _( "Transmit Rate :" ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new CAutoChoice( this, ID_CH_TRANSMITRATE ), field_weight, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( 1, 10, 1, 0 ); sz_currentline->Add( bt_w, 10, 0, 0 ); sz_settings->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // MAC address sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_MACADDRESS, _( "Mac Address : " ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new wxTextCtrl( this, ID_TX_MACADDRESS, _( "" ), wxDefaultPosition, wxDefaultSize, wxTE_READONLY ), field_weight, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( 1, 10, 1, 0 ); sz_currentline->Add( bt_w, 10, 0, 0 ); sz_settings->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // The monitor group wxStaticBoxSizer *sz_monitor = new wxStaticBoxSizer( sb_monitor, wxVERTICAL ); // Status sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_monitor->Add( 1, 10, 0, 1 ); sz_currentline->Add( new wxStaticText( this, ID_ST_STATUS, _( "Status : " ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new wxTextCtrl( this, ID_TX_STATUS_INFO, _( "" ), wxDefaultPosition, wxDefaultSize, wxTE_READONLY ), 1, wxALIGN_CENTER_VERTICAL, 0 ); sz_monitor->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // Link quality sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_LINKQUALITY, _( "Link Quality : " ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new wxGauge( this, ID_GG_LINKQUALITY, 100, wxDefaultPosition, wxSize( -1, 12 ), wxGA_HORIZONTAL ), 1, wxALIGN_CENTER_VERTICAL, 0 ); sz_monitor->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border ); // Signal strength sz_currentline = new wxBoxSizer( wxHORIZONTAL ); sz_currentline->Add( new wxStaticText( this, ID_ST_SIGSTRENGTH, _( "Signal Strength : " ), wxDefaultPosition, page1_labelsize ), 0, wxALIGN_CENTER_VERTICAL, 0 ); sz_currentline->Add( new wxGauge( this, ID_GG_SIGSTRENGTH, 100, wxDefaultPosition, wxSize( -1, 12 ), wxGA_HORIZONTAL, wxDefaultValidator ), 1, wxALIGN_CENTER_VERTICAL, 0 ); sz_monitor->Add( sz_currentline, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, sizer_border );//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// wxBoxSizer *sz_page_monitor = new wxBoxSizer( wxVERTICAL ); sz_page_monitor->Add( sz_settings, 7, wxEXPAND | wxALL, 5 ); sz_page_monitor->Add( sz_monitor, 3, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); SetSizer( sz_page_monitor ); SetAutoLayout( true );////////////////////////////////////Monitor page choices setup mMonitorChoice = new CMonitorChoiceSP( this ); // only for channel for now. wxArrayString operatingmode_ret = mMonitorChoice->ProvideStrings( ID_CH_OPERATINGMODE ); ( ( CAutoChoice * )FindWindowById( ID_CH_OPERATINGMODE ) )->SetStrings( operatingmode_ret ); wxArrayString radioonoff_ret = mMonitorChoice->ProvideStrings( ID_CH_RADIOONOFF ); ( ( CAutoChoice * )FindWindowById( ID_CH_RADIOONOFF ) )->SetStrings( radioonoff_ret ); wxArrayString inroaming_ret = mMonitorChoice->ProvideStrings( ID_CH_INROAMING ); ( ( CAutoChoice * )FindWindowById( ID_CH_INROAMING ) )->SetStrings( inroaming_ret ); wxArrayString transmitrate_ret = mMonitorChoice->ProvideStrings( ID_CH_TRANSMITRATE ); ( ( CAutoChoice * )FindWindowById( ID_CH_TRANSMITRATE ) )->SetStrings( transmitrate_ret ); wxArrayString channel_ret = mMonitorChoice->ProvideStrings( ID_CH_CHANNEL ); ( ( CAutoChoice * )FindWindowById( ID_CH_CHANNEL ) )->SetStrings( channel_ret ); ( ( CHistoryCombo * ) FindWindowById( ID_CB_ESSID ) )->SetMaxLength( MAX_SSID_LENGTH );}//=====================================================================================CMonitorPage::~CMonitorPage( ){}bool CMonitorPage::OnUpdateGauge( bool querydevice ){ CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL ); CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE ); CDeviceConfigurationData *data = ( CDeviceConfigurationData * ) model->GetChild( MC_DEVICECONFIGURATIONDATA ); if( querydevice == true ) { if( device->GetDeviceConfig( data ) == false ) {// debug :CWinterRuf ruf;ruf.Log( "General failure!" ); return false; } } unsigned char lq = data->GetLinkQuality( );#if 0 // No more tweaking! float half_delta = ( 100.0 - ( float ) lq ) / 2.0; lq == 0 means that there is a strong possibility that the radio is off. if( lq != 0 ) { // Create kinda optical effect with the gauge. lq += ( int ) ( 0.7 * half_delta ); lq += ( int ) ( 0.1 * half_delta + ( 0.1 * half_delta * rand( ) ) / ( RAND_MAX + 1.0 ) ); }#endif // 0// debug ://::wxLogDebug( wxT( "Link quality is %d" ) , lq ); wxGauge *gglink = ( wxGauge * ) FindWindow( ID_GG_LINKQUALITY ); gglink->SetValue( lq ); // Absolute value is required because, sometimes, a negative RSSI value is returned. int rssi = abs( data->GetRssi( ) ); if( rssi <= 100 ) { wxGauge *ggrssi = ( wxGauge * ) FindWindow( ID_GG_SIGSTRENGTH ); ggrssi->SetValue( rssi ); } return true;}bool CMonitorPage::OnUpdateStatus( bool querydevice ){ CWinterModel *model = ( CWinterModel * ) CAccessor::Access( AID_CURRENTMODEL ); CVnetDeviceBase *device = ( CVnetDeviceBase * ) CAccessor::Access( AID_CURRENTDEVICE ); CDeviceConfigurationData *data = ( CDeviceConfigurationData * ) model->GetChild( MC_DEVICECONFIGURATIONDATA ); if( querydevice == true ) { if( device->GetDeviceConfig( data ) == false ) { return false; } } int stationstate = data->GetStationState( ); DisplayMessages( stationstate ); if( stationstate != mStationState ) { OnStationStateChanged( mStationState, stationstate ); mStationState = stationstate; } return true;}void CMonitorPage::OnBtChange( wxCommandEvent &event ){ mInChangeMode = true; return;}void CMonitorPage::OnBtSubmit( 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 SubmitMonitorPageData( ); mInChangeMode = false;#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 CMonitorPage::OnBtCancel( wxCommandEvent &event ){ mInChangeMode = false; UpdateWinterPage( ); return;}void CMonitorPage::SubmitMonitorPageData( ){ TransferToModel( NULL ); 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_HAND, ( CWinterFrame * ) CAccessor::Access( AID_FRAME ) ); return; } if( device->SetDeviceConfig( data ) == true ) { mIsDirty = true; } return;}void CMonitorPage::OnIdle( wxIdleEvent &event ){ bool enable_channel = mInChangeMode && !( ( ( CAutoChoice * ) FindWindow( ID_CH_OPERATINGMODE ) )->GetSelection( ) == 1 ); bool enable_submit = mInChangeMode;// Timer if( mInChangeMode == true ) { DEACTIVATE_TIMER( ); } if( mInChangeMode == false ) { ACTIVATE_TIMER( ); }// Channel if( enable_channel != FindWindowById( ID_ST_CHANNEL )->IsEnabled( ) ) { FindWindowById( ID_ST_CHANNEL )->Enable( enable_channel ); FindWindowById( ID_CH_CHANNEL )->Enable( enable_channel ); }// Buttons if( FindWindowById( ID_BT_MONITORPAGE_CHANGE )->IsEnabled( ) == enable_submit ) { FindWindowById( ID_BT_MONITORPAGE_CHANGE )->Enable( !enable_submit ); } if( FindWindowById( ID_BT_MONITORPAGE_SUBMIT )->IsEnabled( ) != enable_submit ) { FindWindowById( ID_BT_MONITORPAGE_SUBMIT )->Enable( enable_submit ); } if( FindWindowById( ID_BT_MONITORPAGE_CANCEL )->IsEnabled( ) != enable_submit ) { FindWindowById( ID_BT_MONITORPAGE_CANCEL )->Enable( enable_submit ); }// All other controls if( mInChangeMode != FindWindowById( ID_ST_OPERATINGMODE )->IsEnabled() ) { FindWindowById( ID_ST_OPERATINGMODE )->Enable( mInChangeMode ); FindWindowById( ID_CH_OPERATINGMODE )->Enable( mInChangeMode ); CWinterStringsProvider *sp = ( CWinterStringsProvider * ) CAccessor::Access( AID_STRINGSPROVIDER );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -