Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ddsenabler/test/resources/dds-types-test"]
path = ddsenabler/test/resources/dds-types-test
url = https://github.com/eProsima/dds-types-test.git
48 changes: 48 additions & 0 deletions ddsenabler/DDS_ENABLER_CONFIGURATION.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"dds": {
"ddsmodule": {
"dds": {
"domain": 0,
"allowlist": [
{
"name": "*"
}
],
"blocklist": [
{
"name": "add_blocked_topics_list_here"
}
]
},
"topics": {
"name": "*",
"qos": {
"durability": "TRANSIENT_LOCAL",
"history-depth": 10
}
},
"ddsenabler": null,
"specs": {
"threads": 12,
"logging": {
"stdout": false,
"verbosity": "info"
}
}
},
"ngsild": {
"topics": {
"P1": {
"entityType": "Camera",
"entityId": "urn:ngsi-ld:camera:cam1",
"attribute": "shutterSpeed"
},
"P2": {
"entityType": "Arm",
"entityId": "urn:ngsi-ld:arm:arm1",
"attribute": "armReach"
}
}
}
}
}
42 changes: 32 additions & 10 deletions ddsenabler/include/ddsenabler/DDSEnabler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#pragma once

#include <memory>
#include <set>

#include <cpp_utils/event/MultipleEventHandler.hpp>
#include <cpp_utils/ReturnCode.hpp>
Expand All @@ -32,11 +31,11 @@
#include <ddspipe_core/efficiency/payload/FastPayloadPool.hpp>
#include <ddspipe_core/types/topic/dds/DistributedTopic.hpp>

#include <ddspipe_participants/participant/dynamic_types/DynTypesParticipant.hpp>
#include <ddspipe_participants/participant/dynamic_types/SchemaParticipant.hpp>

#include <ddsenabler_participants/CBCallbacks.hpp>
#include <ddsenabler_participants/CBHandler.hpp>
#include <ddsenabler_participants/CBHandlerConfiguration.hpp>
#include <ddsenabler_participants/DdsParticipant.hpp>
#include <ddsenabler_participants/EnablerParticipant.hpp>

#include <ddsenabler_yaml/EnablerConfiguration.hpp>

Expand Down Expand Up @@ -67,13 +66,31 @@ class DDSEnabler
void set_data_callback(
participants::DdsNotification callback)
{
cb_handler_.get()->set_data_callback(callback);
cb_handler_->set_data_callback(callback);
}

void set_type_callback(
participants::DdsTypeNotification callback)
{
cb_handler_.get()->set_type_callback(callback);
cb_handler_->set_type_callback(callback);
}

void set_topic_callback(
participants::DdsTopicNotification callback)
{
cb_handler_->set_topic_callback(callback);
}

void set_topic_request_callback(
participants::DdsTopicRequest callback)
{
enabler_participant_->set_topic_request_callback(callback);
}

void set_type_request_callback(
participants::DdsTypeRequest callback)
{
cb_handler_->set_type_request_callback(callback);
}

/**
Expand All @@ -87,6 +104,11 @@ class DDSEnabler
utils::ReturnCode reload_configuration(
yaml::EnablerConfiguration& new_configuration);

// TODO

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

bool publish(
const std::string& topic_name,
const std::string& json);

protected:

/**
Expand Down Expand Up @@ -115,11 +137,11 @@ class DDSEnabler
//! CB Handler
std::shared_ptr<eprosima::ddsenabler::participants::CBHandler> cb_handler_;

//! Dynamic Types Participant
std::shared_ptr<eprosima::ddspipe::participants::DynTypesParticipant> dyn_participant_;
//! DDS Participant
std::shared_ptr<eprosima::ddsenabler::participants::DdsParticipant> dds_participant_;

//! Schema Participant
std::shared_ptr<eprosima::ddspipe::participants::SchemaParticipant> enabler_participant_;
//! Enabler Participant
std::shared_ptr<eprosima::ddsenabler::participants::EnablerParticipant> enabler_participant_;

//! DDS Pipe
std::unique_ptr<ddspipe::core::DdsPipe> pipe_;
Expand Down
30 changes: 13 additions & 17 deletions ddsenabler/include/ddsenabler/dds_enabler_runner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,24 @@
// limitations under the License.

/**
* @file intDDSEnabler.hpp
* @file dds_enabler_runner.hpp
*
*/

#pragma once

#include <string>

#include <cpp_utils/event/FileWatcherHandler.hpp>
#include <cpp_utils/event/MultipleEventHandler.hpp>
#include <cpp_utils/event/PeriodicEventHandler.hpp>
#include <cpp_utils/event/SignalEventHandler.hpp>
#include <cpp_utils/exception/ConfigurationException.hpp>
#include <cpp_utils/exception/InitializationException.hpp>
#include <cpp_utils/logging/BaseLogConfiguration.hpp>
#include <cpp_utils/logging/StdLogConsumer.hpp>
#include <cpp_utils/ReturnCode.hpp>
#include <cpp_utils/time/time_utils.hpp>
#include <cpp_utils/types/Fuzzy.hpp>
#include <cpp_utils/utils.hpp>

#include <ddsenabler_participants/CBCallbacks.hpp>

#include <ddsenabler_yaml/EnablerConfiguration.hpp>
#include <ddsenabler_participants/DDSEnablerLogConsumer.hpp>

#include "ddsenabler/DDSEnabler.hpp"

using namespace eprosima::ddspipe;
using namespace eprosima::ddsenabler;

namespace eprosima {
namespace ddsenabler {

Expand All @@ -50,12 +43,15 @@ std::unique_ptr<eprosima::utils::event::PeriodicEventHandler> create_periodic_ha
const std::string& file_path,
const eprosima::utils::Duration_ms& reload_time);

int init_dds_enabler(
bool create_dds_enabler(
const char* ddsEnablerConfigFile,
participants::DdsNotification data_callback,
participants::DdsTypeNotification type_callback,
participants::DdsLogFunc log_callback);

participants::DdsTopicNotification topic_callback,
participants::DdsTypeRequest type_req_callback,
participants::DdsTopicRequest topic_req_callback,
participants::DdsLogFunc log_callback,
std::unique_ptr<DDSEnabler>& enabler);

} /* namespace ddsenabler */
} /* namespace eprosima */
7 changes: 7 additions & 0 deletions ddsenabler/project_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ set(MODULE_DEPENDENCIES
$<IF:$<BOOL:${WIN32}>,lz4::lz4,lz4>
$<IF:$<BOOL:${WIN32}>,$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>,zstd>)

set(MODULE_THIRDPARTY_HEADERONLY
nlohmann-json
)

set(MODULE_THIRDPARTY_PATH
"../thirdparty")

set(MODULE_LICENSE_FILE_PATH
"../LICENSE")

Expand Down
23 changes: 13 additions & 10 deletions ddsenabler/src/cpp/DDSEnabler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <filesystem>
#include <math.h>

#include <cpp_utils/exception/InitializationException.hpp>
#include <cpp_utils/utils.hpp>

#include <ddspipe_core/types/dynamic_types/types.hpp>
Expand Down Expand Up @@ -53,20 +49,20 @@ DDSEnabler::DDSEnabler(
// Create CB Handler configuration
participants::CBHandlerConfiguration handler_config;

// Create DynTypes Participant
dyn_participant_ = std::make_shared<DynTypesParticipant>(
// Create DDS Participant
dds_participant_ = std::make_shared<DdsParticipant>(
configuration_.simple_configuration,
payload_pool_,
discovery_database_);
dyn_participant_->init();
dds_participant_->init();

// Create CB Handler
cb_handler_ = std::make_shared<participants::CBHandler>(
handler_config,
payload_pool_);

// Create Enabler Participant
enabler_participant_ = std::make_shared<SchemaParticipant>(
enabler_participant_ = std::make_shared<EnablerParticipant>(
configuration_.enabler_configuration,
payload_pool_,
discovery_database_,
Expand All @@ -77,8 +73,8 @@ DDSEnabler::DDSEnabler(

// Populate Participant Database
participants_database_->add_participant(
dyn_participant_->id(),
dyn_participant_);
dds_participant_->id(),
dds_participant_);

participants_database_->add_participant(
enabler_participant_->id(),
Expand Down Expand Up @@ -123,5 +119,12 @@ void DDSEnabler::load_internal_topics_(
}
}

bool DDSEnabler::publish(
const std::string& topic_name,
const std::string& json)
{
return enabler_participant_->publish(topic_name, json);
}

} /* namespace ddsenabler */
} /* namespace eprosima */
Loading