ImageVerifierCode 换一换
格式:PPTX , 页数:102 ,大小:684.53KB ,
资源ID:9537197      下载积分:18 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/9537197.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(OPC接口技术.pptx)为本站上传会员【精****】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

OPC接口技术.pptx

1、单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,#,内容提要,概述,OPC,基本原理,OPC DA,接口标准,OPC AE,接口标准,OPC HDA,接口标准,OPC XML,接口标准,OPC,基本原理,通用,OPC,结构及组成,对象及接口概述,必需的接口定义,可选的接口定义,服务器地址空间及配置,时间同步与顺序发送机制,EnumOPC,对象属性条目,通用,OPC,结构及组成,OPC,数据访问规范,OPC,报警和事件规范,OPC,数据交换规范,OPC,历史数据访问规范,OPC,批处理规范,OPC,安全性规范,OPC XML,规范,对象及接口概述,OPC,对

2、象,OPC,对象有三个:,服务器,(OPC Server),、,组,(OPC Group),和,项,(OPC Item),OPC,接口,服务器,OPC Server,即,OPC,启动服务器,通过它获得其他对象和服务的起始类,并用于返回,OPC Group,类对象。,OPC Server,级别有多种属性,其中包含一个,OPC,服务器对象的状态和版本等信息。这种级别中的对象由客户应用创建。,IOPCServer,接口包含管理,OPC Group,级别中的对象的方法。如将组加入服务器或从服务器中删除组的方法(,AddGroup,,,RemoveGroup,)。,IOPCBrowseServerAdd

3、ressSpace,接口包含查找服务器地址空间的方法。,IOPCCommon,接口方法用于通知服务器语言的设置和客户机的名称。,标准,OPC,服务器对象,必需的接口定义,OPC,服务器必需的接口有,Iunknown,IOPCServer,IOPCCommer,IConnectionPointContainer,组,(OPC Group),OPC Group,存储由若干,OPC Item,组成的,Group,信息,并用于返回,OPC Item,类对象。,OPC Group,级别管理被称为,OPC Item,的各个过程变量。,IOPCItemMgt,接口提供将项加入组或从组中删除项的方法(“,Ad

4、dItem,”,,“,RemoveItem,”,)。,IOPCGroupStateMgt,接口的方法用于处理组专用的参数或复制组。,标准,OPC,组对象,项,(OPC Item),OPC Item,存储具体,Item,的定义、数据值、状态值等信息。,OPC Item,级别的一个对象代表与一个过程变量的连接。该对象的唯一接口是,OPCItemDisp,。关于,OPC Item,的信息可以在属性表中找到,例如数值(“,Value,”,)属性或存取路径(“,AccessPath,”,)属性。,OPC,项对象,OPC,的过程数据构造,OPC,项代表了与服务器中的数据的连接。客户程序对,OPC,项的操作

5、都是通过包容此项的,OPC,组来进行的,而不是直接把,OPC,项作为一个对象来操作。每个,OPC,项都有值,(Value),。品质,(Quality),和时间戳,(Time Stamp),三个属性。,EnumOPC,对象属性条目,OPC,客户与,OPC,服务器,自定义接口与自动化接口,OPC Automation,wrapper,Automation client,(Visual Basic,Excel,),custom interface,server,Custom client,(C+,.),custom,interface,server,自定义接口与自动化接口,自定义接口效率高,通过该接

6、口,客户能够发挥,OPC,服务器的最佳性能,采用,C,语言的客户一般采用定制接口方案;,自动化接口使解释性语言和宏语言访问,OPC,服务器成为可能,采用,VB,等,语言的客户一般采用自动化接口,OPC DA,接口标准,数据访问方式,DA,功能实现过程,DA,的对象与接口,数据访问方式,DA,的同步读取,DA,的异步读取,DA,的数据更新,DA,的数据订阅,DA,的同步写入,DA,的异步写入,DA,的同步读取,myGroup.SynchRead(),client,Call,Reply,server,synchronous,DA,的异步读取,myGroup.AsyncRead(),myGroup_

7、AsyncReadComplete(),server,Call,Reply,client,DA,的数据订阅,server,Subscribe,Notify,myGroup.IsSubscribed,myGroup_DataChange(),myGroup_DataChange(),client,Notify,数据订阅传输模式,server,Subscribe,Notify,myGroup.IsSubscribed,myGroup_DataChange(),myGroup_DataChange(),client,Notify,myGroup.Refresh(),myGroup_DataChang

8、e(),Notify,数据源,: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

9、 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 3.0 allows write to cache),DA,功能实现过程,OPC DA,客户连接到,DA,服务器,建立,OPC Group,和,OPC Item,;,通过,Group,和,Item,进行数据

10、访问;,处理完毕,关闭连接。,OPC DA,对象的层次模型,OPCItem,OPCBrowser,OPCServer,OPCGroups(collection),OPCGroup,OPCItems(collection),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 objec

11、ts.,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 da

12、ta 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 t

13、he items 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 servers configuration.There exists only one instance of an OPCBrowser object per instance of an OPC Server object.,OPCItem

14、OPCItem,OPCGroup,OPC DA,初始化连接,find out existing OPC servers,connect to that OPC server,create an OPCBrowser object,create an OPCGroups object,create an OPCServer object,create an OPCGroup object,build array of items,checking with the browser that these items exist in this server,add item array to t

15、he group,activate and subscribe group,next,group,初始化,myDummyServer.GetOPCServers,myServer.Connect,Set myBrowser=myServer.Browser,Set myGroups=myServer.Groups,myServer=new OPCServer,Set myGroup1=myGroups.AddSet MyItems=MyGroup1.OPCItems,FQItems11=Device1.Temp1,ClientHandle11=101,ReDim ServerHandle1(n

16、rItems),ReDim ServerErrors1(nrItems),ReDim Value1(nrItems),myGroup1.AddItems,myGroup1.IsActive,myGroup1.IsSubscribed,Declarations,Option Base 1,OPC arrays indices start with 1,Dim,WithEvents,MyServer As OPCServer,OPC Server Object(Events optional),Dim,WithEvents,MyGroups As OPCGroups,OPC Group Colle

17、ction(Events opt.),Dim,WithEvents,MyGroup As OPCGroup ,OPC Group Object,items,Dim nrItems,As Integer,Dim MyItems As OPCItems,OPC Item Collection Object,Dim MyItem As OPCItem,OPC Item Object,Dim ItemsID(2)As String,fully qualified items(see later),Dim ClientHandles(2)As Long,Dim ServerHandles()As Lon

18、g,must be a dynamic array,Dim ServerErrors()As Long,must be a dynamic array,Reference:OPC Automation 2.0 must be included into Visual Basic or C#,(if missing:copy opcdaauto.dll to C:WINNTSystem32opddaauto),and register it:C:regsvr32 C:WINNTSystem32opddaauto.,A simple way to do it:install Software To

19、olboxs TopServer(freeware),查找,OPC,服务器,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

20、 by each server at its installation time,。,Private Sub ShowServers(netNodeName As String),Dim,dummyS,erver As OPCServer,Dim Servers As Variant,this is an array of strings,Dim,cntServers,As Integer,Set,dummyServer,=New OPCServer,create a,dummy,server object,Servers=,dummyServer,.GetOPCServers(,netNod

21、eName,),returns all available servers,For,cntServers,=LBound(Servers)To UBound(Servers),display the names,MsgBox,Servers(,cntServers,),Next,cntServers,Set Getserver=Nothing,delete,this,object(,was created,by,N,ew,),Exit Sub,连接到,OPC,服务器,Set MyServer=New OPCServer,create server object,MyServer.Connect

22、Matrikon.OPC.Simulation),connect to Matrikon,server,Before connecting,it is safe to check the name of the server from the servers list.,Also,it is preferable to include the connection in a separate routine since it can fail:,Function ServerGetCare(Name As String,ServerNode As String)As OPCServer,On

23、 Error GoTo ServerGetCareErr,Dim MyOPCServer As New OPCServer,MyOPCServer.Connect ServerName,ServerNode connect risky,Set ServerGetCare=MyOPCServer,Exit Function,ServerGetCare_Err:,error handler,if connect fails,Err.Clear,MsgBox Could not connect,Set MyServer=Nothing,Exit Function,浏览服务器,The object O

24、PCBrowser(of type collection)acts as a pointer to the servers tree:,Dim MyServer As OPCServer,Dim MyBrowser As OPCBrowser,Dim vName As Variant,MyServer.Connect,Matrikon.OPC.Simulation,Orion,server,and node name,(DCOM),Set MyBrowser=MyServer.CreateBrowser,create an OPC browser,MyBrowser.ShowBranches,

25、show the branches,For Each vName In MyBrowser,MsgBox Branch:&,vName,display the branch name,Next vName,MyBrowser.Show,Leafs,explore the,leaves,For Each vName In MyBrowser,MsgBox Leaf:&,vName,display the leavess name,Next vName,浏览,MyBrowser.MoveDown(strBranch)go down the selected branch tree,MyBrowse

26、r.MoveUp go up the selected branch tree,site properties,TAG,Server root,Level,Temperature,Valve_On,TAG,TAG,TAG,Site A,Store,Machine Room,Grinder,Wash Room,Climate,server,Tank,There may be leaves at every branch,since a branch may have properties,获得,ItemID,myOPCBrowser.MoveDown(TankArea),myOPCBrowser

27、MoveDown(Tank1),FQI=,myOPCBrowser.GetItemId,(Level),Of course,one can write an Item ID directly when defining a group,but it is safer to browse the server and get the FQI from there,since the delimiter depends on the server.,To get the fully qualified itemID,one positions the browser at the place w

28、here the leaf is attached to the branch and calls GetItemID,e.g.FQI could be Controller1;Tanks!Level,创建,OPCGroups and OPCItems,Set MyGroups=MyServer.OPCGroups create groups collection,Set MyGroup1=MyGroups.Add(GRP1)add group,name private,Set MyItems=MyGroup1.OPCItems define the OPCItems of group,FQI

29、temIDs(1)=Area2.Tank1.Level fully qualified itemID,ClientHandles(1)=5 arbitrary,FQItemIDs(2)=Area2.Tank1.Temperature fully qualified itemID,ClientHandles(2)=6 arbitrary(but different),nrItems=2,MyItems.AddItems _ adds the items tocollection nrItems,_ input parameter,FQItemIDs,_ supply fully qualifie

30、d ID,ClientHandles,_ supply ClientHandles,ServerHandles,_ return parameterServerHandles,ServerErrors return parameter ServerErrors,MyGroup1.ClientHandle=1 handle of the group(no s)!,MyGroup1.IsActive=True now ready to send and receive,MyGroup1.IsSubscribed=True and to generate events,The role of the

31、 ServerHandles and ClientHandles will be explained later,客户端 的数据结构,Fully,QualifiedItem,ID,ClientHandle,ServerHandle,Channel1.Device1.Temp1,communicated to server by registering group,ServerError,Value,Quality,TimeStamp,100,34543,0,123.4,OK,12:09.234,Channel1.Device1.,Speed,1,102,22532,0,999.8,OK,12:

32、02.214,Channel1.,PLC2,.,Door,203,534676,0,0,OK,12:03.002,Channel1.,PLC2,.,Valve3,204,787234,0,1,OK,12:02.345,Channel1.,PLC2,.,CloseDoor,205,58432,0,0,BAD,12:02.345,returned by server,when registering,dynamic changes,(refreshed on change),The client prepares data structures for its items and gives th

33、e server the corresponding pointers so the server can update them.,Items to be written and read can be mixed in the same group.,The type of the item(Boolean,Float,)is implicit,but known at the server,.,.,.,.,.,.,Dim thisGroup As OPCGroup,Dim cntItems As Integer,Dim source As Integer,Dim,s,erverHandl

34、es(2)As Long,Dim,v,alues()As Variant,Dim,e,rrors()As Long,s,erverHandles(1)=ServerHandle(11),copy,from global variables,s,erverHandles(2)=ServerHandle(14),source=OPCcache,could also be OPCDevice,thisGroup.SyncRead source,nrItems,s,erverHandles,identifies the items to be read!,v,alues,returns be a dy

35、namic array,e,rrors,returns a dynamic array,For cntItems=LBound(,s,erverHandles)To UBound(,s,erverHandles)1.n,MsgBox CStr(cntItems)&:&,v,alues(cntItems),Next cntItems,myGroup.SynchRead(),client,Call,Reply,server,Group,的同步读,single Items,的异步读,AsyncRead(),AsyncReadComplete(),server,Dim WithEvents MyGro

36、up,.,MyGroup.AsyncRead,nrItems,ServerHandles,ServerErrors,TransactionID,CancelID,Call,Reply,client,Private Sub Mygroup_AsyncReadComplete(ByVal,TransactionID,As Long,ByVal NumItems As Long,ClientHandles()As Long,ItemValues()As Variant,Qualities()As Long,TimeStamps()As Date,Errors()As Long),MsgBox(Asy

37、nc Read Complete)End Sub,Asynchronous read separates Call and Reply.,Call supplies the ServerHandles,Reply returns the corresponding ClientHandles,AsyncRead(source=device),AsyncReadComplete(),server,Call,Reply,client,AsyncRead(source=cache),AsyncRead(source=device),Although the AsynchReadComplete ca

38、rries the ClientHandle of each item,it does not tell which AsynchRead caused the AsynchReadComplete event to fire.,Call and Reply are linked by the TransactionID:this ID is returned in AsynchReadComplete,。,It can also be used to cancel the operation,AsyncCancel(),AsyncCancelComplete(),Transaction ID

39、Reading(by events)the OPC group,Dim WithEvents MyGroup,.,Private Sub MyGroup_DataChange(_,ByVal TransactionID As Long,_,ByVal N,r,Items As Long,_,ClientHandles()As Long,_,returned by the server to the client,ItemValues()As Variant,_,Qualities()As Long,_,TimeStamps()As Date),Dim cntItems As Integer,

40、For cntItems=LBound(ClientHandles)To UBound(ClientHandles)index 1.n,TextValue(cntItems-1).Text =ItemValues(cntItems)display,TextTimeStamp(cntItems-1).Text=DateAdd(h,9,TimeStamps(cntItems),TextQuality(cntItems-1).Text =Qualities(cntItems),Next cntItems,End Sub,This function is called each time an ite

41、m in the group changes,The ClientHandles(here:5 and 6)identifies the variables,not the“fully qualified itemID”,The values are displayed in the TextValue,TextTimeStamp and TextQuality fields.The refresh rate is given in the group definition.,Groups Events,Although transmission by groups is more effic

42、ient than AsyncRead,it can be improved,by using Groups Events(Global Data Change),This event is fired whenever a variable of a group changes.,If the group is subscribed also to a Group Event(DataChange),I.e.if the group is,declared WithEvents,then both Events will be fired.,The application must sort

43、 out the groups and the items.,GlobalDataChange,Dim WithEvents MyGroups As OPCGroups,.,Private Sub MyGroups_GlobalDataChange(,ByVal TransactionID As Long,=0 if called by Refresh,ByVal GroupHandle As Long,ByVal NumItems As Long,ClientHandles()As Long,identifies the items,ItemValues()As Variant,value

44、of the items,Qualities()As Long,value of the items,TimeStamps()As Date)timestamps of the items,Select Case GroupHandle depending on the group,.,Case 1,treat group 1,Case 2,treat group 2,The GlobalDataChange event is fired when any item in a group changed.,(if Groups is also with events,the correspon

45、ding Group_DataChange will also be called),OPC DA:Server Events,Dim WithEvents MyServer As OPCServer,define the event,.,Private Sub Myserver_ServerShutDown(ByVal Reason As String),MsgBox my OPC Server&MyServer.ServerName&quit,End Sub,This event signals to the client that the server shut down.,The cl

46、ient must declare its server WithEvents“and provide the corresponding event Subroutine,This should stop all actions,otherwise exceptions will occur.,OPC,的断开,Private Sub ServerShutdown,Dim,dummyS,erver As OPCServer,Dim Servers As Variant,this is an array of strings,Dim,cntServers,As Integer,Set,myGro

47、up1=Nothing,create a,dummy,server object,Set myGroups=Nothing,returns all available servers,MyServer.Remove,MyServer.RemoveAllGroups,MyServer.Disconnect,delete,this,object(,was created,by,N,ew,),Set MyServer=Nothing,To speed up connection/disconnection,an OPC server remembers its groups and clients

48、when a client disconnects.,To do this,an OPC server initialises its structures with a client counter of 2,instead of 1.,Therefore,it is imperative to shut down explicitly the server,otherwise links will subside,(and you will have kill the server to clear them).,OPC DA,的类库,The OPC DA specification is

49、 not formal,conformance can hardly be checked against this document.,To ensure that the standard is observed,the OPC foundation distributes on its website the DLLs(opcdaauto.dll,opccomn_ps,)that contain the type libraries to access the OPC server.,The vendors are not compelled to implement all featu

50、res.For instance,the description of the variables is seldom used.Calling unimplemented functions causes exceptions that must be caught in Visual Basic with On Error statements.,There exist three versions of DA,1.0,2.0 and 3.0,that behave differently,however,older servers do not have a property indic

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服