📄 stats.cpp
字号:
/*============================================================================
Copyright (c) 1996
Hewlett-Packard Company
ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
Permission to use, copy, modify, distribute and/or sell this software
and/or its documentation is hereby granted without fee. User agrees
to display the above copyright notice and this license notice in all
copies of the software and any documentation of the software. User
agrees to assume all liability for the use of the software; Hewlett-Packard
makes no representations about the suitability of this software for any
purpose. It is provided "AS-IS without warranty of any kind,either express
or implied. User hereby grants a royalty-free license to any and all
derivatives based upon this software code base.
=============================================================================*/
#include "stdafx.h"
#include "browser.h"
#include "Stats.h"
#include "pdu_cont.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int pdu_ref_count=0;
extern __declspec( dllimport ) Pdu_Container *pdu_container;
/////////////////////////////////////////////////////////////////////////////
// Stats dialog
Stats::Stats(CWnd* pParent /*=NULL*/)
: CDialog(Stats::IDD, pParent)
{
//{{AFX_DATA_INIT(Stats)
m_auto_refresh = FALSE;
m_queue = _T("");
m_timeouts = _T("");
m_traprec = _T("");
m_trapsent = _T("");
m_uided = _T("");
m_decerrs = _T("");
m_received = _T("");
m_recerrs = _T("");
m_sent = _T("");
m_senterrs = _T("");
m_strays = _T("");
//}}AFX_DATA_INIT
Create(IDD, pParent);
// create a snmp++ object
int status;
snmp = new Snmp( status);
if ( status != SNMP_CLASS_SUCCESS)
{
AfxMessageBox("Unable To Create Snmp Object!");
snmp = NULL;
}
}
void Stats::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Stats)
DDX_Check(pDX, IDC_AUTOREFRESH, m_auto_refresh);
DDX_Text(pDX, IDC_QUEUE, m_queue);
DDX_Text(pDX, IDC_TIMEOUTS, m_timeouts);
DDX_Text(pDX, IDC_TRAPREC, m_traprec);
DDX_Text(pDX, IDC_TRAPSENT, m_trapsent);
DDX_Text(pDX, IDC_UIDED, m_uided);
DDX_Text(pDX, IDC_DECERRS, m_decerrs);
DDX_Text(pDX, IDC_RECEIVED, m_received);
DDX_Text(pDX, IDC_RECERRS, m_recerrs);
DDX_Text(pDX, IDC_SENT, m_sent);
DDX_Text(pDX, IDC_SENTERRS, m_senterrs);
DDX_Text(pDX, IDC_STRAYS, m_strays);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Stats, CDialog)
//{{AFX_MSG_MAP(Stats)
ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
ON_BN_CLICKED(IDC_AUTOREFRESH, OnAutorefresh)
ON_WM_TIMER()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_USER+1,init)
END_MESSAGE_MAP()
long Stats::init(UINT wParam,LONG lParam)
{
OnUpdate();
return 0;
} ;
BOOL Stats::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CenterWindow();
PostMessage( WM_USER+1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Stats::OnUpdate()
{
// TODO: Add your control notification handler code here
char msg[20];
// received
sprintf(msg,"%08ld", pdu_container->get_pdus_received());
m_received = msg;
// received errors
sprintf(msg,"%08ld", pdu_container->get_received_errs());
m_recerrs = msg;
// max queue size
sprintf(msg,"%08ld", pdu_container->get_max_queue());
m_queue = msg;
// sent errors
sprintf(msg,"%08ld", pdu_container->get_sent_errs());
m_senterrs = msg;
// sent
sprintf(msg,"%08ld", pdu_container->get_pdus_sent());
m_sent = msg;
// timeouts
sprintf(msg,"%08ld", pdu_container-> get_timeouts());
m_timeouts = msg;
// traps received
sprintf(msg,"%08ld", pdu_container->get_trap_count());
m_traprec = msg;
// traps sent
sprintf(msg,"%08ld", pdu_container->get_traps_sent());
m_trapsent = msg;
// decode errors
sprintf(msg,"%08ld", pdu_container->get_decode_errs());
m_decerrs = msg;
// stray responses
sprintf(msg,"%08ld", pdu_container->get_stray_resp());
m_strays = msg;
// unidentified responses
sprintf(msg,"%08ld", pdu_container->get_inval_resp());
m_uided = msg;
UpdateData( FALSE);
}
void Stats::OnAutorefresh()
{
// TODO: Add your control notification handler code here
UpdateData( TRUE);
if ( m_auto_refresh)
SetTimer(1 ,1000, NULL);
else
KillTimer(1);
}
void Stats::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
KillTimer( nIDEvent);
OnUpdate();
SetTimer( nIDEvent, 1000, NULL);
CDialog::OnTimer(nIDEvent);
}
void Stats::OnCancel()
{
// TODO: Add extra cleanup here
DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -