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

📄 dlgopcitemwrite.cpp

📁 OPC Client 源代码
💻 CPP
字号:
// DlgOPCItemWrite.cpp : implementation file
//

#include "stdafx.h"
#include "TYOPCClient.h"
#include "DlgOPCItemWrite.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgOPCItemWrite dialog
#define WM_TIMER_UPDATADATE_TIME  200
#define WM_TIMER_UPDATADATE_EVENT 1000


CDlgOPCItemWrite::CDlgOPCItemWrite(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgOPCItemWrite::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgOPCItemWrite)
	m_strModifyValue = _T("0");
	m_strDataType = _T("");
	m_strCurValue = _T("0");
	//}}AFX_DATA_INIT

	m_pDoc=NULL;
	m_pOPCGroup=NULL;
	m_pCurOPCItem=NULL;
}


void CDlgOPCItemWrite::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgOPCItemWrite)
	DDX_Control(pDX, IDC_CUR_VALUE, m_cCtrlEditCutValue);
	DDX_Control(pDX, IDC_ITEMNAME, m_cCtrlComBox);
	DDX_Text(pDX, IDC_MODIFY_VAULE, m_strModifyValue);
	DDX_Text(pDX, IDC_DATATYPE, m_strDataType);
	DDX_Text(pDX, IDC_CUR_VALUE, m_strCurValue);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgOPCItemWrite, CDialog)
	//{{AFX_MSG_MAP(CDlgOPCItemWrite)
	ON_BN_CLICKED(IDC_APPLICATION, OnApp)
	ON_WM_TIMER()
	ON_CBN_SELCHANGE(IDC_ITEMNAME, OnSelChange)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgOPCItemWrite message handlers
void CDlgOPCItemWrite::SetWriteItem(CTYOPCClientDoc* pDoc,CStringArray& cstrItems)
{
	m_pDoc=pDoc;
	m_pOPCGroup=pDoc->m_cOPCMgt.GetSelOPCGroup ();				//
	m_cstrItemNames.Append (cstrItems);		//
	

	//	m_cCtrlComBox
		
}

void CDlgOPCItemWrite::OnApp() 
{
	// TODO: Add your control notification handler code here
	UpdateData (TRUE);
	//
	CStringArray cstrItemNames;
	CStringArray cstrValues;
	CString      strText;

	m_cCtrlComBox.GetWindowText (strText);
	cstrItemNames.Add (strText);
	cstrValues.Add (m_strModifyValue);
	m_pOPCGroup->WriteAsync20(cstrItemNames,cstrValues);

	//事件视中提示
//	m_pDoc->UpdateAllViews (NULL,
}

BOOL CDlgOPCItemWrite::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString strItem;
	for(int nIndex=0;nIndex<=m_cstrItemNames.GetUpperBound ();nIndex++)
	{
		strItem=m_cstrItemNames.GetAt (nIndex);
		m_cCtrlComBox.AddString (strItem);
	}

	if(m_cCtrlComBox.GetCount ()>0)
	{
		m_cCtrlComBox.SetCurSel (0);
		OnSelChange();
	}
	//
	SetTimer(WM_TIMER_UPDATADATE_EVENT,WM_TIMER_UPDATADATE_TIME,NULL)	;

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

void CDlgOPCItemWrite::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	switch(nIDEvent)
	{
	case WM_TIMER_UPDATADATE_EVENT:
	{
//		CString strText;
//		m_cCtrlComBox.GetWindowText (strText);
		if(m_pCurOPCItem)
		{	
			m_pCurOPCItem->GetValue (m_strCurValue);
			m_cCtrlEditCutValue.SetWindowText(m_strCurValue);
		}
		break;
	}
	default:
		;
	}

	CDialog::OnTimer(nIDEvent);
}

void CDlgOPCItemWrite::OnSelChange() 
{
	// TODO: Add your control notification handler code here
	CString strText;
	m_cCtrlComBox.GetWindowText (strText);
	m_pCurOPCItem=m_pOPCGroup->GetItem (strText);
	if(m_pCurOPCItem)
		m_pCurOPCItem->GetDataType (m_strDataType);
	UpdateData(FALSE);	//更新数据
}

⌨️ 快捷键说明

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