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

📄 kwhdatadialog.cpp

📁 这是一个变电站的监控程序
💻 CPP
字号:
// KwhDataDialog.cpp : implementation file
//

#include "stdafx.h"
#include "fert2000.h"
#include "KwhDataDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// CKwhDataDialog dialog
extern CHANNEL Channels[MAX_CHANNEL_NUM];
extern RTU Rtus[MAX_RTU_NUM];
extern SYSTEMCOUNT SystemCount;

CKwhDataDialog::CKwhDataDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CKwhDataDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CKwhDataDialog)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	RtuNo = 0;
}


void CKwhDataDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CKwhDataDialog)
	DDX_Control(pDX, IDC_KWHDATA_RTUNO, m_RtuNoCom);
	DDX_Control(pDX, IDC_MSFLEXGRID1, m_KwhDataTable);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CKwhDataDialog, CDialog)
	//{{AFX_MSG_MAP(CKwhDataDialog)
	ON_CBN_CLOSEUP(IDC_KWHDATA_RTUNO, OnCloseupKwhdataRtuno)
	ON_WM_TIMER()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CKwhDataDialog message handlers


void CKwhDataDialog::OnCloseupKwhdataRtuno() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if (RtuNo != m_RtuNoCom.GetCurSel())
	{
		RtuNo = m_RtuNoCom.GetCurSel();
		ShowKwhPara();
		UpdateData(FALSE);
	}
}

BOOL CKwhDataDialog::OnInitDialog() 
{
	char Ch[30];
	CDialog::OnInitDialog();
	
	for (int i = 0;i < SystemCount.RtuNum ;i++)
	{
		sprintf(Ch,"%d-%s",i,Rtus[i].Name);
		m_RtuNoCom.AddString(Ch);
	}
	m_RtuNoCom.SetCurSel(0);
	RtuNo = 0;
	ShowKwhPara();
	SetTimer(10,1000,NULL);

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

void CKwhDataDialog::OnTimer(UINT nIDEvent) 
{
	CString TempStr;
	for (int i = 0;i < Rtus[RtuNo].KwhNum ;i++)
	{
		TempStr.Format("%8.0f",Rtus[RtuNo].KwhValue[i]);
		m_KwhDataTable.SetTextArray(4+((i/32)*2+1)+4*(i%32),(LPCTSTR)TempStr);
	}

	CDialog::OnTimer(nIDEvent);
}

void CKwhDataDialog::OnDestroy() 
{
	CDialog::OnDestroy();
	KillTimer(1);
	// TODO: Add your message handler code here
	
}

void CKwhDataDialog::ShowKwhPara()
{
	CString TempStr;
	m_KwhDataTable.Clear();
	m_KwhDataTable.SetFormatString("KWH号|           采集值|KWH号|           采集值");
//	m_KwhDataTable.SetRows(Rtus[RtuNo].KwhNum + 1);
	for (int i = 0;i < Rtus[RtuNo].KwhNum ;i++)
	{
		TempStr.Format("%d",i);
		m_KwhDataTable.SetTextArray(4+((i/32)*2)+4*(i%32),(LPCTSTR)TempStr);
	}
}

⌨️ 快捷键说明

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