OPC接口技术的介绍
fieldbus connection fieldbus fieldbus device FB agent client application (OPC client) OPC server cache FB manager fieldbus synchronous call over the field bus to the end device (takes a while)
checking with the browser that these items exist in this server
next group
add item array to the group activate and subscribe group
初始化
myDummyServer.GetOPCServers myServer = new OPCServer myServer.Connect Set myBrowser = myServer.Browser Set myGroups = myServer.Groups Set myGroup1 = myGroups.Add Set MyItems = MyGroup1.OPCItems FQItems1[1] = "Device1.Temp1" ClientHandle1[1] = 101 ReDim ServerHandle1(nrItems) ReDim ServerErrors1(nrItems) ReDim Value1(nrItems) myGroup1.AddItems myGroup1.IsActive myGroup1.IsSubscribed
OPCServer OPCGroups (collection)
OPCGroup OPCGroup
OPCItems (collection) OPCIte OPCItem m OPCItem OPCBrowser
OPC DA 初始化连接
find out existing OPC servers create an OPCServer object connect to that OPC server create an OPCBrowser object create an OPCGroups object create an OPCGroup object build array of items
EnumOPC对象属性条目
IUnknown
IEnumOPCItemAttributes
EnumOPCItemAttributes 对象
OPC客户与OPC服务器
C++客户应用
自定义接口 自动化接口
OPC 服务器
OPC接口 物理接口
SCADA系统
硬件设备
物理接口 硬件设备
VB客户应用
自定义接口与自动化接口
能够发挥OPC服务器的最佳性能,采用C ++语言的客户一般采用定制接口方案; • 自动化接口使解释性语言和宏语言访问 OPC服务器成为可能,采用VB等语言的 客户一般采用自动化接口
OPC DA 接口标准
• 数据访问方式
• DA功能实现过程
• DA的对象与接口
数据访问方式
• DA 的同步读取 • DA的异步读取 • DA的数据更新
"Automation" client (Visual Basic, Excel,…) OPC Automation wrapper
"Custom" client (C++,….)
custom interface server
custom interface server
自定义接口与自动化接口
• 自定义接口效率高,通过该接口,客户
• DA的数据订阅
• DA的同步写入 • DA的异步写入
DA 的同步读取
synchronous
client myGroup.SynchRead() server Call Reply
DA的异步读取
client myGroup.AsyncRead()
Call
server
Reply
myGroup_AsyncReadComplete()
Notify
myGroup_DataChange() myGroup.Refresh() Notify myGroup_DataChange()
数据源:cache/device
"SynchRead" reads the data either from cache (local to the PC) or reads synchronous from the device. "Write" is always to device (DA 3.0 allows write to cache) server samples items (at the RequestedUpdateRate) and puts them into cache
标准OPC服务器对象
必需的接口定义
• OPC服务器必需的接口有 Iunknown IOPCServer IOPCCommer IConnectionPointContainer
组(OPC Group)
• OPC Group存储由若干OPC Item组成
的Group信息,并用于返回OPC Item 类对象。OPC Group级别管理被称为 OPC Item的各个过程变量。 IOPCItemMgt接口提供将项加入组或 从组中删除项的方法(“AddItem”, “RemoveItem”)。 IOPCGroupStateMgt接口的方法用于 处理组专用的参数或复制组。
OPC项对象
IUnknown
IOPCItemDisp
OPC Item 对象
OPC 的过程数据构造
• OPC项代表了与服务器中的数据的连接。
客户程序对OPC项的操作都是通过包容 此项的OPC组来进行的,而不是直接把 OPC项作为一个对象来操作。每个OPC 项都有值(Value)。品质(Quality)和时 间戳(Time Stamp)三个属性。
• 可选的接口定义
• 服务器地址空间及配置 • 时间同步与顺序发送机制 • EnumOPC对象属性条目
通用OPC结构及组成
• OPC数据访问规范 • OPC报警和事件规
• OPC批处理规范 • OPC安全性规范 • OPC XML规范
对象及接口概述
no need for “device access” when fieldbus operates cyclically…
device FB agent
DA功能实现过程
1. OPC DA客户连接到DA服务器,建立
OPC Group和OPC Item; 2. 通过Group 和Item进行数据访问; 3. 处理完毕,关闭连接。
标准OPC组对象
项(OPC Item)
• OPC Item存储具体Item 的定义、数据
值、状态值等信息。OPC Item级别的 一个对象代表与一个过程变量的连接。 该对象的唯一接口是OPCItemDisp。关 于OPC Item的信息可以在属性表中找 到,例如数值(“Value”)属性或存取 路径(“AccessPath”)属性。
OPC DA对象的层次模型
Description An instance of an OPC Server. You must create an OPCServer object before you can get references to other objects. It contains the OPCGroups Collection and creates OPCBrowser objects. A collection containing all of the OPCGroup objects this client has created within the scope of the OPCServer that the Automation Application has connected to via OPCServer.Connect() An instance of an OPCGroup object. this object maintains state information and provides the mechanism to access data for the OPCItems Collection object that the OPCGroup object references. A collection containing all of the OPCItem objects this client has created within the scope of the OPCServer, and corresponding OPCGroup object that the Automation Application has created. An automation object that maintains the item’s definition, current value, status information, last update time. Note the Custom Interface does not provide a separate Item Object. An object that browses item names in the server’s configuration. There exists only one instance of an OPCBrowser object per instance of an OPC Server object.