예제 #1
0
// TODO Change api of  set_IP4_address to support const string.
void RTPSAsSocketReader::init(std::string &ip, uint32_t port, uint16_t nmsgs)
{
	RTPSParticipantAttributes pattr;
	pattr.builtin.use_SIMPLE_RTPSParticipantDiscoveryProtocol = false;
	pattr.builtin.use_WriterLivelinessProtocol = false;
    pattr.builtin.domainId = (uint32_t)GET_PID() % 230;
    pattr.participantID = 1;
	participant_ = RTPSDomain::createParticipant(pattr);

	//Create readerhistory
	HistoryAttributes hattr;
	hattr.payloadMaxSize = 255;
	history_ = new ReaderHistory(hattr);

	//Create reader
	ReaderAttributes rattr;
	Locator_t loc;
	loc.set_IP4_address(ip);
	loc.port = port;
	rattr.endpoint.multicastLocatorList.push_back(loc);
    configReader(rattr);
	reader_ = RTPSDomain::createRTPSReader(participant_, rattr, history_, &listener_);

	//Add remote writer (in this case a reader in the same machine)
    GUID_t guid = participant_->getGuid();
    addRemoteWriter(reader_, ip, port, guid);

    // Initialize list of msgs
    for(uint16_t count = 0; count < nmsgs; ++count)
    {
        msgs_.push_back(count);
    }

    text_ = getText();
    domainId_ = (uint32_t)GET_PID();
    hostname_ = asio::ip::host_name();

    std::ostringstream word;
    word << text_ << "_" << hostname_ << "_" << domainId_;
    word_ = word.str();

    initialized_ = true;
}
예제 #2
0
// TODO Change api of  set_IP4_address to support const string.
void RTPSAsSocketReader::init(std::string &ip, uint32_t port, uint16_t nmsgs)
{
	RTPSParticipantAttributes pattr;
	pattr.builtin.use_SIMPLE_RTPSParticipantDiscoveryProtocol = false;
	pattr.builtin.use_WriterLivelinessProtocol = false;
    pattr.participantID = 1;
	participant_ = RTPSDomain::createParticipant(pattr);
    ASSERT_NE(participant_, nullptr);

	//Create readerhistory
	HistoryAttributes hattr;
	hattr.payloadMaxSize = 255;
	history_ = new ReaderHistory(hattr);
    ASSERT_NE(history_, nullptr);

	//Create reader
	ReaderAttributes rattr;
	Locator_t loc;
	loc.set_IP4_address(ip);
	loc.port = port;
	rattr.endpoint.multicastLocatorList.push_back(loc);
    configReader(rattr);
	reader_ = RTPSDomain::createRTPSReader(participant_, rattr, history_, &listener_);
    ASSERT_NE(reader_, nullptr);

	//Add remote writer (in this case a reader in the same machine)
    GUID_t guid = participant_->getGuid();
    addRemoteWriter(reader_, ip, port, guid);

    // Initialize list of msgs
    for(uint16_t count = 0; count < nmsgs; ++count)
    {
        msgs_.push_back(count);
    }

    initialized_ = true;
}