OpenDDS Java开发(2)——基于Windows10的OpenDDS测试

话接上文,由于Perl的问题,我并没有通过测试程序run_test.pl测试成功。

我在Git上找了个测试程序,很丰富,点赞,非常感谢作者。https://github.com/WeiKangJian/OpenDDSapplication

我没有直接编译运行他的代码,而是试着自己摸索编译。

将他的外卖程序简单修改一下Supermarket.idl:

module Supermarket {
	#pragma DCPS_DATA_TYPE "Supermarket::UpdateInf"
	#pragma DCPS_DATA_KEY "Supermarket::UpdateInf UpdateInfID"
	struct UpdateInf {
		long UpdateInfID;
		string UpdateInfTopic;
		string UpdateInfMessage;
		string PublisherName;
		string MTime;
		long ClockTime;
	};
	
	#pragma DCPS_DATA_TYPE "Supermarket::DefaultInf"
	#pragma DCPS_DATA_KEY "Supermarket::DefaultInf DefaultInfID"
	struct DefaultInf {
		long DefaultInfID;
		string DefaultInfTopic;
		string DefaultInfMessage;
		string PublisherName;
		string MTime;
		long ClockTime;
	};

};

Supermarket.mpc:

project(*idl): dcps {

  includes      += $(TAO_ROOT)/orbsvcs

   

 // This project ensures the common components get built first.
    TypeSupport_Files {
        Supermarket.idl
    }
    custom_only = 1
}
project(*Publisher) : dcpsexe_with_tcp {
  exename   = publisher
  after    += *idl
  TypeSupport_Files {
    Supermarket.idl
  }
  Source_Files {
    Publisher.cpp
  }
}
project(*Subscriber) : dcpsexe_with_tcp {
 exename   = subscriber
 after    += *idl
 TypeSupport_Files {
   Supermarket.idl
 }
 Source_Files {
   Subscriber.cpp
   DataReaderListenerImpl.cpp
 }
}

然后在VS的开发人员命令提示符执行:

tao_idl Supermarket.idl

opendds_idl Supermarket.idl

generate_export_file.pl Supermarket > Supermarket_Export.h

中间出现一些警告,直接忽略即可。

将Publisher.cpp、Subscriber.cpp、DataReaderListenerImpl.cpp、DataReaderListenerImpl.h复制过来,将其中的“S01_”都去掉。然后执行

mwc.pl -type vs2017

可以看到此时该目录下生成了一个*.sln文件,这个文件名和当前文件夹名相同,比如我在D:\env\opendds\workspace\market目录下,这个文件就是market.sln。

双击market.sln用vs2017打开。

编译成功后生成了publisher.exe和subscriber.exe文件,在CMD命令行,当前目录下,执行:

%DDS_ROOT%/bin/DCPSInfoRepo -ORBEndpoint iiop://localhost:12345

分别双击subscriber.exe和publisher.exe能够收发消息即为成功。

 

再次感谢这位Git作者:https://github.com/WeiKangJian/OpenDDSapplication

 

 

 

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值