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

[config] Attributes for Publisher/Subscriber and Reader/Writer #1747

Merged
merged 5 commits into from
Oct 14, 2024
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
8 changes: 7 additions & 1 deletion ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ endif()
# common
######################################
set(ecal_cmn_src
src/config/builder/monitoring_attribute_builder.cpp
src/ecal.cpp
src/ecal_def.h
src/ecal_def_ini.h
Expand Down Expand Up @@ -456,6 +455,13 @@ set (ecal_builder_src
src/config/builder/monitoring_attribute_builder.cpp
src/config/builder/registration_attribute_builder.cpp
src/logging/config/builder/udp_attribute_builder.cpp
src/pubsub/config/builder/reader_attribute_builder.cpp
src/pubsub/config/builder/writer_attribute_builder.cpp
src/readwrite/config/builder/shm_attribute_builder.cpp
src/readwrite/config/builder/tcp_attribute_builder.cpp
src/readwrite/config/builder/udp_attribute_builder.cpp
src/readwrite/tcp/config/builder/data_reader_tcp_attribute_builder.cpp
src/readwrite/udp/config/builder/udp_attribute_builder.cpp
src/registration/config/builder/udp_shm_attribute_builder.cpp
src/registration/config/builder/sample_applier_attribute_builder.cpp
src/registration/udp/config/builder/udp_attribute_builder.cpp
Expand Down
60 changes: 60 additions & 0 deletions ecal/core/src/pubsub/config/builder/reader_attribute_builder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#pragma once

#include "reader_attribute_builder.h"
#include "ecal/ecal_process.h"

namespace eCAL
{
eCALReader::SAttributes BuildReaderAttributes(const std::string& topic_name_, const Subscriber::Configuration& sub_config_, const Publisher::Configuration& pub_config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_)
{
eCALReader::SAttributes attributes;

attributes.network_enabled = reg_config_.network_enabled;
attributes.loopback = reg_config_.loopback;
attributes.drop_out_of_order_messages = sub_config_.drop_out_of_order_messages;
attributes.registation_timeout_ms = reg_config_.registration_timeout;
Peguen marked this conversation as resolved.
Show resolved Hide resolved
attributes.topic_name = topic_name_;
attributes.host_name = Process::GetHostName();
attributes.host_group_name = Process::GetHostGroupName();
attributes.process_id = Process::GetProcessID();
attributes.process_name = Process::GetProcessName();
attributes.share_topic_type = pub_config_.share_topic_type;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

share_topic_type and share_topic_description needs to be moved to registration configuration in the future

attributes.share_topic_description = pub_config_.share_topic_description;

attributes.udp.enable = sub_config_.layer.udp.enable;
attributes.udp.mode = tl_config_.udp.mode;
attributes.udp.port = tl_config_.udp.port;
attributes.udp.receivebuffer = tl_config_.udp.receive_buffer;

attributes.udp.local.group = tl_config_.udp.local.group;

attributes.udp.network.group = tl_config_.udp.network.group;

attributes.tcp.enable = sub_config_.layer.tcp.enable;
attributes.tcp.thread_pool_size = tl_config_.tcp.number_executor_reader;
attributes.tcp.max_reconnection_attempts = tl_config_.tcp.max_reconnections;

attributes.shm.enable = sub_config_.layer.shm.enable;

return attributes;
}
}
31 changes: 31 additions & 0 deletions ecal/core/src/pubsub/config/builder/reader_attribute_builder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#pragma once

#include "readwrite/config/attributes/reader_attributes.h"
#include "ecal/config/subscriber.h"
#include "ecal/config/transport_layer.h"
#include "ecal/config/registration.h"
#include "ecal/config/publisher.h"

namespace eCAL
{
eCALReader::SAttributes BuildReaderAttributes(const std::string& topic_name_, const Subscriber::Configuration& sub_config_, const Publisher::Configuration& pub_config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_);
}
70 changes: 70 additions & 0 deletions ecal/core/src/pubsub/config/builder/writer_attribute_builder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#pragma once

#include "writer_attribute_builder.h"
#include "ecal/ecal_process.h"

namespace eCAL
{
eCALWriter::SAttributes BuildWriterAttributes(const std::string& topic_name_, const Publisher::Configuration& pub_config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_)
{
eCALWriter::SAttributes attributes;

attributes.network_enabled = reg_config_.network_enabled;
attributes.loopback = reg_config_.loopback;

attributes.share_topic_type = pub_config_.share_topic_type;
attributes.share_topic_description = pub_config_.share_topic_description;
attributes.layer_priority_local = pub_config_.layer_priority_local;
attributes.layer_priority_remote = pub_config_.layer_priority_remote;

attributes.host_name = Process::GetHostName();
attributes.host_group_name = Process::GetHostGroupName();
attributes.process_id = Process::GetProcessID();
attributes.process_name = Process::GetProcessName();

attributes.unit_name = Process::GetUnitName();
attributes.topic_name = topic_name_;

attributes.shm.enable = pub_config_.layer.shm.enable;
attributes.shm.acknowledge_timeout_ms = pub_config_.layer.shm.acknowledge_timeout_ms;
attributes.shm.memfile_buffer_count = pub_config_.layer.shm.memfile_buffer_count;
attributes.shm.memfile_min_size_bytes = pub_config_.layer.shm.memfile_min_size_bytes;
attributes.shm.memfile_reserve_percent = pub_config_.layer.shm.memfile_reserve_percent;
attributes.shm.zero_copy_mode = pub_config_.layer.shm.zero_copy_mode;

attributes.udp.enable = pub_config_.layer.udp.enable;
attributes.udp.port = tl_config_.udp.port;
attributes.udp.send_buffer = tl_config_.udp.send_buffer;
attributes.udp.mode = tl_config_.udp.mode;

attributes.udp.network.group = tl_config_.udp.network.group;
attributes.udp.network.ttl = tl_config_.udp.network.ttl;

attributes.udp.local.group = tl_config_.udp.local.group;
attributes.udp.local.ttl = tl_config_.udp.local.ttl;

attributes.tcp.enable = pub_config_.layer.tcp.enable;
attributes.tcp.thread_pool_size = tl_config_.tcp.number_executor_writer;

return attributes;
}
}
29 changes: 29 additions & 0 deletions ecal/core/src/pubsub/config/builder/writer_attribute_builder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#pragma once

#include "readwrite/config/attributes/writer_attributes.h"
#include "ecal/config/publisher.h"
#include "ecal/config/registration.h"

namespace eCAL
{
eCALWriter::SAttributes BuildWriterAttributes(const std::string& topic_name_, const Publisher::Configuration& config_, const eCAL::TransportLayer::Configuration& tl_config_, const eCAL::Registration::Configuration& reg_config_);
}
5 changes: 4 additions & 1 deletion ecal/core/src/pubsub/ecal_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "readwrite/ecal_writer.h"
#include "readwrite/ecal_writer_buffer_payload.h"

#include "config/builder/writer_attribute_builder.h"
#include "ecal/ecal_config.h"

#include <iostream>
#include <memory>
#include <sstream>
Expand Down Expand Up @@ -91,7 +94,7 @@ namespace eCAL
if (topic_name_.empty()) return(false);

// create datawriter
m_datawriter = std::make_shared<CDataWriter>(topic_name_, data_type_info_, config_);
m_datawriter = std::make_shared<CDataWriter>(data_type_info_, BuildWriterAttributes(topic_name_, config_, GetTransportLayerConfiguration(), GetRegistrationConfiguration()));

// register datawriter
g_pubgate()->Register(topic_name_, m_datawriter);
Expand Down
3 changes: 2 additions & 1 deletion ecal/core/src/pubsub/ecal_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "ecal_globals.h"
#include "readwrite/ecal_reader.h"
#include "config/builder/reader_attribute_builder.h"

#include <iostream>
#include <set>
Expand Down Expand Up @@ -81,7 +82,7 @@ namespace eCAL
if (topic_name_.empty()) return(false);

// create datareader
m_datareader = std::make_shared<CDataReader>(topic_name_, data_type_info_, config_);
m_datareader = std::make_shared<CDataReader>(data_type_info_, BuildReaderAttributes(topic_name_, config_, GetPublisherConfiguration(), GetTransportLayerConfiguration(), GetRegistrationConfiguration()));

// register datareader
g_subgate()->Register(topic_name_, m_datareader);
Expand Down
78 changes: 78 additions & 0 deletions ecal/core/src/readwrite/config/attributes/reader_attributes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================= eCAL LICENSE =================================
*/

#pragma once

#include <string>
#include <cstddef>
#include "ecal/types/ecal_custom_data_types.h"

namespace eCAL
{
namespace eCALReader
{
struct SUDPModeAttributes
{
std::string group;
};

struct SUDPAttributes
{
bool enable;
Types::UDPMode mode;
int port;
int receivebuffer;
SUDPModeAttributes network;
SUDPModeAttributes local;
};

struct STCPAttributes
{
bool enable;
size_t thread_pool_size;
int max_reconnection_attempts;
};

struct SSHMAttributes
{
bool enable;
};

struct SAttributes
{
bool network_enabled;
bool drop_out_of_order_messages;
bool loopback;
unsigned int registation_timeout_ms;

SUDPAttributes udp;
STCPAttributes tcp;
SSHMAttributes shm;

std::string topic_name;
std::string host_name;
std::string host_group_name;
int process_id;
std::string process_name;
std::string unit_name;
bool share_topic_type;
bool share_topic_description;
};
}
}
Loading
Loading