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

📄 commstatsdlg.cpp

📁 工业强度的PLC模拟程序
💻 CPP
字号:
// @dlg
//
// @module		CommStatsDlg.cpp
//
//
// Maintenance:
//	
// Version		Date		Who		What
// -------		--------	---		-------------------------------------
// 7.0			07/23/97	jra		Created

// CommStatsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "itkplc.h"
#include "CommStatsDlg.h"
#include "itkprotocol.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CCommStatsDlg dialog


CCommStatsDlg::CCommStatsDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCommStatsDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCommStatsDlg)
	m_ack_rcvd_count = _T("");
	m_ack_sent_count = _T("");
	m_bitwrite_count = _T("");
	m_nak_count = _T("");
	m_read_count = _T("");
	m_unsol_msgs_sent_count = _T("");
	m_write_count = _T("");
	m_nak_sent_count = _T("");
	//}}AFX_DATA_INIT

	this->m_dwNakRcvdCount			= 0;
	this->m_dwNakSentCount			= 0;
	this->m_dwAckRcvdCount			= 0;
	this->m_dwAckSentCount			= 0;
	this->m_dwReadCount				= 0;
	this->m_dwBitWriteCount			= 0;
	this->m_dwWriteCount			= 0;
	this->m_dwUnsolicitedSentCount	= 0;
	this->m_bDisplayed				= FALSE;
}


void CCommStatsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCommStatsDlg)
	DDX_Text(pDX, IDC_ACKRCVD_COUNT, m_ack_rcvd_count);
	DDX_Text(pDX, IDC_ACKSENT_COUNT, m_ack_sent_count);
	DDX_Text(pDX, IDC_BITWRITE_COUNT, m_bitwrite_count);
	DDX_Text(pDX, IDC_NAK_COUNT, m_nak_count);
	DDX_Text(pDX, IDC_READ_COUNT, m_read_count);
	DDX_Text(pDX, IDC_UNSOL_MSGS_SENT_COUNT, m_unsol_msgs_sent_count);
	DDX_Text(pDX, IDC_WRITE_COUNT, m_write_count);
	DDX_Text(pDX, IDC_NAK_SENT_COUNT, m_nak_sent_count);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCommStatsDlg, CDialog)
	//{{AFX_MSG_MAP(CCommStatsDlg)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_RESET, OnReset)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCommStatsDlg message handlers


//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CCommStatsDlg | OnInitDialog |
//
// Initializes the dialog box members
//
BOOL CCommStatsDlg::OnInitDialog() 
{	
	//
	// Create a 500ms timer to refresh the statistics
	//
	SetTimer(STATS_TIMER, 500, NULL);

	this->m_bDisplayed = TRUE;

	CDialog::OnInitDialog();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CCommStatsDlg | Create |
//
// Creates the modeless dialog box
//
BOOL CCommStatsDlg::Create()
{
	BOOL	bRetVal;


	bRetVal = CDialog::Create(IDD_COMM_STATS);

	this->ShowWindow(SW_SHOW);

	return (bRetVal);
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CCommStatsDlg | OnClose |
//
// Closes the modeless dialog box.
//
void CCommStatsDlg::CloseDialog() 
{
	this->m_bDisplayed = FALSE;

	//
	// Release the timer
	//
	KillTimer(STATS_TIMER);

	//
	// Close the window
	//
	this->DestroyWindow();
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CCommStatsDlg | OnReset |
//
// Resets the statistics to 0.
//
void CCommStatsDlg::OnReset() 
{
	this->m_dwNakRcvdCount			= 0;
	this->m_dwNakSentCount			= 0;
	this->m_dwAckRcvdCount			= 0;
	this->m_dwAckSentCount			= 0;
	this->m_dwReadCount				= 0;
	this->m_dwBitWriteCount			= 0;
	this->m_dwWriteCount			= 0;
	this->m_dwUnsolicitedSentCount	= 0;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CCommStatsDlg | OnTimer |
//
// Handler for Windows timers for statistics refresh
//
void CCommStatsDlg::OnTimer(UINT nIDEvent) 
{
	switch (nIDEvent)
	{
	case STATS_TIMER:
		m_nak_count.Format("%d", this->m_dwNakRcvdCount);
		m_nak_sent_count.Format("%d", this->m_dwNakSentCount);
		m_read_count.Format("%d", this->m_dwReadCount);
		m_bitwrite_count.Format("%d", this->m_dwBitWriteCount);
		m_write_count.Format("%d", this->m_dwWriteCount);
		m_ack_sent_count.Format("%d", this->m_dwAckSentCount);
		m_ack_rcvd_count.Format("%d", this->m_dwAckRcvdCount);
		m_unsol_msgs_sent_count.Format("%d", this->m_dwUnsolicitedSentCount);

		UpdateData(FALSE);
		break;

	default:
		break;
	}
	
	CDialog::OnTimer(nIDEvent);
}

⌨️ 快捷键说明

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