Ejemplo n.º 1
0
void ReqRepHelloWorldReplier::newNumber(SampleIdentity sample_identity, uint16_t number)
{
    waitDiscovery();

    WriteParams wparams;
    HelloWorld hello;
    hello.index(number);
    hello.message("GoodBye");
    wparams.related_sample_identity(sample_identity);
    ASSERT_EQ(reply_publisher_->write((void*)&hello, wparams), true);
}
void PubSubKeepAllTransientWriter::send(const std::list<uint16_t> &msgs)
{
    waitDiscovery();

	for(std::list<uint16_t>::const_iterator it = msgs.begin(); it != msgs.end(); ++it)
	{
        HelloWorld hello;
        hello.index(*it);
        hello.message("HelloWorld");
        publisher_->write((void*)&hello);
	}
}
Ejemplo n.º 3
0
int main()
{
	ParticipantAttributes participant_attributes;
	Participant* participant = Domain::createParticipant(participant_attributes);

	if(participant == nullptr)
		return 1;

    HelloWorldType type; 
	Domain::registerType(participant,&type);

    PubListener listener;

	//CREATE THE PUBLISHER
	PublisherAttributes publisher_attributes;
	publisher_attributes.topic.topicKind = NO_KEY;
	publisher_attributes.topic.topicDataType = type.getName();
	publisher_attributes.topic.topicName = "HelloWorldTopic";
	publisher_attributes.qos.m_reliability.kind = RELIABLE_RELIABILITY_QOS;
	Publisher* publisher = Domain::createPublisher(participant, publisher_attributes, &listener);
	if(publisher == nullptr)
    {
        Domain::removeParticipant(participant);
		return 1;
    }

    while(listener.matched_ == 0)
		eClock::my_sleep(250);

    HelloWorld data;
    data.index(1);
    data.message("HelloWorld");

    while(1)
    {
        publisher->write((void*)&data);

        if(data.index() == 4)
            data.index() = 1;
        else
            ++data.index();

		eClock::my_sleep(250);
    };

	Domain::removeParticipant(participant);

	return 0;
}
Ejemplo n.º 4
0
void ReqRepHelloWorldRequester::send(const uint16_t number)
{
    waitDiscovery();

    WriteParams wparams;
    HelloWorld hello;
    hello.index(number);
    hello.message("HelloWorld");

    std::unique_lock<std::mutex> lock(mutex_);

    ASSERT_EQ(request_publisher_->write((void*)&hello, wparams), true);
    related_sample_identity_ = wparams.sample_identity();
    current_number_ = number;
}
Ejemplo n.º 5
0
void ReqRepHelloWorldRequester::ReplyListener::onNewDataMessage(Subscriber *sub)
{
    ASSERT_NE(sub, nullptr);

    HelloWorld hello;
    SampleInfo_t info;

    if(sub->takeNextData((void*)&hello, &info))
    {
        if(info.sampleKind == ALIVE)
        {
            ASSERT_EQ(hello.message().compare("GoodBye"), 0);
            requester_.newNumber(info.related_sample_identity, hello.index());
        }
    }
}
Ejemplo n.º 6
0
void HelloWorldTest::test0()
{
  HelloWorld hello;
  string expected("Hello World");
  CPPUNIT_ASSERT_EQUAL(expected, hello.message());
}
Ejemplo n.º 7
0
TEST(HelloWorldTest, test0)
{
  HelloWorld hello;
  string expected("Hello World");
  ASSERT_EQ(expected, hello.message());
}