Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export RTPS Time_t to Python [19738] #68

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fastdds_python/src/swig/fastdds/rtps/common/Time_t.i
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
// limitations under the License.

%{
#include "fastdds/rtps/common/Time_t.h"
#include <fastdds/rtps/common/Time_t.h>
%}

// There are two definitions of Time_t in different namespaces
// As SWIG flattens the namespaces, we cannot have two classes with the same name
// We remove the one that is not used in the user API
// We also remove all the related operators
%ignore eprosima::fastrtps::rtps::Time_t;
%rename(RTPSTime_t) eprosima::fastrtps::rtps::Time_t;
%ignore eprosima::fastrtps::rtps::operator==(const Time_t&, const Time_t&);
%ignore eprosima::fastrtps::rtps::operator!=(const Time_t&, const Time_t&);
%ignore eprosima::fastrtps::rtps::operator<(const Time_t&, const Time_t&);
Expand Down Expand Up @@ -48,7 +48,7 @@
%ignore eprosima::fastrtps::operator+(const Time_t&, const Time_t&);
%ignore eprosima::fastrtps::operator-(const Time_t&, const Time_t&);

%include "fastdds/rtps/common/Time_t.h"
%include <fastdds/rtps/common/Time_t.h>

// Declare the comparison operators as internal to the class
%extend eprosima::fastrtps::Time_t {
Expand Down
16 changes: 16 additions & 0 deletions fastdds_python/test/api/test_datareader.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ def test_read(transient_datareader_qos, datareader,
assert(1 == len(data_seq))
assert(1 == len(info_seq))
assert(info_seq[0].valid_data is True)
assert(0 < info_seq[0].source_timestamp.to_ns())
assert(0 < info_seq[0].reception_timestamp.to_ns())
assert(sample.int16_field() == data_seq[0].int16_field())
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.return_loan(data_seq, info_seq))
Expand Down Expand Up @@ -575,6 +577,8 @@ def test_read_instance(transient_datareader_qos, test_keyed_type,
assert(1 == len(data_seq))
assert(1 == len(info_seq))
assert(info_seq[0].valid_data is True)
assert(0 < info_seq[0].source_timestamp.to_ns())
assert(0 < info_seq[0].reception_timestamp.to_ns())
assert(sample.id() == data_seq[0].id())
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.return_loan(data_seq, info_seq))
Expand Down Expand Up @@ -612,6 +616,8 @@ def test_read_next_instance(transient_datareader_qos, test_keyed_type,
assert(1 == len(data_seq))
assert(1 == len(info_seq))
assert(info_seq[0].valid_data is True)
assert(0 < info_seq[0].source_timestamp.to_ns())
assert(0 < info_seq[0].reception_timestamp.to_ns())
assert(sample.id() == data_seq[0].id())
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.return_loan(data_seq, info_seq))
Expand All @@ -638,6 +644,8 @@ def test_read_next_sample(transient_datareader_qos, datareader,
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.read_next_sample(data, info))
assert(info.valid_data)
assert(0 < info.source_timestamp.to_ns())
assert(0 < info.reception_timestamp.to_ns())
assert(sample.int16_field() == data.int16_field())


Expand Down Expand Up @@ -671,6 +679,8 @@ def test_take(transient_datareader_qos, datareader,
assert(1 == len(data_seq))
assert(1 == len(info_seq))
assert(info_seq[0].valid_data is True)
assert(0 < info_seq[0].source_timestamp.to_ns())
assert(0 < info_seq[0].reception_timestamp.to_ns())
assert(sample.int16_field() == data_seq[0].int16_field())
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.return_loan(data_seq, info_seq))
Expand Down Expand Up @@ -709,6 +719,8 @@ def test_take_instance(transient_datareader_qos, test_keyed_type,
assert(1 == len(data_seq))
assert(1 == len(info_seq))
assert(info_seq[0].valid_data is True)
assert(0 < info_seq[0].source_timestamp.to_ns())
assert(0 < info_seq[0].reception_timestamp.to_ns())
assert(sample.id() == data_seq[0].id())
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.return_loan(data_seq, info_seq))
Expand Down Expand Up @@ -746,6 +758,8 @@ def test_take_next_instance(transient_datareader_qos, test_keyed_type,
assert(1 == len(data_seq))
assert(1 == len(info_seq))
assert(info_seq[0].valid_data is True)
assert(0 < info_seq[0].source_timestamp.to_ns())
assert(0 < info_seq[0].reception_timestamp.to_ns())
assert(sample.id() == data_seq[0].id())
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.return_loan(data_seq, info_seq))
Expand All @@ -772,6 +786,8 @@ def test_take_next_sample(transient_datareader_qos, datareader,
assert(fastdds.ReturnCode_t.RETCODE_OK ==
datareader.take_next_sample(data, info))
assert(info.valid_data)
assert(0 < info.source_timestamp.to_ns())
assert(0 < info.reception_timestamp.to_ns())
assert(sample.int16_field() == data.int16_field())


Expand Down
Loading