OpenDDS安装与开发

OpenDDS安装与开发

1. OpenDDS介绍

官网:https://opendds.org/

是个开源的数据分发中间件,有三层:TAO+ACE+DDS

  • TAO负责封装数据,让OpenDDS支持跨平台;

  • ACE负责数据通信;

  • DDS负责数据的分发交互。

2. 环境搭建

主要包括三部分:

  • Perl:用于运行OpenDDS的用例和一些环境配置
  • OpenDDS:V3.20
  • ACE+TAO:V7.0.6

具体的安装步骤可以参考博客:https://blog.csdn.net/babypphappy/article/details/123228108 ,经过验证可以安装成功。

注:在编译TAO的过程中编译出错,错误如下:

…/orbsvcs\orbsvcs/Security.idl(7): fatal error C1083: 无法打开包括文件: “orb.idl”: No such file or directory [D:\DDS\ACE_wrappers\TAO\orbsvcs\orbsvcs\Security_vs2019.vcxproj]
…/orbsvcs\orbsvcs/Security.idl(7): fatal error C1083: 无法打开包括文件: “orb.idl”: No such file or directory [D:\DDS\ACE_wrappers\TAO\orbsvcs\orbsvcs\Security_vs2019.vcxproj]

参照博客ACE+TAO环境搭建 windows平台,需要先编译一下TAO\TAO_IDL文件夹里的TAO_IDL_ACE_vs2019.sln,另外需要保证已经通过Visual Studio Installer安装了通用Windows平台开发这一组件,另外注意ace\config.h配置中只有一行代码

#include "ace/config-win32.h"

3. OpenDDS测试

OpenDDS在配置完成,并将生成的解决方案.sln编译完成后,就可以通过perl run_test.pl命令进行测试,测试过程中报错如下:

D:\DDS\OpenDDS-3.20\examples\DCPS\Messenger_Imr>perl run_test.pl
Can't locate Win32/Process.pm in @INC (you may need to install the Win32::Process module) (@INC contains: D:\DDS\ACE_wrappers/bin D:\DDS\OpenDDS-3.20/bin D:\DDS\OpenDDS-3.20\bin\PerlDDS c:/Users/SN-539/AppData/Local/activestate/cache/922e561e/site/lib c:/Users/SN-539/AppData/Local/activestate/cache/922e561e/lib) at D:\DDS\ACE_wrappers/bin/PerlACE/Process_Win32.pm line 8.

提示找不到Win32/Process.pm,这个是Perl的模块缺失问题,可以直接在ActiveState命令行中通过state install Win32-Process安装对应的模块包:

[md/Perl-5.34.0-Windows] C:\Users\md\Perl-5.34.0-Windows>state install Win32-Process

安装完毕后,再运行命令perl run_test.pl,又出现新的错误:

.\.\publisher.EXE   -DCPSConfigFile pub.ini -orbendpoint iiop://:23204
ERROR: Cannot Spawn: <.\.\publisher.EXE> not found
.\.\subscriber.EXE   -DCPSConfigFile sub.ini
ERROR: Cannot Spawn: <.\.\subscriber.EXE> not found
cP is not of type Win32::Process at D:\DDS\ACE_wrappers/bin/PerlACE/Process_Win32.pm line 458.
ERROR: <D:\DDS\ACE_wrappers\TAO/orbsvcs/ImplRepo_Service/tao_imr_activator> still running upon object destruction
ERROR: <D:\DDS\ACE_wrappers\TAO/orbsvcs/ImplRepo_Service/tao_imr_locator> still running upon object destruction

缺少publishersubscriber,可能是由于目前使用的OpenDDS最新版本中示例文件就没有带这俩文件,不过通过文件全局搜索,发现在OpenDDS-3.20\DevGuideExamples\DCPS\Messenger目录下有上一步sln编译生成好的publisher.exe和subscriber.exe文件,拷贝到OpenDDS-3.20\examples\DCPS\Messenger_Imr目录后,再运行perl run_test.pl发现测试成功。

SampleInfo.instance_state = NOT_ALIVE_DISPOSED_INSTANCE_STATE
>>> D:\DDS\ACE_wrappers\bin\tao_imr.EXE -ORBInitRef ImplRepoService=file://imr.ior shutdown InfoRepo
Successfully shut down server <InfoRepo>
test PASSED.

4. 名词解释

ACE is an open-source framework that provides many components and patterns for developing high-performance, distributed real-time and embedded systems. ACE provides powerful, yet efficient abstractions for sockets, demultiplexing loops, threads, synchronization primitives.

TAO (The ACE ORB) is an open-source implementation of a CORBA Object Request Broker (ORB) built using components and patterns in the ACE framework.

ACE是一个开源的函数库,一种框架。

TAO是基于ACE的对CORBA的一种实现。

CORBA(Common Object Request Broker Architecture,公共对象请求代理体系结构,通用对象请求代理体系结构)是由OMG组织制订的一种标准的面向对象应用程序体系规范。

IDL:Interface description language的缩写,指接口描述语言,是CORBA规范的一部分,是跨平台开发的基础。

RPC(Remote Procedure Call)—远程过程调用,CORBA的底层实现

OpenDDS is an open-source C++ implementation of the Object Management Group's
specification "Data Distribution Service for Real-time Systems" (DDS), as well
as some other related specifications. OpenDDS is built on the ACE abstraction layer to provide platform portability.  OpenDDS also leverages capabilities of TAO, such as its IDL compiler and as the basis of the OpenDDS DCPS Information Repository (DCPSInfoRepo).

OpenDDS: 是对OMG组织的DDS协议的C++开源实现,它建立在ACE抽象层之上来保证平台间的可移植性,OpenDDS同样依赖了TAO的一些特性。

5. OpenDDS应用开发步骤

原文链接: OPenDDS程序 的 实现+运行

基于Windows10的OpenDDS测试、https://github.com/WeiKangJian/OpenDDSapplication

  1. 新建XXX.idl文件:接口描述语言,是CORBA规范的一部分,是跨平台开发的基础,里面内容是结构体,定义了数据类型;
  2. 新建XXX.mpc文件:该文件有点像是配置文件,里面会配置不同属性对应的源文件;
  3. 新建Publisher.cpp、Subscriber.cpp、DataReaderListener.h、DataReaderListener.cpp;
  4. 通过perl脚本生成VS解决方案,shell命令是perl %ACE_ROOT%\MPC\mwc.pl -type vs2019,执行后会生成XXX.sln
  5. 编译XXX.sln,生成publisher.exesubscriber.exe
  6. 运行,先在工程目录下通过命令%DDS_ROOT%/bin/DCPSInfoRepo -ORBEndpoint iiop://localhost:12345,然后双击启动publisher.exesubscriber.exe

参考链接

猜你喜欢

转载自blog.csdn.net/wml00000/article/details/124071783
今日推荐