Skip to content

Commit

Permalink
changed naming activate to enable for shm, udp, tcp layer configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky committed May 13, 2024
1 parent 18d98be commit 7804f09
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 65 deletions.
7 changes: 4 additions & 3 deletions ecal/core/include/ecal/ecal_publisher_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace eCAL
{
struct ECAL_API Configuration
{
bool activate = false; //!< activate layer
bool enable = false; //!< enable layer
bool zero_copy_mode = false; //!< enable zero copy shared memory transport mode
int acknowledge_timeout_ms = 0; /*!< force connected subscribers to send acknowledge event after processing the message
the publisher send call is blocked on this event with this timeout (0 == no handshake) */
Expand All @@ -114,7 +114,8 @@ namespace eCAL
{
struct ECAL_API Configuration
{
bool activate = false; //!< activate layer
bool enable = false; //!< enable layer
bool loopback = false; //!< enable to receive udp messages on the same local machine
int sndbuf_size_bytes = (5*1024*1024); //!< udp send buffer size in bytes (default 5MB)
};
}
Expand All @@ -123,7 +124,7 @@ namespace eCAL
{
struct ECAL_API Configuration
{
bool activate = false; //!< activate layer
bool enable = false; //!< enable layer
};
}

Expand Down
7 changes: 4 additions & 3 deletions ecal/core/src/pubsub/ecal_publisher_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace eCAL
share_topic_description(eCAL::Config::IsTopicDescriptionSharingEnabled())
{
// shm config
shm.activate = eCAL::Config::GetPublisherShmMode() != TLayer::eSendMode::smode_off;
shm.enable = eCAL::Config::GetPublisherShmMode() != TLayer::eSendMode::smode_off;
shm.zero_copy_mode = eCAL::Config::IsMemfileZerocopyEnabled();
shm.acknowledge_timeout_ms = eCAL::Config::GetMemfileAckTimeoutMs();

Expand All @@ -42,11 +42,12 @@ namespace eCAL
shm.memfile_buffer_count = eCAL::Config::GetMemfileBufferCount();

// udp config
udp.activate = eCAL::Config::GetPublisherUdpMulticastMode() != TLayer::eSendMode::smode_off;
udp.enable = eCAL::Config::GetPublisherUdpMulticastMode() != TLayer::eSendMode::smode_off;
udp.loopback = false; // TODO: make this configurable
udp.sndbuf_size_bytes = eCAL::Config::GetUdpMulticastSndBufSizeBytes();

// tcp config
tcp.activate = eCAL::Config::GetPublisherTcpMode() != TLayer::eSendMode::smode_off;
tcp.enable = eCAL::Config::GetPublisherTcpMode() != TLayer::eSendMode::smode_off;
}
}
}
46 changes: 17 additions & 29 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,10 @@ namespace eCAL
// register
Register(false);

// create udp multicast layer
ActivateUdpLayer(config_.udp.activate);

// create shm layer
ActivateShmLayer(config_.shm.activate);

// create tcp layer
ActivateTcpLayer(config_.tcp.activate);
// enable transport layers
EnableUdpLayer(config_.udp.enable);
EnableShmLayer(config_.shm.enable);
EnableTcpLayer(config_.tcp.enable);
}

CDataWriter::~CDataWriter()
Expand Down Expand Up @@ -264,9 +260,9 @@ namespace eCAL
// can we do a zero copy write ?
const bool allow_zero_copy =
m_config.shm.zero_copy_mode // zero copy mode activated by user
&& m_config.shm.activate // shm layer active
&& !m_config.udp.activate // udp layer inactive
&& !m_config.tcp.activate; // tcp layer inactive
&& m_config.shm.enable // shm layer active
&& !m_config.udp.enable // udp layer inactive
&& !m_config.tcp.enable; // tcp layer inactive

// create a payload copy for all layer
if (!allow_zero_copy)
Expand All @@ -285,7 +281,7 @@ namespace eCAL
// SHM
////////////////////////////////////////////////////////////////////////////
#if ECAL_CORE_TRANSPORT_SHM
if (m_writer_shm && m_config.shm.activate)
if (m_writer_shm && m_config.shm.enable)
{
#ifndef NDEBUG
// log it
Expand Down Expand Up @@ -351,7 +347,7 @@ namespace eCAL
// UDP (MC)
////////////////////////////////////////////////////////////////////////////
#if ECAL_CORE_TRANSPORT_UDP
if (m_writer_udp && m_config.udp.activate)
if (m_writer_udp && m_config.udp.enable)
{
#ifndef NDEBUG
// log it
Expand All @@ -361,22 +357,14 @@ namespace eCAL
// send it
bool udp_sent(false);
{
#if ECAL_CORE_TRANSPORT_SHM
// if shared memory layer for local communication is not activated
// we activate udp message loopback to communicate with local processes too
const bool loopback = !m_config.shm.activate;
#else
const bool loopback = true;
#endif

// fill writer data
struct SWriterAttr wattr;
wattr.len = payload_buf_size;
wattr.id = m_id;
wattr.clock = m_clock;
wattr.hash = snd_hash;
wattr.time = time_;
wattr.loopback = loopback;
wattr.loopback = m_config.udp.loopback;

// prepare send
if (m_writer_udp->PrepareWrite(wattr))
Expand Down Expand Up @@ -410,7 +398,7 @@ namespace eCAL
// TCP
////////////////////////////////////////////////////////////////////////////
#if ECAL_CORE_TRANSPORT_TCP
if (m_writer_tcp && m_config.tcp.activate)
if (m_writer_tcp && m_config.tcp.enable)
{
#ifndef NDEBUG
// log it
Expand Down Expand Up @@ -749,10 +737,10 @@ namespace eCAL
}
}

void CDataWriter::ActivateUdpLayer(bool state_)
void CDataWriter::EnableUdpLayer(bool state_)
{
#if ECAL_CORE_TRANSPORT_UDP
m_config.udp.activate = state_;
m_config.udp.enable = state_;
if (!m_created) return;

// log state
Expand All @@ -774,10 +762,10 @@ namespace eCAL
#endif // ECAL_CORE_TRANSPORT_UDP
}

void CDataWriter::ActivateShmLayer(bool state_)
void CDataWriter::EnableShmLayer(bool state_)
{
#if ECAL_CORE_TRANSPORT_SHM
m_config.shm.activate = state_;
m_config.shm.enable = state_;
if (!m_created) return;

// log state
Expand All @@ -800,10 +788,10 @@ namespace eCAL
#endif // ECAL_CORE_TRANSPORT_SHM
}

void CDataWriter::ActivateTcpLayer(bool state_)
void CDataWriter::EnableTcpLayer(bool state_)
{
#if ECAL_CORE_TRANSPORT_TCP
m_config.tcp.activate = state_;
m_config.tcp.enable = state_;
if (!m_created) return;

// log state
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/readwrite/ecal_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ namespace eCAL
void Connect(const std::string& tid_, const SDataTypeInformation& tinfo_);
void Disconnect();

void ActivateUdpLayer(bool state_);
void ActivateShmLayer(bool state_);
void ActivateTcpLayer(bool state_);
void EnableUdpLayer(bool state_);
void EnableShmLayer(bool state_);
void EnableTcpLayer(bool state_);

size_t PrepareWrite(long long id_, size_t len_);
bool IsInternalSubscribedOnly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ void throughput_test(int snd_size, int snd_loops, eCAL::TLayer::eTransportLayer
eCAL::Publisher::Configuration pub_config;

// set transport layer
pub_config.shm.activate = false;
pub_config.udp.activate = false;
pub_config.tcp.activate = false;
pub_config.shm.enable = false;
pub_config.udp.enable = false;
pub_config.tcp.enable = false;
switch (layer)
{
case eCAL::TLayer::tlayer_shm:
pub_config.shm.activate = true;
pub_config.shm.enable = true;
break;
case eCAL::TLayer::tlayer_udp_mc:
pub_config.udp.activate = true;
pub_config.udp.enable = true;
break;
case eCAL::TLayer::tlayer_tcp:
pub_config.tcp.activate = true;
pub_config.tcp.enable = true;
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ int main(int argc, char **argv)
eCAL::Publisher::Configuration pub_config;

// switch shm and udp layer off, tcp layer on
pub_config.shm.activate = false;
pub_config.udp.activate = false;
pub_config.tcp.activate = true;
pub_config.shm.enable = false;
pub_config.udp.enable = false;
pub_config.tcp.enable = true;

// create a publisher (topic name "person")
eCAL::protobuf::CPublisher<pb::People::Person> pub("person", pub_config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ int main(int argc, char **argv)
eCAL::Publisher::Configuration pub_config;

// switch shm and tcp layer off, udp layer on
pub_config.shm.activate = false;
pub_config.udp.activate = true;
pub_config.tcp.activate = false;
pub_config.shm.enable = false;
pub_config.udp.enable = true;
pub_config.tcp.enable = false;

// create a publisher (topic name "person")
eCAL::protobuf::CPublisher<pb::People::Person> pub("person", pub_config);
Expand Down
6 changes: 3 additions & 3 deletions ecal/tests/cpp/pubsub_test/src/pubsub_multibuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ std::vector<char> multibuffer_pub_sub_test(int buffer_count, bool zero_copy, int
// create publisher config
eCAL::Publisher::Configuration pub_config;
// set transport layer
pub_config.shm.activate = true;
pub_config.udp.activate = false;
pub_config.tcp.activate = false;
pub_config.shm.enable = true;
pub_config.udp.enable = false;
pub_config.tcp.enable = false;
// set zero copy mode
pub_config.shm.zero_copy_mode = zero_copy;
// set number of memory buffer
Expand Down
12 changes: 6 additions & 6 deletions ecal/tests/cpp/pubsub_test/src/pubsub_test_shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ TEST(core_cpp_pubsub, ZeroPayloadMessageSHM)
// create publisher config
eCAL::Publisher::Configuration pub_config;
// set transport layer
pub_config.shm.activate = true;
pub_config.udp.activate = false;
pub_config.tcp.activate = false;
pub_config.shm.enable = true;
pub_config.udp.enable = false;
pub_config.tcp.enable = false;

// create publisher for topic "A"
eCAL::CPublisher pub("A", pub_config);
Expand Down Expand Up @@ -115,9 +115,9 @@ TEST(core_cpp_pubsub, MultipleSendsSHM)
// create publisher config
eCAL::Publisher::Configuration pub_config;
// set transport layer
pub_config.shm.activate = true;
pub_config.udp.activate = false;
pub_config.tcp.activate = false;
pub_config.shm.enable = true;
pub_config.udp.enable = false;
pub_config.tcp.enable = false;

// create publisher for topic "A"
eCAL::string::CPublisher<std::string> pub("A", pub_config);
Expand Down
12 changes: 6 additions & 6 deletions ecal/tests/cpp/pubsub_test/src/pubsub_test_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ TEST(core_cpp_pubsub, ZeroPayloadMessageUDP)
// create publisher config
eCAL::Publisher::Configuration pub_config;
// set transport layer
pub_config.shm.activate = false;
pub_config.udp.activate = true;
pub_config.tcp.activate = false;
pub_config.shm.enable = false;
pub_config.udp.enable = true;
pub_config.tcp.enable = false;

// create publisher for topic "A"
eCAL::CPublisher pub("A", pub_config);
Expand Down Expand Up @@ -115,9 +115,9 @@ TEST(core_cpp_pubsub, MultipleSendsUDP)
// create publisher config
eCAL::Publisher::Configuration pub_config;
// set transport layer
pub_config.shm.activate = false;
pub_config.udp.activate = true;
pub_config.tcp.activate = false;
pub_config.shm.enable = false;
pub_config.udp.enable = true;
pub_config.tcp.enable = false;

// create publisher for topic "A"
eCAL::string::CPublisher<std::string> pub("A", pub_config);
Expand Down

0 comments on commit 7804f09

Please sign in to comment.