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

[21768] DDS data publication implementation #2

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removed old file. Applied suggestions.
Signed-off-by: adriancampo <adriancampo@eprosima.com>
adriancampo committed Oct 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6f4ce63c0438163521d1dbfbc8f5485bd4058eb5
32 changes: 20 additions & 12 deletions ddsenabler/src/cpp/dds_enabler_runner.cpp
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ std::unique_ptr<eprosima::utils::event::FileWatcherHandler> create_filewatcher(
[&enabler, &file_path]
(std::string file_name)
{
logInfo(DDSENABLER_EXECUTION,
EPROSIMA_LOG_INFO(DDSENABLER_EXECUTION,
"FileWatcher notified changes in file " << file_path << ". Reloading configuration");
try
{
@@ -55,7 +55,7 @@ std::unique_ptr<eprosima::utils::event::FileWatcherHandler> create_filewatcher(
}
catch (const std::exception& e)
{
logWarning(DDSENABLER_EXECUTION,
EPROSIMA_LOG_WARNING(DDSENABLER_EXECUTION,
"Error reloading configuration file " << file_path << " with error: " << e.what());
}
};
@@ -114,23 +114,21 @@ int init_dds_enabler(
eprosima::utils::Log::RegisterConsumer(
std::make_unique<eprosima::utils::StdLogConsumer>(&log_configuration));
}

eprosima::utils::Log::SetVerbosity(log_configuration.verbosity);
}

// DDS Enabler Initialization
logInfo(DDSENABLER_EXECUTION,
EPROSIMA_LOG_INFO(DDSENABLER_EXECUTION,
"Starting DDS Enabler execution.");

// Create a multiple event handler that handles all events that make the enabler stop
auto close_handler = std::make_shared<eprosima::utils::event::MultipleEventHandler>();

// Start recording right away
// Create DDSEnabler and set the context broker callbacks
auto enabler = std::make_unique<DDSEnabler>(configuration, close_handler);
enabler.get()->set_data_callback(data_callback);
enabler.get()->set_type_callback(type_callback);

logInfo(DDSENABLER_EXECUTION,
EPROSIMA_LOG_INFO(DDSENABLER_EXECUTION,
"DDS Enabler running.");

// Create File Watcher Handler
@@ -140,27 +138,37 @@ int init_dds_enabler(
// Wait until signal arrives
close_handler->wait_for_event();

logInfo(DDSENABLER_EXECUTION,
EPROSIMA_LOG_INFO(DDSENABLER_EXECUTION,
"Stopping DDS Enabler.");

logInfo(DDSENABLER_EXECUTION,
EPROSIMA_LOG_INFO(DDSENABLER_EXECUTION,
"DDS Enabler stopped correctly.");
}
catch (const eprosima::utils::ConfigurationException& e)
{
logError(DDSENABLER_ERROR,
EPROSIMA_LOG_ERROR(DDSENABLER_EXECUTION,
"Error Loading DDS Enabler Configuration from file " << dds_enabler_config_file <<
". Error message:\n " << e.what());
// Force print every log before closing
eprosima::utils::Log::Flush();

// Delete the consumers before closing
eprosima::utils::Log::ClearConsumers();
return -1;
}
catch (const eprosima::utils::InitializationException& e)
{
logError(DDSENABLER_ERROR,
EPROSIMA_LOG_ERROR(DDSENABLER_EXECUTION,
"Error Initializing DDS Enabler. Error message:\n " << e.what());
// Force print every log before closing
eprosima::utils::Log::Flush();

// Delete the consumers before closing
eprosima::utils::Log::ClearConsumers();
return -1;
}

logInfo(DDSENABLER_EXECUTION,
EPROSIMA_LOG_INFO(DDSENABLER_EXECUTION,
"Finishing DDS Enabler execution correctly.");

// Force print every log before closing
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ class DDSEnablerLogConsumer : public utils::BaseLogConsumer

private:

DdsLogFunc log_callback_;
DdsLogFunc log_callback_;
};

} /* namespace participants */

This file was deleted.

12 changes: 6 additions & 6 deletions ddsenabler_participants/src/cpp/CBHandler.cpp
Original file line number Diff line number Diff line change
@@ -47,15 +47,15 @@ CBHandler::CBHandler(
: configuration_(config)
, payload_pool_(payload_pool)
{
logInfo(DDSENABLER_CB_HANDLER,
EPROSIMA_LOG_INFO(DDSENABLER_CB_HANDLER,
"Creating CB handler instance.");

cb_writer_ = std::make_unique<CBWriter>();
}

CBHandler::~CBHandler()
{
logInfo(DDSENABLER_CB_HANDLER,
EPROSIMA_LOG_INFO(DDSENABLER_CB_HANDLER,
"Destroying CB handler.");
}

@@ -77,7 +77,7 @@ void CBHandler::add_schema(
}

// Add to schemas map
logInfo(DDSENABLER_CB_HANDLER,
EPROSIMA_LOG_INFO(DDSENABLER_CB_HANDLER,
"Adding schema with name " << dyn_type->get_name().to_string() << ".");

schemas_[type_id] = dyn_type;
@@ -89,7 +89,7 @@ void CBHandler::add_data(
{
std::unique_lock<std::mutex> lock(mtx_);

logInfo(DDSENABLER_CB_HANDLER,
EPROSIMA_LOG_INFO(DDSENABLER_CB_HANDLER,
"Adding data in topic: " << topic << ".");

CBMessage msg;
@@ -133,7 +133,7 @@ void CBHandler::add_data(
else
{
// NO TYPE_IDENTIFIERS
logWarning(DDSENABLER_CB_HANDLER,
EPROSIMA_LOG_WARNING(DDSENABLER_CB_HANDLER,
"Received Schema for type " << topic.type_name << " with no TypeIdentifier.");
return;
}
@@ -147,7 +147,7 @@ void CBHandler::add_data(
}
else
{
logWarning(DDSENABLER_CB_HANDLER,
EPROSIMA_LOG_WARNING(DDSENABLER_CB_HANDLER,
"Schema for type " << topic.type_name << " not available.");
}

10 changes: 5 additions & 5 deletions ddsenabler_participants/src/cpp/CBWriter.cpp
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ void CBWriter::write_data(

write_schema(msg, dyn_type);

logInfo(DDSENABLER_CB_WRITER,
EPROSIMA_LOG_INFO(DDSENABLER_CB_WRITER,
"Writing message from topic: " << msg.topic.topic_name() << ".");

// Get the data as JSON
@@ -48,7 +48,7 @@ void CBWriter::write_data(
if (fastdds::dds::RETCODE_OK !=
fastdds::dds::json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, ss_dyn_data))
{
logError(DDSENABLER_CB_WRITER,
EPROSIMA_LOG_ERROR(DDSENABLER_CB_WRITER,
"Not able to serialize data of topic " << msg.topic.topic_name() << " into JSON format.");
return;
}
@@ -91,14 +91,14 @@ void CBWriter::write_schema(
if (it == stored_schemas_.end())
{
//Schema has not been registered
logInfo(DDSENABLER_CB_WRITER,
EPROSIMA_LOG_INFO(DDSENABLER_CB_WRITER,
"Writing schema: " << type_name << " on topic: " << topic_name << ".");

std::stringstream ss_idl;
auto ret = fastdds::dds::idl_serialize(dyn_type, ss_idl);
if (ret != fastdds::dds::RETCODE_OK)
{
logError(DDSENABLER_CB_WRITER,
EPROSIMA_LOG_ERROR(DDSENABLER_CB_WRITER,
"Failed to serialize DynamicType to idl for type with name: " << type_name);
return;
}
@@ -116,7 +116,7 @@ void CBWriter::write_schema(
else
{
//Schema has been registered
logInfo(DDSENABLER_CB_WRITER,
EPROSIMA_LOG_INFO(DDSENABLER_CB_WRITER,
"Schema: " + type_name + " already registered for topic: " + topic_name + ".");
}
}
2 changes: 1 addition & 1 deletion ddsenabler_yaml/src/cpp/EnablerConfiguration.cpp
Original file line number Diff line number Diff line change
@@ -262,7 +262,7 @@ void EnablerConfiguration::load_ddsenabler_configuration_from_file_(
}
else
{
logWarning(DDSENABLER_YAML,
EPROSIMA_LOG_WARNING(DDSENABLER_YAML,
"No configuration file specified, using default values.");
}
EnablerConfiguration::load_ddsenabler_configuration_(yml);