-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataReaderListenerImpl_VehData.cpp
161 lines (95 loc) · 3.03 KB
/
DataReaderListenerImpl_VehData.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
*
*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/
#include <ace/Log_Msg.h>
#include <ace/OS_NS_stdlib.h>
#include "DataReaderListenerImpl_VehData.h"
#include "MriTypeSupportC.h"
#include "MriTypeSupportImpl.h"
#include <iostream> //cout, endl
//#include <boost/lockfree/queue.hpp>
#include "QueueTs.h"
using std::cerr;
using std::cout;
using std::endl;
using std::string;
//extern boost::lockfree::queue<Mri::VehData> vehdata_queue;
extern QueueTs<Mri::VehData> vehdata_queue;
void
DataReaderListenerImpl_VehData::on_data_available(DDS::DataReader_ptr reader)
{
Mri::VehDataDataReader_var reader_i =
Mri::VehDataDataReader::_narrow(reader);
if (!reader_i) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: on_data_available() -")
ACE_TEXT(" _narrow failed!\n")));
ACE_OS::exit(-1);
}
Mri::VehData veh_message;
DDS::SampleInfo info;
DDS::ReturnCode_t error = reader_i->take_next_sample(veh_message, info);
if (error == DDS::RETCODE_OK) {
//cout << "SampleInfo.sample_rank = " << info.sample_rank << endl;
//cout << "SampleInfo.instance_state = " << info.instance_state << endl;
if (info.valid_data) {
//buffor.push_back(z);
//vehdata_queue.push(veh_message);
vehdata_queue.push(veh_message);
//cout << csvConvertVehDataToString(veh_message);
/*<< " position_x = " << veh_message.position_x << endl
<< " timestamp =" << veh_message.timestamp << endl;*/
//<< " str1 = " << aux_message.str1 << std::endl
//<< " str2 = " << aux_message.str2 << std::endl
//<< " tag = " << aux_message.tag << std::endl;
}
}
else {
ACE_ERROR((LM_ERROR,
ACE_TEXT("ERROR: %N:%l: on_data_available() -")
ACE_TEXT(" take_next_sample failed!\n")));
}
}
void
DataReaderListenerImpl_VehData::on_requested_deadline_missed(
DDS::DataReader_ptr /*reader*/,
const DDS::RequestedDeadlineMissedStatus& /*status*/)
{
}
void
DataReaderListenerImpl_VehData::on_requested_incompatible_qos(
DDS::DataReader_ptr /*reader*/,
const DDS::RequestedIncompatibleQosStatus& /*status*/)
{
}
void
DataReaderListenerImpl_VehData::on_sample_rejected(
DDS::DataReader_ptr /*reader*/,
const DDS::SampleRejectedStatus& /*status*/)
{
}
void
DataReaderListenerImpl_VehData::on_liveliness_changed(
DDS::DataReader_ptr /*reader*/,
const DDS::LivelinessChangedStatus& /*status*/)
{
//cout << "END OF RECORDING" << endl;
}
void
DataReaderListenerImpl_VehData::on_subscription_matched(
DDS::DataReader_ptr /*reader*/,
const DDS::SubscriptionMatchedStatus& /*status*/)
{
cout << "****************** VehData **************************" << endl;
cout << "****************** **************************" << endl;
cout << "****************** **************************" << endl << endl;
}
void
DataReaderListenerImpl_VehData::on_sample_lost(
DDS::DataReader_ptr /*reader*/,
const DDS::SampleLostStatus& /*status*/)
{
}