Skip to content

Commit 14cc634

Browse files
Adding logic to support original writer forwarding (#163)
* Adding logic to support original writer forwarding Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> * Uncrustify Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> * Applying review Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> * Refs 23573, adapting changes to new original writer info struct Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> --------- Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com>
1 parent 44d4f81 commit 14cc634

5 files changed

Lines changed: 42 additions & 2 deletions

File tree

ddspipe_core/include/ddspipe_core/types/data/RtpsPayloadData.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <fastdds/rtps/common/SerializedPayload.hpp>
1919
#include <fastdds/rtps/common/SequenceNumber.hpp>
20+
#include <fastdds/rtps/common/OriginalWriterInfo.hpp>
2021

2122
#include <ddspipe_core/library/library_dll.h>
2223
#include <ddspipe_core/types/dds/Payload.hpp>
@@ -85,6 +86,9 @@ struct RtpsPayloadData : public core::IRoutingData
8586

8687
//! Id of the participant from which the Reader has received the data.
8788
core::types::ParticipantId participant_receiver{};
89+
90+
//! Guid of the original entity that transmitted the data for the first time
91+
eprosima::fastdds::rtps::OriginalWriterInfo original_writer_info{};
8892
};
8993

9094
/**

ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ void CommonReader::fill_received_data_(
302302
// Store the new data that has arrived in the Track data
303303
// Get the writer guid
304304
data_to_fill.source_guid = detail::guid_from_instance_handle(info.publication_handle);
305+
306+
auto original_source_guid = info.original_writer_info.original_writer_guid();
307+
if (original_source_guid == fastdds::rtps::GUID_t::unknown())
308+
{
309+
// If the original source guid is unknown, this is the first time a router receives this data
310+
// and the current source is the original
311+
data_to_fill.original_writer_info.original_writer_guid(data_to_fill.source_guid);
312+
}
313+
else
314+
{
315+
// If the original source guid is known, set it
316+
data_to_fill.original_writer_info = info.original_writer_info;
317+
}
318+
305319
// Get source timestamp
306320
data_to_fill.source_timestamp = info.source_timestamp;
307321
// Get Participant receiver

ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ void CommonReader::internal_entities_creation_(
131131
" for Simple RTPSReader in Participant " << participant_id_);
132132
}
133133

134-
EPROSIMA_LOG_INFO(DDSPIPE_RTPS_READER, "New CommonReader created in Participant " << participant_id_ << " for topic " <<
134+
EPROSIMA_LOG_INFO(DDSPIPE_RTPS_READER,
135+
"New CommonReader created in Participant " << participant_id_ << " for topic " <<
135136
topic_ << " with guid " << rtps_reader_->getGuid());
136137
}
137138

@@ -205,6 +206,20 @@ void CommonReader::fill_received_data_(
205206
// Store the new data that has arrived in the Track data
206207
// Get the writer guid
207208
data_to_fill.source_guid = received_change.writerGUID;
209+
210+
auto original_source_guid = received_change.write_params.original_writer_info().original_writer_guid();
211+
if (original_source_guid == fastdds::rtps::GUID_t::unknown())
212+
{
213+
// If the original source guid is unknown, this is the first time a router receives this data
214+
// and the current source is the original
215+
data_to_fill.original_writer_info.original_writer_guid(data_to_fill.source_guid);
216+
}
217+
else
218+
{
219+
// If the original source guid is known, set it
220+
data_to_fill.original_writer_info = received_change.write_params.original_writer_info();
221+
}
222+
208223
// Get source timestamp
209224
data_to_fill.source_timestamp = received_change.sourceTimestamp;
210225
// Get Participant receiver
@@ -454,7 +469,8 @@ void CommonReader::on_reader_matched(
454469
if (info.status == fastdds::rtps::MatchingStatus::MATCHED_MATCHING)
455470
{
456471
EPROSIMA_LOG_INFO(DDSPIPE_RTPS_COMMONREADER_LISTENER,
457-
"Reader " << *this << " in topic " << topic_.serialize() << " matched with a new Writer with guid " <<
472+
"Reader " << *this << " in topic " << topic_.serialize() <<
473+
" matched with a new Writer with guid " <<
458474
info.remoteEndpointGuid);
459475
}
460476
else

ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ utils::ReturnCode CommonWriter::fill_to_send_data_(
215215
// Set source time stamp to be the original one
216216
to_send_params.source_timestamp(data.source_timestamp);
217217

218+
// Set original writer guid
219+
to_send_params.original_writer_info(data.original_writer_info);
220+
218221
return utils::ReturnCode::RETCODE_OK;
219222
}
220223

ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ utils::ReturnCode CommonWriter::fill_to_send_data_(
251251
// Set source time stamp to be the original one
252252
to_send_params.source_timestamp(data.source_timestamp);
253253

254+
// Set original writer guid
255+
to_send_params.original_writer_info(data.original_writer_info);
256+
254257
return utils::ReturnCode::RETCODE_OK;
255258
}
256259

0 commit comments

Comments
 (0)