Skip to content

Commit

Permalink
Export RTPS Time_t to Python (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
richiware authored Oct 20, 2023
1 parent d851a4c commit 76c5655
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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

0 comments on commit 76c5655

Please sign in to comment.