Skip to content

Commit 9d0ffc0

Browse files
Rebase fixes and updates
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
1 parent d21b19e commit 9d0ffc0

7 files changed

Lines changed: 43 additions & 25 deletions

File tree

ddsenabler/examples/CLIParser.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CLIParser
2929
struct example_config
3030
{
3131
uint32_t expected_types_ = 0;
32+
uint32_t expected_topics_ = 0;
3233
uint32_t expected_data_ = 0;
3334
uint32_t timeout_seconds = 30;
3435
std::string config_file_path_ = "";
@@ -44,12 +45,14 @@ class CLIParser
4445
static void print_help(
4546
uint8_t return_code)
4647
{
47-
std::cout << "Usage: ddsenabler_example <expected_types> <expected_data> <timeout> <path/to/config/file>" <<
48+
std::cout << "Usage: ddsenabler_example <expected_types> <expected_topics> <expected_data> <timeout> <path/to/config/file>" <<
4849
std::endl;
4950
std::cout << "" <<
5051
std::endl;
5152
std::cout << "expected_types: number of types to be expected" <<
5253
std::endl;
54+
std::cout << "expected_topics: number of topics to be expected" <<
55+
std::endl;
5356
std::cout << "expected_data: number of data to be expected" <<
5457
std::endl;
5558
std::cout << "timeout: time to wait before stopping the program if the data is not received" <<
@@ -74,7 +77,7 @@ class CLIParser
7477
{
7578
example_config config;
7679

77-
if (argc < 5)
80+
if (argc < 6)
7881
{
7982
std::cerr << "Missing entity argument" << std::endl;
8083
print_help(EXIT_FAILURE);
@@ -83,9 +86,10 @@ class CLIParser
8386
try
8487
{
8588
config.expected_types_ = std::stoi(argv[1]);
86-
config.expected_data_ = std::stoi(argv[2]);
87-
config.timeout_seconds = std::stoi(argv[3]);
88-
config.config_file_path_ = argv[4];
89+
config.expected_topics_ = std::stoi(argv[2]);
90+
config.expected_data_ = std::stoi(argv[3]);
91+
config.timeout_seconds = std::stoi(argv[4]);
92+
config.config_file_path_ = argv[5];
8993
}
9094
catch (const std::exception& e)
9195
{

ddsenabler/examples/main.cpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@
2727
#include "CLIParser.hpp"
2828

2929
uint32_t received_types_ = 0;
30+
uint32_t received_topics_ = 0;
3031
uint32_t received_data_ = 0;
3132
std::mutex type_received_mutex_;
33+
std::mutex topic_received_mutex_;
3234
std::mutex data_received_mutex_;
3335
bool stop_app_ = false;
3436

3537
// Static type callback
3638
static void test_type_callback(
3739
const char* typeName,
38-
const char* topicName,
39-
const char* serializedType)
40+
const char* serializedType,
41+
const unsigned char* serializedTypeInternal,
42+
uint32_t serializedTypeInternalSize,
43+
const char* dataPlaceholder)
4044
{
4145
std::lock_guard<std::mutex> lock(type_received_mutex_);
4246

@@ -45,17 +49,29 @@ static void test_type_callback(
4549
received_types_ << std::endl;
4650
}
4751

52+
// Static topic callback
53+
static void test_topic_callback(
54+
const char* topicName,
55+
const char* typeName,
56+
const char* serializedQos)
57+
{
58+
std::lock_guard<std::mutex> lock(topic_received_mutex_);
59+
60+
received_topics_++;
61+
std::cout << "Topic callback received: " << topicName << " of type " << typeName << ", Total topics: " <<
62+
received_topics_ << std::endl;
63+
}
64+
4865
// Static data callback
4966
static void test_data_callback(
50-
const char* typeName,
5167
const char* topicName,
5268
const char* json,
5369
int64_t publishTime)
5470
{
5571
std::lock_guard<std::mutex> lock(data_received_mutex_);
5672

5773
received_data_++;
58-
std::cout << "Data callback received: " << typeName << ", Total data: " <<
74+
std::cout << "Data callback received: " << topicName << ", Total data: " <<
5975
received_data_ << std::endl;
6076
}
6177

@@ -66,6 +82,13 @@ int get_received_types()
6682
return received_types_;
6783
}
6884

85+
int get_received_topics()
86+
{
87+
std::lock_guard<std::mutex> lock(topic_received_mutex_);
88+
89+
return received_topics_;
90+
}
91+
6992
int get_received_data()
7093
{
7194
std::lock_guard<std::mutex> lock(data_received_mutex_);
@@ -84,10 +107,12 @@ int main(
84107
int argc,
85108
char** argv)
86109
{
110+
using namespace eprosima::ddsenabler;
111+
87112
CLIParser::example_config config = CLIParser::parse_cli_options(argc, argv);
88113

89114
std::unique_ptr<DDSEnabler> enabler;
90-
create_dds_enabler(config.config_file_path_.c_str(), test_data_callback, test_type_callback, nullptr, enabler);
115+
create_dds_enabler(config.config_file_path_.c_str(), test_data_callback, test_type_callback, test_topic_callback, nullptr, nullptr, nullptr, enabler);
91116

92117
signal(SIGINT, signal_handler);
93118
signal(SIGTERM, signal_handler);
@@ -106,6 +131,7 @@ int main(
106131
return EXIT_SUCCESS;
107132
}
108133
else if (get_received_types() >= config.expected_types_ &&
134+
get_received_topics() >= config.expected_topics_ &&
109135
get_received_data() >= config.expected_data_)
110136
{
111137
std::cout << "Received enough data, stopping..." << std::endl;

ddsenabler/test/ddsEnablerTests/ReloadConfig.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ TEST(ReloadConfig, yaml)
206206

207207
// Create DDS Enabler
208208
std::unique_ptr<DDSEnabler> enabler;
209-
bool result = create_dds_enabler(configfile, test_data_callback, test_type_callback, test_topic_notification_callback, test_type_request_callback, test_topic_request_callback, test_log_callback, enabler);
210-
ASSERT_TRUE(result);
209+
ASSERT_TRUE(create_dds_enabler(configfile, test_data_callback, test_type_callback, test_topic_notification_callback, test_type_request_callback, test_topic_request_callback, test_log_callback, enabler));
211210

212211
// Create DDSEnablerAccessor to access protected configuration
213212
auto enabler_accessor = static_cast<DDSEnablerAccessor*>(enabler.get());

ddsenabler_participants/include/ddsenabler_participants/CBWriter.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ class CBWriter
4545
void set_data_callback(
4646
DdsNotification callback)
4747
{
48-
std::lock_guard<std::mutex> lock(mutex_);
4948
data_callback_ = callback;
5049
}
5150

5251
DDSENABLER_PARTICIPANTS_DllAPI
5352
void set_type_callback(
5453
DdsTypeNotification callback)
5554
{
56-
std::lock_guard<std::mutex> lock(mutex_);
5755
type_callback_ = callback;
5856
}
5957

ddsenabler_participants/src/cpp/CBHandler.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,9 @@
1616
* @file CBHandler.cpp
1717
*/
1818

19-
<<<<<<< HEAD
20-
#include <algorithm>
21-
#include <cstdio>
22-
#include <filesystem>
23-
#include <vector>
24-
25-
#include <fastdds/dds/topic/TypeSupport.hpp>
26-
=======
2719
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
2820
#include <fastdds/dds/xtypes/dynamic_types/DynamicData.hpp>
2921
#include <fastdds/dds/xtypes/dynamic_types/DynamicPubSubType.hpp>
30-
>>>>>>> e025823 (DDS data publication implementation)
3122
#include <fastdds/dds/xtypes/dynamic_types/DynamicType.hpp>
3223
#include <fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilderFactory.hpp>
3324
#include <fastdds/dds/xtypes/utils.hpp>

ddsenabler_test/compose/test_cases/topics_json/compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- std_net
1717
volumes:
1818
- ./config.json:/config/config.json
19-
command: ./build/ddsenabler/examples/ddsenabler_example 1 1 10 /config/config.json
19+
command: ./build/ddsenabler/examples/ddsenabler_example 1 1 1 10 /config/config.json
2020

2121
talker:
2222
image: ${DDSENABLER_COMPOSE_TEST_ROS2_DOCKER_IMAGE}

ddsenabler_test/compose/test_cases/topics_yaml/compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- std_net
1717
volumes:
1818
- ./config.yml:/config/config.yml
19-
command: ./build/ddsenabler/examples/ddsenabler_example 1 1 10 /config/config.yml
19+
command: ./build/ddsenabler/examples/ddsenabler_example 1 1 1 10 /config/config.yml
2020

2121
talker:
2222
image: ${DDSENABLER_COMPOSE_TEST_ROS2_DOCKER_IMAGE}

0 commit comments

Comments
 (0)