应用COM开发OPC DA服务器

VIP免费
应用 COM 开发 OPC DA 服务器
摘 要
OPC (OLE for Process Control) 是一种通用工业控制标准,是由世界上领先的
自动化软硬件厂商与微软公司合作,所制定的一套标准的接口协议。OPC 技术主
要是为了解决由于设备驱动的非共享性,导致的应用程序难以同时与所有设备进
行通讯而提出的,它将软件应用程序开发与硬件设备提供商分离开来,两部分各
司其职,以 OPC 技术为中间件,同时提升了双方的工作效率,并从整体上优化了
典型工业控制系统兼容性差,数据传输效率低的情况,也进一步提高了系统的集
成性。OPC 技术代表了今后过程控制系统发展的主方向。
本文通过研究 OPC 数据访问规范 (OPC Data Access Specification),开发一个
可重用的 OPC DA 服务器来访问底层的硬件,并将数据以 OPC 接口的方式提供给
任何支持 OPC 规范的客户应用软件,使得客户能通过统一的数据访问标准来访问
不同厂商的硬件设备,方便系统的集成。
OPC DA 服务器的开发是以 COM (Component Object Model) 为基础的。本文
根据 COM 技术的原理,分析研究了 COM 对象的创建、实现、注册等方法,并详
细论述了基于 COM 技术的 OPC DA 服务器的开发原理和实现过程,提出了 OPC
DA 服务器的软件结构以及各对象的层次关系,给出了各对象主要接口的实现方
法。通过研究 OPC DA 的通信机制,阐述了 OPC DA 规范中以数据通报和连接点
为核心技术的两种不同的异步数据交换机制并付诸于具体实现。
本文根据实际开发所碰到的问题,给出了各接口实现过程中所需要注意的事
项,考虑到 OPC DA 服务器的向下兼容性,同时实现了 OPC 1.0 和OPC 2.0 异步
数据交换接口,分析了其中的工作原理以及回调函数的作用,完成了 OPC DA 服
务器与客户端的双向通信。
本文最后使用标准 OPC 客户端对 OPC DA 服务器的整体实现情况进行了测试,
根据 OPC DA 规范的标准,对对象管理以及同步、异步数据交换的测试结果进行
了评估。
关键词:OPC 服务器 工业控制标准 中间件 COM 技术 数据访
问规范 异步数据交换 连接点技术
ABSTRACT
OPC (OLE for Process Control) is a kind of general criterion of industrial control.
It’s a standard protocol of interface which is made by the one-up automatism software
and hardware corporations in the world. Because the drivers of devices can’t be shared
each other, the OPC technology is put forward to solve the problem and let the
applications can communicate with all the devices. It separates the development of
software applications from the hardware device providers. The two separated parts
perform their respective roles and advance their working efficiency with the OPC
technology as a middle component. The OPC technology optimizes the classic industrial
control system in the whole with the situation of poor compatibility and low efficiency
in data transmission, and improves the system integration further. It represents the main
development aspect of the process control system in the future.
This paper mainly develops a reusable OPC DA Server to access the bottom
hardware through researching the OPC Data Access Specification, and provides the data
in the way of OPC interfaces to the application software which support the OPC
specification so as to let the Clients access the different devices with a uniform data
access criterion and make the system integrate conveniently.
COM (Component Object Model) is the basis of developing the OPC DA Server.
According to the principles of the COM technology, this paper researches the methods
of creating, realizing and registering the COM object, and discusses the development
principles and realization process of the OPC DA Server which base on the COM
technology in detail. The paper also puts forward to the software structure of the OPC
DA Server and the hiberarchy of the objects, and offers the realization methods of the
main interfaces of each object. Through researching the communication mechanism of
the OPC, this paper sets forth two different asynchronous data exchange mechanisms
mainly with the data message and the connection point as the internal technologies in
the OPC DA Specification and realize them.
According to the problems got in practice, this paper describes the events need to
be noticed in the realization process. Considering the compatibility of the OPC DA
Server, the asynchronous data exchange interfaces of OPC 1.0 and OPC 2.0 are realized
at one time. This paper analyzes the working principles and the operations of the
callback functions of them and achieves the bidirectional communication between the
OPC DA Server and Client.
At last, this paper uses the standard OPC Clients to test the whole realization
situation of the OPC DA Server, and evaluates the test results of the objects
management, synchronous and asynchronous data exchange with the OPC DA
Specification.
Key Words: OPC Server, industrial control criterion, middle
component, COM technology, Data Access Specification, asynchronous
data exchange, connection point technology
目 录
摘 要
ABSTRACT
第一章 绪 论..........................................................................................................1
§1.1 OPC 概述....................................................................................................1
§1.1.1 控制系统现状....................................................................................1
§1.1.2 OPC 技术发展现状...........................................................................2
§1.1.3 OPC 规范简介...................................................................................3
§1.2 课题研究内容及意义...................................................................................3
§1.2.1 问题的提出........................................................................................3
§1.2.2 主要研究内容....................................................................................4
§1.2.3 研究的意义........................................................................................5
§1.2.4 论文结构............................................................................................5
第二章 OPC 规范.....................................................................................................7
§2.1 OPC 技术发展过程......................................................................................7
§2.2 OPC DA 规范的内容...................................................................................8
§2.2.1 OPC Server 对象结构......................................................................8
§2.2.2 OPC Group 对象结构......................................................................9
§2.2.3 OPC 通信的基本架构...................................................................10
第三章 COM 技术..................................................................................................12
§3.1 COM 特性及其与 OPC 的关系...............................................................12
§3.2 COM 对象和接口.....................................................................................13
§3.2.1 COM 对象......................................................................................13
§3.2.2 COM 接口......................................................................................15
§3.2.3 COM 接口的原则..........................................................................17
§3.3 COM 中的通信机制.................................................................................18
§3.3.1 可连接对象的双向通信机制........................................................18
§3.3.2 数据通报的双向通信机制............................................................21
§3.3.3 DCOM 技术...................................................................................22
§3.4 COM 组件的开发方式.............................................................................24
§3.4.1 COM 组件开发方式比较..............................................................24
§3.4.2 ATL 对COM 技术的支持.............................................................25
第四章 OPC DA 服务器规划设计........................................................................28
§4.1 OPC DA 服务器结构...............................................................................28
§4.2 OPC DA 通信机制...................................................................................28
§4.2.1 数据访问方法................................................................................29
§4.2.2 数据传送方式................................................................................30
§4.3 活动状态和数据源对数据获取的影响....................................................33
§4.3.1 IOPCSyncIO..................................................................................33
§4.3.2 IOPCAsyncIO................................................................................33
§4.3.3 经由 IDataObject 订阅数据...........................................................34
§4.3.4 IOPCAsyncIO2..............................................................................34
§4.3.5 经由 IOPCDataCallback 订阅数据...............................................35
§4.4 OPC DA 服务器接口方法.......................................................................35
第五章OPC DA 服务器程序实现........................................................................40
§5.1 OPC 服务器端 DA 规范内容的实现.......................................................40
§5.1.1 服务器组件对象的创建................................................................40
§5.1.2 服务器注册....................................................................................41
§5.1.3 OPC 服务器 DA 接口的实现........................................................43
§5.2 OPC DA 服务器与以太网网关的通信...................................................54
第六章OPC DA 服务器的测试............................................................................56
§6.1 服务器测试的软、硬件环境...................................................................56
§6.2 服务器通用性测试...................................................................................56
§6.3 服务器组和项的管理测试.......................................................................58
§6.4 数据同步读写测试...................................................................................60
§6.5 数据异步读写测试...................................................................................61
§6.5.1 数据异步 1.0 读写测试................................................................62
§6.5.2 数据异步 2.0 读写测试................................................................63
结束与展望..................................................................................................................65
附 录..........................................................................................................................67
参考文献......................................................................................................................80
第一章 绪论
第一章 绪 论
§1.1 OPC概述
§1.1.1 控制系统现状
在以往的工业控制中,各种仪器、仪表、PLC以及单片机等设备都是通过通信
协议与计算机进行通讯的。然而,随着计算机控制系统的不断发展,由于缺乏统一
的工业控制标准,造成不同厂商的设备乃至不同类型的设备在与计算机的通讯过程
中使用的协议都有所不同,这就给开发设备驱动程序带来了极大的不便以及大量重
复性的开发工作。有时,设备厂商仅仅对设备做了一些小小的改动,驱动程序就有
可能需要重写;此外,由于设备的多样性,在技术上也很难做到同时对不同的一些
设备进行访问来优化操作。虽然众多设备厂商也在不断尝试去解决这个问题,但是
由于不同客户有不同需求,而且存在很多不同的数据传输协议,因此收效甚微。
从程序设计角度而言,由于不同的编程语言对驱动程序的接口也有着不同的要
求,因此每一个针对不同客户开发的应用程序在与数据源进行数据交换的时候,通
常都会根据不同的硬件设备采用不同的驱动程序来提供软硬件之间的通讯,这就会
带来一些问题:
1有多少硬件设备就会有多少驱动程序;
2系统包含的硬件设备越多,则负责通信的模块也越多,使用到的驱动也就
越多,这在无形中就极大地限制了系统今后的升级换代;
3由于驱动程序一般不能共享使用,因此,不同的应用程序通常不能同时访
问同一个硬件设备;
随着计算机软件的发展,这种情况有所改观,高级语言中库函数的采用,在一
定程度上实现了资源共享,尤其是面向对象开发方法的应用,使得我们可以利用开
发语言的继承等方式来大量重用源代码。但这些只是对源代码的重用而不是对可执
行文件的重用,所以并没有在真正意义上实现资源的共享。此外,由于对某个模块
中某个类库的修改往往引发所有引用该类库的模块的修改,因此非常难以对某个模
块进行升级。同时,为一种语言开发的类库以及函数库都不能够为其他语言所用,
这也在很大程度上限制了软件的重用。
以常见的DSC (Distributed Control System) 系统为例,该系统实现了人机接口
通信以及数据处理等功能在网络上的分布,同时将一个系统划分为各个子系统,降
低了系统的复杂程度,改善了系统的性能,减少了开发周期与维护费用,但由于系
统中各个硬件设备与计算机的通信协议没有形成统一的标准,因此难以将不同的软
硬件进行有效的集成,也难以在真正意义上实现软件的共享。为了使工业控制计算
环境中的各个数据源之间能够灵活地进行通信,制订出一种能有效进行数据访问和
管理的开放标准就显得尤为关键和重要了。
- 1 -
摘要:
展开>>
收起<<
应用COM开发OPCDA服务器摘要OPC(OLEforProcessControl)是一种通用工业控制标准,是由世界上领先的自动化软硬件厂商与微软公司合作,所制定的一套标准的接口协议。OPC技术主要是为了解决由于设备驱动的非共享性,导致的应用程序难以同时与所有设备进行通讯而提出的,它将软件应用程序开发与硬件设备提供商分离开来,两部分各司其职,以OPC技术为中间件,同时提升了双方的工作效率,并从整体上优化了典型工业控制系统兼容性差,数据传输效率低的情况,也进一步提高了系统的集成性。OPC技术代表了今后过程控制系统发展的主方向。本文通过研究OPC数据访问规范(OPCDataAccessSpecif...
作者:高德中
分类:高等教育资料
价格:15积分
属性:83 页
大小:1.48MB
格式:DOC
时间:2024-11-19