Skip to content

Commit

Permalink
minimal send sample reverted
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky committed Apr 16, 2024
1 parent f4b7753 commit ef29175
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions ecal/samples/cpp/pubsub/string/minimal_snd/src/minimal_snd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,42 @@
#include <ecal/msg/string/publisher.h>

#include <iostream>
#include <chrono>
#include <sstream>

class CDescGate
int main(int argc, char **argv)
{
public:
CDescGate(const std::chrono::milliseconds& exp_timeout_)
{
std::cout << "Constructor" << std::endl;
}
void Foo()
std::cout << "-------------------------------" << std::endl;
std::cout << " HELLO WORLD SENDER" << std::endl;
std::cout << "-------------------------------" << std::endl;

// initialize eCAL API
eCAL::Initialize(argc, argv, "minimal_snd");

// publisher for topic "Hello"
eCAL::string::CPublisher<std::string> pub("Hello");

// set some attributes
pub.SetAttribute("Hello", "World");
pub.SetAttribute("Hallo", "Welt");

// send updates
int cnt = 0;
while (eCAL::Ok())
{
std::cout << "Foo" << std::endl;
// build string
std::stringstream snd_content;
snd_content << "Hello World" << " (" << ++cnt << ")";

// send content
pub.Send(snd_content.str(), cnt);
std::cout << "Sent \"" << snd_content.str() << "\"" << std::endl;

// sleep 10 ms
eCAL::Process::SleepMS(10);
}
};

int main(int argc, char **argv)
{
long long time_ms(5000);
CDescGate desc_gate(std::chrono::milliseconds(time_ms));
desc_gate.Foo();
// finalize eCAL API
eCAL::Finalize();

return(0);
}

0 comments on commit ef29175

Please sign in to comment.