資源簡介
使用了DDS標準來進行通信,在VS08中使用QT編寫了界面程序,支持圖形顯示,是學習DDS的典型例子
代碼片段和文件信息
//?-*-?C++?-*-
//
//?$Id:?DataReaderListener.cpp?2014-08-28?20:19:02?lyb?$
#include?“DataReaderListener.h“
#include?“ShapeDemoTypeSupportC.h“
#include?“ShapeDemoTypeSupportImpl.h“
#include?
#include?
using?namespace?ShapeDemo;
//?Implementation?skeleton?constructor
DataReaderListenerImpl::DataReaderListenerImpl()
{
shape_.xpos?=?shape_.ypos?=?0;
delay_??????=?0;
}
//?Implementation?skeleton?destructor
DataReaderListenerImpl::~DataReaderListenerImpl?()
{
}
void?DataReaderListenerImpl::on_data_available(DDS::DataReader_ptr?reader)
throw?(CORBA::SystemException)
{
try?{
unsigned?long?long?CurTime?=?GetCurTime();
ShapeDataReader_var?message_dr?=?ShapeDataReader::_narrow(reader);
if?(CORBA::is_nil?(message_dr.in?()))?{
//cerr?<“read:?_narrow?failed.“?< return?;
}
DDS::SampleInfo?si?;
DDS::ReturnCode_t?status?=?message_dr->take_next_sample(shape_?si);
delay_?=?CurTime?-?shape_.timestamp;
if?(status?==?DDS::RETCODE_OK)?{
}?else?if?(status?==?DDS::RETCODE_NO_DATA)?{
//cerr?<“ERROR:?reader?received?DDS::RETCODE_NO_DATA!“?< }?else?{
//cerr?<“ERROR:?read?Shape:?Error:?“?<?status?< }
}?catch?(...)?{
//cerr?<“Exception?caught?in?read:“?< return?;
}
}
void?DataReaderListenerImpl::on_requested_deadline_missed?(
DDS::DataReader_ptr
const?DDS::RequestedDeadlineMissedStatus?&)
throw?(CORBA::SystemException)
{
//cerr?<“DataReaderListenerImpl::on_requested_deadline_missed“?<}
void?DataReaderListenerImpl::on_requested_incompatible_qos?(
DDS::DataReader_ptr
const?DDS::RequestedIncompatibleQosStatus?&)
throw?(CORBA::SystemException)
{
//cerr?<“DataReaderListenerImpl::on_requested_incompatible_qos“?<}
void?DataReaderListenerImpl::on_liveliness_changed?(
DDS::DataReader_ptr
const?DDS::LivelinessChangedStatus?&)
throw?(CORBA::SystemException)
{
//cerr?<“DataReaderListenerImpl::on_liveliness_changed“?<}
void?DataReaderListenerImpl::on_subscription_matched?(
DDS::DataReader_ptr
const?DDS::SubscriptionMatchedStatus?&)
throw?(CORBA::SystemException)
{
//cerr?<“DataReaderListenerImpl::on_subscription_matched“?<}
void?DataReaderListenerImpl::on_sample_rejected(
DDS::DataReader_ptr
const?DDS::SampleRejectedStatus&)
throw?(CORBA::SystemException)
{
//cerr?<“DataReaderListenerImpl::on_sample_rejected“?<}
void?DataReaderListenerImpl::on_sample_lost(
DDS::DataReader_ptr
const?DDS::SampleLostStatus&)
throw?(CORBA::SystemException)
{
//cerr?<“DataReaderListenerImpl::on_sample_lost“?<}
void?DataReaderListenerImpl::on_subscription_disconnected?(
DDS::DataReader_ptr
const?::OpenDDS::DCPS::SubscriptionDisconnectedStatus?&)
throw?(CORBA::SystemException)
{
//cerr?<“DataReaderListenerImpl::on_subscription_disconnected“?<}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4051??2014-10-05?12:59??ShapeDemo\DataReaderListener.cpp
?????文件???????2678??2014-10-05?12:56??ShapeDemo\DataReaderListener.h
?????文件???????5825??2014-09-09?16:47??ShapeDemo\MainFrm.cpp
?????文件???????1103??2014-09-07?12:20??ShapeDemo\MainFrm.h
?????文件?????????23??2014-06-27?15:24??ShapeDemo\mpc.bat
?????文件????????341??2014-10-12?23:05??ShapeDemo\Release\dds_rtps_dis_conf.ini
?????文件??????67777??2007-11-28?16:21??ShapeDemo\res\ShapeDemo.ico
?????文件????????365??2014-02-17?13:50??ShapeDemo\res\ShapeDemo.rc2
?????文件???????1724??2014-09-07?20:00??ShapeDemo\resource.h
?????文件?????112404??2014-09-09?16:54??ShapeDemo\ShapeDemo.aps
?????文件???????3830??2014-09-07?19:49??ShapeDemo\ShapeDemo.cpp
?????文件????????641??2014-02-17?13:50??ShapeDemo\ShapeDemo.h
?????文件????????272??2014-09-15?22:37??ShapeDemo\ShapeDemo.idl
?????文件????????304??2014-02-17?14:30??ShapeDemo\ShapeDemo.mpc
?????文件??????11455??2014-09-09?16:54??ShapeDemo\ShapeDemo.rc
?????文件???????2011??2014-10-12?23:14??ShapeDemo\ShapeDemo.sln
?????文件???????6428??2014-06-27?19:25??ShapeDemo\ShapeDemo.vcproj
?????文件???????1075??2014-09-09?16:57??ShapeDemo\ShapeDemoDoc.cpp
?????文件????????566??2014-09-09?16:58??ShapeDemo\ShapeDemoDoc.h
?????文件??????15112??2015-04-15?21:46??ShapeDemo\ShapeDemoView.cpp
?????文件???????2837??2014-10-17?00:05??ShapeDemo\ShapeDemoView.h
?????文件???????2195??2014-02-17?13:33??ShapeDemo\ShapeDemo_export.h
?????文件??????20609??2014-09-07?00:30??ShapeDemo\ShapeDemo_Idl.vcproj
?????文件????????142??2014-02-17?13:50??ShapeDemo\stdafx.cpp
?????文件???????1809??2014-06-27?15:48??ShapeDemo\stdafx.h
?????文件???????1030??2014-02-17?13:50??ShapeDemo\targetver.h
?????目錄??????????0??2014-11-18?17:47??ShapeDemo\Release
?????目錄??????????0??2014-10-20?20:20??ShapeDemo\res
?????目錄??????????0??2014-11-18?17:47??ShapeDemo
-----------?---------??----------?-----??----
............此處省略2個文件信息
評論
共有 條評論