您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 国内外标准规范 > OPC接口技术的介绍
OPC接口技术谈英姿tanyz@seu.edu.cn东南大学自控系工业自动化教研室内容提要•概述•OPC基本原理•OPCDA接口标准•OPCAE接口标准•OPCHDA接口标准•OPCXML接口标准OPC基本原理•通用OPC结构及组成•对象及接口概述•必需的接口定义•可选的接口定义•服务器地址空间及配置•时间同步与顺序发送机制•EnumOPC对象属性条目通用OPC结构及组成•OPC数据访问规范•OPC报警和事件规范•OPC数据交换规范•OPC历史数据访问规范•OPC批处理规范•OPC安全性规范•OPCXML规范对象及接口概述•OPC对象OPC对象有三个:服务器(OPCServer)、组(OPCGroup)和项(OPCItem)•OPC接口服务器•OPCServer即OPC启动服务器,通过它获得其他对象和服务的起始类,并用于返回OPCGroup类对象。OPCServer级别有多种属性,其中包含一个OPC服务器对象的状态和版本等信息。这种级别中的对象由客户应用创建。IOPCServer接口包含管理OPCGroup级别中的对象的方法。如将组加入服务器或从服务器中删除组的方法(AddGroup,RemoveGroup)。IOPCBrowseServerAddressSpace接口包含查找服务器地址空间的方法。IOPCCommon接口方法用于通知服务器语言的设置和客户机的名称。标准OPC服务器对象必需的接口定义•OPC服务器必需的接口有IunknownIOPCServerIOPCCommerIConnectionPointContainer组(OPCGroup)•OPCGroup存储由若干OPCItem组成的Group信息,并用于返回OPCItem类对象。OPCGroup级别管理被称为OPCItem的各个过程变量。IOPCItemMgt接口提供将项加入组或从组中删除项的方法(“AddItem”,“RemoveItem”)。IOPCGroupStateMgt接口的方法用于处理组专用的参数或复制组。标准OPC组对象项(OPCItem)•OPCItem存储具体Item的定义、数据值、状态值等信息。OPCItem级别的一个对象代表与一个过程变量的连接。该对象的唯一接口是OPCItemDisp。关于OPCItem的信息可以在属性表中找到,例如数值(“Value”)属性或存取路径(“AccessPath”)属性。OPC项对象IOPCItemDispIUnknownOPCItem对象OPC的过程数据构造•OPC项代表了与服务器中的数据的连接。客户程序对OPC项的操作都是通过包容此项的OPC组来进行的,而不是直接把OPC项作为一个对象来操作。每个OPC项都有值(Value)。品质(Quality)和时间戳(TimeStamp)三个属性。EnumOPC对象属性条目IUnknownEnumOPCItemAttributes对象IEnumOPCItemAttributesOPC客户与OPC服务器自定义接口OPC服务器OPC接口物理接口SCADA系统硬件设备物理接口硬件设备C++客户应用自动化接口VB客户应用自定义接口与自动化接口OPCAutomationwrapperAutomationclient(VisualBasic,Excel,…)custominterfaceserverCustomclient(C++,….)custominterfaceserver自定义接口与自动化接口•自定义接口效率高,通过该接口,客户能够发挥OPC服务器的最佳性能,采用C++语言的客户一般采用定制接口方案;•自动化接口使解释性语言和宏语言访问OPC服务器成为可能,采用VB等语言的客户一般采用自动化接口OPCDA接口标准•数据访问方式•DA功能实现过程•DA的对象与接口数据访问方式•DA的同步读取•DA的异步读取•DA的数据更新•DA的数据订阅•DA的同步写入•DA的异步写入DA的同步读取myGroup.SynchRead()clientCallReplyserversynchronousDA的异步读取myGroup.AsyncRead()myGroup_AsyncReadComplete()serverCallReplyclientDA的数据订阅serverSubscribeNotifymyGroup.IsSubscribedmyGroup_DataChange()myGroup_DataChange()clientNotify数据订阅传输模式serverSubscribeNotifymyGroup.IsSubscribedmyGroup_DataChange()myGroup_DataChange()clientNotifymyGroup.Refresh()myGroup_DataChange()Notify数据源:cache/deviceclientapplication(OPCclient)fieldbusOPCservercachefieldbusdevicefieldbusdevicefieldbusconnectionserversamplesitems(attheRequestedUpdateRate)andputsthemintocachesynchronouscalloverthefieldbustotheenddevice(takesawhile)noneedfor“deviceaccess”whenfieldbusoperatescyclically…FBmanagerFBagentFBagentSynchReadreadsthedataeitherfromcache(localtothePC)orreadssynchronousfromthedevice.Writeisalwaystodevice(DA3.0allowswritetocache)DA功能实现过程1.OPCDA客户连接到DA服务器,建立OPCGroup和OPCItem;2.通过Group和Item进行数据访问;3.处理完毕,关闭连接。OPCDA对象的层次模型OPCItemOPCBrowserOPCServerOPCGroups(collection)OPCGroupOPCItems(collection)DescriptionAninstanceofanOPCServer.YoumustcreateanOPCServerobjectbeforeyoucangetreferencestootherobjects.ItcontainstheOPCGroupsCollectionandcreatesOPCBrowserobjects.AcollectioncontainingalloftheOPCGroupobjectsthisclienthascreatedwithinthescopeoftheOPCServerthattheAutomationApplicationhasconnectedtoviaOPCServer.Connect()AninstanceofanOPCGroupobject.thisobjectmaintainsstateinformationandprovidesthemechanismtoaccessdatafortheOPCItemsCollectionobjectthattheOPCGroupobjectreferences.AcollectioncontainingalloftheOPCItemobjectsthisclienthascreatedwithinthescopeoftheOPCServer,andcorrespondingOPCGroupobjectthattheAutomationApplicationhascreated.Anautomationobjectthatmaintainstheitem’sdefinition,currentvalue,statusinformation,lastupdatetime.NotetheCustomInterfacedoesnotprovideaseparateItemObject.Anobjectthatbrowsesitemnamesintheserver’sconfiguration.ThereexistsonlyoneinstanceofanOPCBrowserobjectperinstanceofanOPCServerobject.OPCItemOPCItemOPCGroupOPCDA初始化连接findoutexistingOPCserversconnecttothatOPCservercreateanOPCBrowserobjectcreateanOPCGroupsobjectcreateanOPCServerobjectcreateanOPCGroupobjectbuildarrayofitemscheckingwiththebrowserthattheseitemsexistinthisserveradditemarraytothegroupactivateandsubscribegroupnextgroup初始化myDummyServer.GetOPCServersmyServer.ConnectSetmyBrowser=myServer.BrowserSetmyGroups=myServer.GroupsmyServer=newOPCServerSetmyGroup1=myGroups.AddSetMyItems=MyGroup1.OPCItemsFQItems1[1]=Device1.Temp1ClientHandle1[1]=101ReDimServerHandle1(nrItems)ReDimServerErrors1(nrItems)ReDimValue1(nrItems)myGroup1.AddItemsmyGroup1.IsActivemyGroup1.IsSubscribedDeclarationsOptionBase1'OPCarraysindicesstartwith1DimWithEventsMyServerAsOPCServer'OPCServerObject(Eventsoptional)DimWithEventsMyGroupsAsOPCGroups'OPCGroupCollection(Eventsopt.)DimWithEventsMyGroupAsOPCGroup'OPCGroupObject'itemsDimnrItemsAsIntegerDimMyItemsAsOPCItems'OPCItemCollectionObjectDimMyItemAsOPCItem'OPCItemObjectDimItemsID(2)AsString'fullyqualifieditems(seelater)DimClientHandles(2)AsLongDimServerHandles()AsLong'mustbeadynamicarrayDimServerErrors()AsLong'mustbeadynamicarrayReference:OPCAutomation2.0mustbeincludedintoVisualBasicorC#(ifmissing:copyopcdaauto.dlltoC:\WINNT\System32\opddaauto)andregisterit:C:\regsvr32C:\WINNT\System32\opddaauto.Asimplewaytodoit:installSoftwareToolbox'sTopServer(freeware)查找OPC服务器TheGetOPCServersfunctionappliedtoadummyServerobjectallowtolisttheexistingservers
本文标题:OPC接口技术的介绍
链接地址:https://www.777doc.com/doc-6011490 .html