void RTPSWithRegistrationWriter::init()
{
	//Create participant
	RTPSParticipantAttributes pattr;
	pattr.builtin.use_SIMPLE_RTPSParticipantDiscoveryProtocol = true;
	pattr.builtin.use_WriterLivelinessProtocol = true;
    pattr.builtin.domainId = (uint32_t)boost::interprocess::ipcdetail::get_current_process_id() % 230;
	participant_ = RTPSDomain::createParticipant(pattr);
    ASSERT_NE(participant_, nullptr);

	//Create writerhistory
	HistoryAttributes hattr;
	hattr.payloadMaxSize = 255;
	history_ = new WriterHistory(hattr);

	//Create writer
	WriterAttributes wattr;
    eprosima::fastrtps::WriterQos Wqos;
    configWriter(wattr, Wqos);
	writer_ = RTPSDomain::createRTPSWriter(participant_, wattr, history_, &listener_);
    ASSERT_NE(writer_, nullptr);

    eprosima::fastrtps::TopicAttributes tattr;
	tattr.topicKind = NO_KEY;
	tattr.topicDataType = "string";
    configTopic(tattr);
	ASSERT_EQ(participant_->registerWriter(writer_, tattr, Wqos), true);

    initialized_ = true;
}
Пример #2
0
int SettingsState::handleKey(int key) {
    if (key == FL_F+3) {
        Config->toggleContrast();
        return(1);
    }
    if (key == FL_F+4) {
        Config->toggleFont();
        return(1);
    }
    if (key == FL_F+5) {
        Config->toggleLinecount();
        return(1);
    }
    if (key == FL_F+6) {
    	if (Config->getPIN().empty()) {
    		this->enteredNewPIN.clear();
    		std::string caption = _("Enter PIN");
    		pinInputState = new PINInputState(Commands, this, caption);
    		Commands->setNewState(pinInputState);
    	} else {
    	  std::string emptyStr;
    	  emptyStr.clear();
    	  Config->setPIN(emptyStr);
    	  // Set this as new state to refresh the screen
    	  Commands->setNewState(this);
    	}
        return(1);
    }

    // write changes to config file
    SettingsPersistence configWriter(Config);
    std::stringstream configFilename;
    configFilename << configWriter.getHomeDir() << "/" << CONFIGFILENAME;
    configWriter.write(configFilename.str());

    Commands->setNewState(Commands->getTypingState());

    return (1);
}