OPC新手求助

hzx504 2010-07-20 11:37:55
/// <summary>
/// 创建组
/// </summary>
private bool CreateGroup()
{
try
{
KepGroups = KepServer.OPCGroups;
KepGroup = KepGroups.Add("OPCDOTNETGROUP");
SetGroupProperty();
KepGroup.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(KepGroup_DataChange);
KepGroup.AsyncWriteComplete += new DIOPCGroupEvent_AsyncWriteCompleteEventHandler(KepGroup_AsyncWriteComplete);
KepItems = KepGroup.OPCItems;
}
catch (Exception err)
{
MessageBox.Show("创建组出现错误:"+err.Message,"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return false;
}
return true;
}
/// <summary>
/// 设置组属性
/// </summary>
private void SetGroupProperty()
{
KepServer.OPCGroups.DefaultGroupIsActive =Convert.ToBoolean(txtGroupIsActive.Text);
KepServer.OPCGroups.DefaultGroupDeadband = Convert.ToInt32(txtGroupDeadband.Text);
KepGroup.UpdateRate = Convert.ToInt32(txtUpdateRate.Text);
KepGroup.IsActive = Convert.ToBoolean(txtIsActive.Text);
KepGroup.IsSubscribed =Convert.ToBoolean(txtIsSubscribed.Text);
}
/// <summary>
/// 列出OPC服务器中所有节点
/// </summary>
/// <param name="oPCBrowser"></param>
private void RecurBrowse(OPCBrowser oPCBrowser)
{
//展开分支
oPCBrowser.ShowBranches();
//展开叶子
oPCBrowser.ShowLeafs(true);
int i = 0;
foreach (object turn in oPCBrowser)
{
listBox1.Items.Add(turn.ToString());
}
}
------------------------------------------------------------------------------------------
第一次接触OPC,想把所有的点,也就是listBox1所有的Item值都添加到Group里,然后每隔30秒刷新一次,把得到的值存到文本文件中。现在不知道怎么把Item值都添加Group里,还有怎么刷新。求高手指点!!!
...全文
85 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzx504 2010-07-20
  • 打赏
  • 举报
回复
高手都去哪了。。
hzx504 2010-07-20
  • 打赏
  • 举报
回复
急急急急急急急急急急急急急急
hzx504 2010-07-20
  • 打赏
  • 举报
回复
KepGroup.DataChange好像会自动刷的,但是不知道机制是怎么样的
I520WUCHAN 2010-07-20
  • 打赏
  • 举报
回复
用TIME定时刷新啊
hzx504 2010-07-20
  • 打赏
  • 举报
回复
ddddddddddddddddddddd

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧