实例化对象
Dim WithEvents AnOPCServer As OPCAutomation.OPCServer
Dim WithEvents ConnectedOPCServer As OPCAutomation.OPCServer
Dim WithEvents ConnectedGroup As OPCAutomation.OPCGroup
连接OPC SERVER
ConnectedOPCServer = New OPCAutomation.OPCServer
ConnectedOPCServer.Connect(OPCServerName(String), OPCNodeName(Object))
OPCServerName-OPC Server名称
OPCNodeName-站点名(一般为计算机名,本地为Local)
断开OPC SERVER的连接
ConnectedOPCServer.Disconnect()
ConnectedOPCServer = Nothing
连接OPC Group
ConnectedOPCServer.OPCGroups.DefaultGroupIsActive = (Boolean)
ConnectedOPCServer.OPCGroups.DefaultGroupDeadband = (Single)
ConnectedGroup = ConnectedOPCServer.OPCGroups.Add(OPCGroupName(Object))
GroupName-组名称,该组是访问OPC Server时临时建立的数据组,因此名称任意。
ConnectedGroup.UpdateRate = (Single)
ConnectedGroup.IsSubscribed = (Boolean)
断开OPC Group
ConnectedOPCServer.OPCGroups.Remove(OPCGroupName(Object))
GroupName-需要删除的并且已经建立过的组名
ConnectedGroup = Nothing</

本文介绍了使用VB.NET OPC Automation接口连接、断开OPC Server及OPC Group的操作步骤,包括实例化对象、设置更新率、添加和移除ITEM,并对比了同步与异步操作在网络异常时的行为差异。
2756

被折叠的 条评论
为什么被折叠?



