【正文】
為一個(gè)對(duì)象來(lái)操作。關(guān)于 OPC Item的信息可以在屬性表中找到,例如數(shù)值(“ Value”)屬性或存取路徑(“ AccessPath”)屬性。 OPC Item級(jí)別的一個(gè)對(duì)象代表與一個(gè)過程變量的連接。IOPCGroupStateMgt接口的方法用于處理組專用的參數(shù)或復(fù)制組。 OPC Group級(jí)別管理被稱為OPC Item的各個(gè)過程變量。 IOPCCommon接口方法用于通知服務(wù)器語(yǔ)言的設(shè)置和客戶機(jī)的名稱。如將組加入服務(wù)器或從服務(wù)器中刪除組的方法( AddGroup, RemoveGroup)。這種級(jí)別中的對(duì)象由客戶應(yīng)用創(chuàng)建。OPC接口技術(shù) 談?dòng)⒆? 東南大學(xué)自控系工業(yè)自動(dòng)化教研室 內(nèi)容提要 ? 概述 ? OPC基本原理 ? OPC DA 接口標(biāo)準(zhǔn) ? OPC AE 接口標(biāo)準(zhǔn) ? OPC HDA 接口標(biāo)準(zhǔn) ? OPC XML接口標(biāo)準(zhǔn) OPC基本原理 ? 通用 OPC結(jié)構(gòu)及組成 ? 對(duì)象及接口概述 ? 必需的接口定義 ? 可選的接口定義 ? 服務(wù)器地址空間及配置 ? 時(shí)間同步與順序發(fā)送機(jī)制 ? EnumOPC對(duì)象屬性條目 通用 OPC結(jié)構(gòu)及組成 ? OPC數(shù)據(jù)訪問規(guī)范 ? OPC報(bào)警和事件規(guī)范 ? OPC數(shù)據(jù)交換規(guī)范 ? OPC歷史數(shù)據(jù)訪問規(guī)范 ? OPC批處理規(guī)范 ? OPC安全性規(guī)范 ? OPC XML規(guī)范 對(duì)象及接口概述 ? OPC對(duì)象 OPC對(duì)象有三個(gè): 服務(wù)器 (OPC Server)、 組(OPC Group)和 項(xiàng) (OPC Item) ? OPC接口 服務(wù)器 ? OPC Server即 OPC啟動(dòng)服務(wù)器,通過它獲得其他對(duì)象和服務(wù)的起始類,并用于返回 OPC Group類對(duì)象。 OPC Server級(jí)別有多種屬性,其中包含一個(gè) OPC服務(wù)器對(duì)象的狀態(tài)和版本等信息。 IOPCServer接口包含管理 OPC Group級(jí)別中的對(duì)象的方法。IOPCBrowseServerAddressSpace接口包含查找服務(wù)器地址空間的方法。 標(biāo)準(zhǔn) OPC服務(wù)器對(duì)象 必需的接口定義 ? OPC服務(wù)器必需的接口有 Iunknown IOPCServer IOPCCommer IConnectionPointContainer 組 (OPC Group) ? OPC Group存儲(chǔ)由若干 OPC Item組成的 Group信息,并用于返回 OPC Item類對(duì)象。IOPCItemMgt接口提供將項(xiàng)加入組或從組中刪除項(xiàng)的方法(“ AddItem”,“ RemoveItem”)。 標(biāo)準(zhǔn) OPC組對(duì)象 項(xiàng) (OPC Item) ? OPC Item存儲(chǔ)具體 Item 的定義、數(shù)據(jù)值、狀態(tài)值等信息。該對(duì)象的唯一接口是 OPCItemDisp。 OPC項(xiàng)對(duì)象 I O P C I t e m D is pIUnknownO P C I t e m對(duì)象OPC 的過程數(shù)據(jù)構(gòu)造 ? OPC項(xiàng)代表了與服務(wù)器中的數(shù)據(jù)的連接。每個(gè) OPC項(xiàng)都有值 (Value)。 EnumOPC對(duì)象屬性條目 IUnknownEnumOPCItemAttributes對(duì)象IEnumOPCItemAttributesOPC客戶與 OPC服務(wù)器 自定義接口OPC服務(wù)器O P C 接口物理接口SCADA 系統(tǒng)硬件設(shè)備物理接口 硬件設(shè)備C + + 客戶應(yīng)用自動(dòng)化接口V B 客戶應(yīng)用自定義接口與自動(dòng)化接口 OPC Automation wrapper Automation client (Visual Basic, Excel,…) custom interface server Custom client (C++,….) custom interface server 自定義接口與自動(dòng)化接口 ? 自定義接口效率高,通過該接口,客戶能夠發(fā)揮 OPC服務(wù)器的最佳性能,采用 C++ 語(yǔ)言的客戶一般采用定制接口方案; ? 自動(dòng)化接口使解釋性語(yǔ)言和宏語(yǔ)言訪問OPC服務(wù)器成為可能,采用 VB等 語(yǔ)言的客戶一般采用自動(dòng)化接口 OPC DA 接口標(biāo)準(zhǔn) ? 數(shù)據(jù)訪問方式 ? DA功能實(shí)現(xiàn)過程 ? DA的對(duì)象與接口 數(shù)據(jù)訪問方式 ? DA 的同步讀取 ? DA的異步讀取 ? DA的數(shù)據(jù)更新 ? DA的數(shù)據(jù)訂閱 ? DA的同步寫入 ? DA的異步寫入 DA 的同步讀取 () client Call Reply server synchronous DA的異步讀取 () myGroup_AsyncReadComplete() server Call Reply client DA的數(shù)據(jù)訂閱 server Subscribe Notify myGroup_DataChange() myGroup_DataChange() client Notify 數(shù)據(jù)訂閱傳輸模式 server Subscribe Notify myGroup_DataChange() myGroup_DataChange() client Notify () myGroup_DataChange() Notify 數(shù)據(jù)源 :cache/device client application (OPC client) fieldbus OPC server cache fieldbus device fieldbus device fieldbus connection server samples items (at the RequestedUpdateRate) and puts them into cache synchronous call over the field bus to the end device (takes a while) no need for “device access” when fieldbus operates cyclically… FB manager FB agent FB agent SynchRead reads the data either from cache (local to the PC) or reads synchronous from the device. Write is always to device (DA allows write to cache) DA功能實(shí)現(xiàn)過程 1. OPC DA客戶連接到 DA服務(wù)器,建立OPC Group和 OPC Item; 2. 通過 Group 和 Item進(jìn)行數(shù)據(jù)訪問; 3. 處理完畢,關(guān)閉連接。OPC arrays indices start with 1 Dim WithEvents MyServer As OPCServer 39。OPC Group Collection (Events opt.) Dim WithEvents MyGroup As OPCGroup 39。 items Dim nrItems As Integer Dim MyItems As OPCItems 39。OPC Item Object Dim ItemsID(2) As String 39。 must be a dynamic array Dim ServerErrors() As Long 39。s TopServer (freeware) 查找 OPC服務(wù)器 The GetOPCServers function applied to a dummy Server object allow to list the existing servers on this node or on another node (over DCOM security must be set correctly) The information about which OPC servers exist is taken from the registry, where it has been put by each server at its installation time。 this is an array of strings Dim tServers As Integer Set dummyServer = New OPCServer 39。 returns all available servers For tServers = LBound(Servers) To UBound(Servers) 39。 delete this object (was created by New) Exit Sub 連接到 OPC服務(wù)器 Set MyServer = New OPCServer 39。 connect to Matrikon server Before connecting, it is safe to check the name of the server from the server39。 connect risky Set ServerGetCare = MyOPCServer Exit Function ServerGetCare_Err: 39。s tree: Dim MyServer As OPCServer Dim MyBrowser As OPCBrowser Dim vName As Variant , Orion 39。 create an OPC browser 39。 vName 39。 explore the leaves For Each vName In MyBrowser MsgBox Leaf: amp。 display the leaves39。 go down the selected branch tree 39。Tanks!Level 創(chuàng)建 OPCGroups and OPCItems Set MyGroups = 39。 add group, name private Set MyItems = 39。 fully qualified itemID ClientHandles(1) = 5 39。 fully qualified itemID ClientHandles(2) = 6 39。 adds the items tocollection nrItems, _ 39。 supply fully qualified ID ClientHandles, _ 39。 return parameterServerHandles ServerErrors 39。 handle of the group (no s) ! = True 39。 and to generate events The role of the ServerHandles and ClientHandles will be explained later… 客戶端 的數(shù)據(jù)結(jié)構(gòu) FullyQualifiedItemID ClientHandle ServerHandle municated to server by registering group ServerError Value Quality TimeStamp 100 34543 0 OK 12: 102 22532 0 OK 12: 203 534676 0 0 OK 12: 204 787234 0 1 OK 12: 205 58432 0 0 BAD 12: returned by server when registering dynamic changes (refreshed on change) The client prepares data structures for its items and gives the server the