Ejemplo n.º 1
0
shared_ptr<ObjectsIRevisionable> FileEditor::createObject()
{
	String file_name;
	String file_type;
	const Buffer *file_data = nullptr;

	if(isRevision() && m_enableBrowser->getCheck() == false)
	{
		shared_ptr<ObjectsFile> currentFile = objects_file_cast(getCurrent());
		if(currentFile != nullptr)
		{
			file_name = currentFile->file_name;
			file_type = currentFile->file_type;
			file_data = currentFile->file_data.get_ptr();
		}
	}
	else
	{
		file_name = m_browser->getFileName();
		file_type = m_browser->getFileType();
		file_data = m_browser->getFileBuffer();
	}

	if(file_data == nullptr)
		return nullptr;

	shared_ptr<ObjectsFile> file(OS_NEW ObjectsFile());
	file->title = algorithms::trim_copy(m_title->getValue());
	file->description = algorithms::trim_copy(m_description->getValue());
	file->file_name = algorithms::trim_copy(file_name);
	file->file_data = *file_data;
	file->file_type = file_type;
	file->file_size = file_data->getSize();

	return file;
}
Ejemplo n.º 2
0
void VoiceRecognitionServer::Main()
{
    /**
     * \sa print
     **/
    //Gui::getInstance();
    //pluginTab = new Tab("Net_server");
    //cons= new Console(WIDTH-600,HEIGHT*.02,600,HEIGHT/2, "net_console", pluginTab);

    NetThread *net = new NetThread();
    string speech= "";

    net->SetOutputStream(stdout);
    net->OpenReadPort(2070);
    net->start();
    net->Accept();
    sleep(10);

    string line;
    ifstream NamesFile("../data/Names");
    if(NamesFile)
    {
    vector<string> names;
    
    while (getline(NamesFile, line))
    {
        names.push_back(line);
    }
    }

    ifstream ObjectsFile("../data/Objects");
    if(ObjectsFile)
    {
    vector<string> objects;
    while (getline(ObjectsFile, line))
    {
        objects.push_back(line);
    }
    }
    
    ifstream DestinationsFile("../data/Destinations");
    if(DestinationsFile)
    {
    vector<string> Destinations;
    while (getline(DestinationsFile, line))
    {
        Destinations.push_back(line);
    }
    }
 
    string accion;
  
	patrol->getInstance().set_Action("LearnPosition");
	for (;;){
		string action = patrol->getInstance().get_Action();
		
		if (action =="LearnPosition"){			
			
			string Location = "";
			
			TextToSpeech("please tell me Name of this location",3);
			Location = LoopRecognize("REQstartRestaurant",net,"name of this location"); //confirmando
// 			sleep(5);
			TextToSpeech("I learnd this place as "+Location,0);
			patrol->getInstance().Microphone.set_Phrase(Location);
			patrol->getInstance().set_Action("follow");

		}
		
		if (action =="requestOrderRestaurant"){			
			
			string Location = "";
			string ObjectA = "";
			string ObjectB = "";
			TextToSpeech("I am ready to take your order",3);
			TextToSpeech("please tell me the first object",3);
			ObjectA = LoopRecognize("REQstartRestaurant",net,"name of the first object"); //confirmando
			sleep(5);
			TextToSpeech("i will bring "+ObjectA,2);
			
			TextToSpeech("please tell me the second object",3);
			ObjectB = LoopRecognize("REQstartRestaurant",net,"name of the second object"); //confirmando
			sleep(5);
// 			TextToSpeech("i will bring "+ObjectB,4);
			
			TextToSpeech("please tell me where to take"+ObjectA+" and "+ ObjectB,6);
			Location = LoopRecognize("REQstartRestaurant",net,"name of the location"); //confirmando
			sleep(5);
			TextToSpeech("i will bring "+ObjectA+"and"+ ObjectB + " to "+Location ,6);
			
			patrol->getInstance().Microphone.set_Phrase(ObjectA);
			patrol->getInstance().Microphone.set_Words(ObjectB);
			patrol->getInstance().set_Current_destination("snaks");

		}
	}
    usleep(100);
}