示例#1
0
文件: manager.cpp 项目: lessc0de/yarp
bool Manager::updateResources(void)
{
    YarpBroker broker;
    broker.init();

    // finding all available yarp ports
    vector<string> ports;
    broker.getAllPorts(ports);

    ResourcePContainer allresources = knowledge.getResources();
    for(unsigned int i=0; i<allresources.size(); i++)
    {
        Computer* comp = dynamic_cast<Computer*>(allresources[i]);
        if(updateResource(comp))
        {
            //set all as unavailable
            for(int i=0; i<comp->peripheralCount(); i++)
            {
                ResYarpPort* res =
                    dynamic_cast<ResYarpPort*>(&comp->getPeripheralAt(i));
                if(res)
                    res->setAvailability(false);
            }

            // adding all available yarp ports as peripherals
            for(unsigned int i=0; i<ports.size(); i++)
            {
                ResYarpPort resport;
                resport.setName(ports[i].c_str());
                resport.setPort(ports[i].c_str());

                bool bfound = false;
                for(int i=0; i<comp->peripheralCount(); i++)
                {
                    ResYarpPort* res =
                        dynamic_cast<ResYarpPort*>(&comp->getPeripheralAt(i));
                    if(res && (string(res->getName()) == string(resport.getName())))
                    {
                        res->setAvailability(true);
                        bfound = true;
                        break;
                    }
                }
                if(!bfound)
                    comp->addPeripheral(resport);
            }
        }
    } // end of for

    return true;
}
示例#2
0
bool SafeManager::prepare(Manager* lazy,
                         yarp::os::Property* pConfig, ApplicationEvent* event)
{

    eventReceiver = event;
    m_pConfig = pConfig;

    if(pConfig->find("watchdog").asString() == "yes")
        enableWatchDog();
    else
        disableWatchod();

    if(pConfig->find("auto_dependency").asString() == "yes")
        enableAutoDependency();
    else
        disableAutoDependency();

    if(pConfig->find("auto_connect").asString() == "yes")
        enableAutoConnect();
    else
        disableAutoConnect();

    // making manager from lazy manager
    KnowledgeBase* lazy_kb = lazy->getKnowledgeBase();

    ModulePContainer mods =  lazy_kb->getModules();
    for(ModulePIterator itr=mods.begin(); itr!=mods.end(); itr++)
        getKnowledgeBase()->addModule((*itr));

    ResourcePContainer res =  lazy_kb->getResources();
    for(ResourcePIterator itr=res.begin(); itr!=res.end(); itr++)
        getKnowledgeBase()->addResource((*itr));

    ApplicaitonPContainer apps =  lazy_kb->getApplications();
    for(ApplicationPIterator itr=apps.begin(); itr!=apps.end(); itr++)
        getKnowledgeBase()->addApplication((*itr));

    return true;
}
示例#3
0
文件: manager.cpp 项目: lessc0de/yarp
bool Manager::loadApplication(const char* szAppName)
{
    __CHECK_NULLPTR(szAppName);

    if(!allStopped())
    {
        logger->addError("Please stop current running application first.");
        return false;
    }

    strAppName = szAppName;

    // set all resources as unavailable
    ResourcePContainer allresources = knowledge.getResources();
    for(unsigned int i=0; i<allresources.size(); i++)
    {
        Computer* comp = dynamic_cast<Computer*>(allresources[i]);
        if(comp)
            comp->setAvailability(false);
    }

    return prepare(true);
}
示例#4
0
bool YConsoleManager::process(const vector<string> &cmdList)
{
    if (!cmdList.size() || cmdList[0] == "")
        return true;

    /**
     * help
     */
     if((cmdList.size() == 1) &&
        (cmdList[0] == "help"))
     {
         help();
         return true;
     }


    /**
     * add application
     */
     if((cmdList.size() == 3) &&
        (cmdList[0] == "add") && (cmdList[1] == "app"))
     {
         if(addApplication(cmdList[2].c_str()))
            cout<<INFO<<cmdList[2]<<" is successfully added."<<ENDC<<endl;
         reportErrors();
        #ifdef WITH_READLINE
        updateAppNames(&appnames);
        #endif
         return true;
     }

    /**
     * add module
     */
     if((cmdList.size() == 3) &&
        (cmdList[0] == "add") && (cmdList[1] == "mod"))
     {
         if(addModule(cmdList[2].c_str()))
            cout<<INFO<<cmdList[2]<<" is successfully added."<<ENDC<<endl;
         reportErrors();
         return true;
     }

    /**
     * add resource
     */
     if((cmdList.size() == 3) &&
        (cmdList[0] == "add") && (cmdList[1] == "res"))
     {
         if(addResource(cmdList[2].c_str()))
            cout<<INFO<<cmdList[2]<<" is successfully added."<<ENDC<<endl;
         reportErrors();
         return true;
     }


    /**
     * load application
     */
     if((cmdList.size() == 3) &&
        (cmdList[0] == "load") && (cmdList[1] == "app"))
     {
         if(loadApplication(cmdList[2].c_str()))
         {
            //cout<<cmdList[2]<<" is successfully loaded."<<endl;
            which();
         }
         reportErrors();
         return true;
     }

    /**
     * load module
     */
    /*
     if((cmdList.size() >= 3) &&
        (cmdList[0] == "load") && (cmdList[1] == "mod"))
     {
         if(cmdList.size() > 3)
         {
            if(manager.loadModule(cmdList[2].c_str(), cmdList[3].c_str()))
                cout<<cmdList[2]<<" is successfully loaded."<<endl;
         }
        else
            if(manager.loadModule(cmdList[2].c_str()))
                cout<<cmdList[2]<<" is successfully loaded."<<endl;
         reportErrors();
         return true;
     }
    */

    /**
     * run
     */
     if((cmdList.size() == 1) &&
        (cmdList[0] == "run"))
     {
         bShouldRun = run();
         reportErrors();
         return true;
     }
     if((cmdList.size() >= 2) &&
        (cmdList[0] == "run"))
     {
        bShouldRun = false;
        for(unsigned int i=1; i<cmdList.size(); i++)
            bShouldRun |= run(atoi(cmdList[i].c_str()));
        reportErrors();
        return true;
     }

    /**
     * stop
     */
     if((cmdList.size() == 1) &&
        (cmdList[0] == "stop"))
     {
         bShouldRun = false;
         stop();
         reportErrors();
         return true;
     }
     if((cmdList.size() >= 2) &&
        (cmdList[0] == "stop"))
     {
         //bShouldRun = false;
        for(unsigned int i=1; i<cmdList.size(); i++)
            stop(atoi(cmdList[i].c_str()));
         bShouldRun = !suspended();
         reportErrors();
         return true;
     }

    /**
     * kill
     */
     if((cmdList.size() == 1) &&
        (cmdList[0] == "kill"))
     {
         bShouldRun = false;
         kill();
         reportErrors();
         return true;
     }
     if((cmdList.size() >= 2) &&
        (cmdList[0] == "kill"))
     {
         //bShouldRun = false;
         for(unsigned int i=1; i<cmdList.size(); i++)
            kill(atoi(cmdList[i].c_str()));
         bShouldRun = !suspended();
         reportErrors();
         return true;
     }

    /**
     * connect
     */
     if((cmdList.size() == 1) &&
        (cmdList[0] == "connect"))
     {
         connect();
         reportErrors();
         return true;
     }
     if((cmdList.size() >= 2) &&
        (cmdList[0] == "connect"))
     {
        for(unsigned int i=1; i<cmdList.size(); i++)
            connect(atoi(cmdList[i].c_str()));
        reportErrors();
        return true;
     }


    /**
     * disconnect
     */
     if((cmdList.size() == 1) &&
        (cmdList[0] == "disconnect"))
     {
         disconnect();
         reportErrors();
         return true;
     }
     if((cmdList.size() >= 2) &&
        (cmdList[0] == "disconnect"))
     {
        for(unsigned int i=1; i<cmdList.size(); i++)
            disconnect(atoi(cmdList[i].c_str()));
        reportErrors();
        return true;
     }


    /**
     * which
     */
     if((cmdList.size() == 1) &&
        (cmdList[0] == "which"))
     {
        which();
        return true;
     }

    /**
     * check for dependencies
     */
    if((cmdList.size() == 2) &&
        (cmdList[0] == "check") && (cmdList[1] == "dep"))
    {
        if(checkDependency())
            cout<<INFO<<"All of resource dependencies are satisfied."<<ENDC<<endl;
        reportErrors();
        return true;
    }


    /**
     * check for running state
     */
    if((cmdList.size() == 3) &&
        (cmdList[0] == "check") && (cmdList[1] == "state"))
    {
        ExecutablePContainer modules = getExecutables();
        unsigned int id = (unsigned int)atoi(cmdList[2].c_str());
        if(id>=modules.size())
        {
            cout<<FAIL<<"ERROR:   "<<INFO<<"Module id is out of range."<<ENDC<<endl;
            return true;
        }

        if(running(id))
            cout<<OKGREEN<<"<RUNNING> ";
        else
            cout<<FAIL<<"<STOPPED> ";
        cout<<INFO<<"("<<id<<") ";
        cout<<modules[id]->getCommand();
        cout<<" ["<<modules[id]->getHost()<<"]"<<ENDC<<endl;
        reportErrors();
        return true;
    }
    if((cmdList.size() == 2) &&
        (cmdList[0] == "check") && (cmdList[1] == "state"))
    {
        checkStates();
        reportErrors();
        return true;
    }


    /**
     * check for connection state
     */
    if((cmdList.size() == 3) &&
        (cmdList[0] == "check") && (cmdList[1] == "con"))
    {

        CnnContainer connections  = getConnections();
        unsigned int id = (unsigned int)atoi(cmdList[2].c_str());
        if(id>=connections.size())
        {
            cout<<FAIL<<"ERROR:   "<<INFO<<"Connection id is out of range."<<ENDC<<endl;
            return true;
        }

        if(connected(id))
            cout<<OKGREEN<<"<CONNECTED> ";
        else
            cout<<FAIL<<"<DISCONNECTED> ";

        cout<<INFO<<"("<<id<<") ";
        cout<<connections[id].from()<<" - "<<connections[id].to();
                cout<<" ["<<connections[id].carrier()<<"]"<<ENDC<<endl;
        reportErrors();
        return true;
    }
    if((cmdList.size() == 2) &&
        (cmdList[0] == "check") && (cmdList[1] == "con"))
    {
        checkConnections();
        return true;
    }



    /**
     *  list available modules
     */
    if((cmdList.size() == 2) &&
        (cmdList[0] == "list") && (cmdList[1] == "mod"))
    {
        KnowledgeBase* kb = getKnowledgeBase();
        ModulePContainer mods =  kb->getModules();
        int id = 0;
        for(ModulePIterator itr=mods.begin(); itr!=mods.end(); itr++)
        {
            string fname;
            string fpath = (*itr)->getXmlFile();

            size_t pos = fpath.rfind(PATH_SEPERATOR);
            if(pos!=string::npos)
                fname = fpath.substr(pos);
            else
                fname = fpath;
            cout<<INFO<<"("<<id++<<") ";
            cout<<OKBLUE<<(*itr)->getName()<<ENDC;
            cout<<INFO<<" ["<<fname<<"]"<<ENDC<<endl;
        }
        return true;
    }


    /**
     *  list available applications
     */
    if((cmdList.size() == 2) &&
        (cmdList[0] == "list") && (cmdList[1] == "app"))
    {
        KnowledgeBase* kb = getKnowledgeBase();
        ApplicaitonPContainer apps =  kb->getApplications();
        int id = 0;
        for(ApplicationPIterator itr=apps.begin(); itr!=apps.end(); itr++)
        {
            string fname;
            string fpath = (*itr)->getXmlFile();

            size_t pos = fpath.rfind(PATH_SEPERATOR);
            if(pos!=string::npos)
                fname = fpath.substr(pos);
            else
                fname = fpath;
            cout<<INFO<<"("<<id++<<") ";
            cout<<OKBLUE<<(*itr)->getName()<<ENDC;
            cout<<INFO<<" ["<<fname<<"]"<<ENDC<<endl;
        }
        return true;
    }

    /**
     *  list available resources
     */
    if((cmdList.size() == 2) &&
        (cmdList[0] == "list") && (cmdList[1] == "res"))
    {
        KnowledgeBase* kb = getKnowledgeBase();
        ResourcePContainer resources = kb->getResources();
        int id = 0;
        for(ResourcePIterator itr=resources.begin(); itr!=resources.end(); itr++)
        {
            Computer* comp = dynamic_cast<Computer*>(*itr);
            if(comp)
            {
                string fname;
                string fpath = comp->getXmlFile();
                size_t pos = fpath.rfind(PATH_SEPERATOR);
                if(pos!=string::npos)
                    fname = fpath.substr(pos);
                else
                    fname = fpath;
                cout<<INFO<<"("<<id++<<") ";
                if(comp->getDisable())
                    cout<<WARNING<<comp->getName()<<ENDC;
                else
                    cout<<OKBLUE<<comp->getName()<<ENDC;
                cout<<INFO<<" ["<<fname<<"]"<<ENDC<<endl;
            }
        }
        return true;
    }


    /**
     *  export knowledgebase graph
     */
    if((cmdList.size() == 2) &&
        (cmdList[0] == "export") )
    {
        if(!exportDependencyGraph(cmdList[1].c_str()))
            cout<<FAIL<<"ERROR:   "<<INFO<<"Cannot export graph to "<<cmdList[1]<<"."<<ENDC<<endl;
        return true;
    }


    /**
     * show module's information
     */
    if((cmdList.size() == 3) &&
        (cmdList[0] == "show") && (cmdList[1] == "mod"))
    {
        KnowledgeBase* kb = getKnowledgeBase();
        if(!kb->getModule(cmdList[2].c_str()))
        {
            cout<<FAIL<<"ERROR:   "<<INFO<<"'"<<cmdList[2].c_str()<<"' not found."<<ENDC<<endl;
            return true;
        }
        cout<<INFO;
        PRINT_MODULE(kb->getModule(cmdList[2].c_str()));
        cout<<ENDC;
        return true;
    }

    /**
     * set an option
     */
     if((cmdList.size() == 3) &&
        (cmdList[0] == "set"))
     {
         config.unput(cmdList[1].c_str());
         config.put(cmdList[1].c_str(), cmdList[2].c_str());

        if(cmdList[1] == string("watchdog"))
        {
            if(cmdList[2] == string("yes"))
                enableWatchDog();
            else
                disableWatchod();
        }

        if(cmdList[1] == string("auto_dependency"))
        {
            if(cmdList[2] == string("yes"))
                enableAutoDependency();
            else
                disableAutoDependency();
        }

        if(cmdList[1] == string("auto_connect"))
        {
            if(cmdList[2] == string("yes"))
                enableAutoConnect();
            else
                disableAutoConnect();
        }

        if(cmdList[1] == string("color_theme"))
        {
            if(cmdList[2] == string("dark"))
                setColorTheme(THEME_DARK);
            else if(cmdList[2] == string("light"))
                setColorTheme(THEME_LIGHT);
            else
                setColorTheme(THEME_NONE);
        }

        return true;
     }


    /**
     * get an option
     */
     if((cmdList.size() == 2) &&
        (cmdList[0] == "get"))
     {
         if(config.check(cmdList[1].c_str()))
         {
            cout<<OKBLUE<<cmdList[1]<<INFO<<" = ";
            cout<<OKGREEN<<config.find(cmdList[1].c_str()).asString()<<ENDC<<endl;
         }
         else
            cout<<FAIL<<"ERROR:   "<<INFO<<"'"<<cmdList[1].c_str()<<"' not found."<<ENDC<<endl;
         return true;
     }

    /**
     * load balancing
     */
    if((cmdList.size() == 2) &&
        (cmdList[0] == "assign") && (cmdList[1] == "hosts"))
    {
        loadBalance();
        reportErrors();
        return true;
    }

    return false;
}
示例#5
0
void ModulePropertyWindow::update(Module* module)
{
    m_pModule = module;
    m_refTreeModel->clear();
    m_refModelCombos.clear();

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
//    Gtk::TreeModel::Row cchildrow;

    Glib::RefPtr<Gtk::ListStore> m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    //row = *(m_refCombo->append());
    //row[m_ColumnsCombo.m_col_choice] = "---";
    m_refModelCombos.push_back(m_refCombo);


    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pModule->getName();
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    /*
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pModule->getDescription();
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();
    */

    //node
    m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    row = *(m_refCombo->append());
    row[m_ColumnsCombo.m_col_choice] = "localhost";
    ResourcePContainer resources = m_pManager->getKnowledgeBase()->getResources();
    for(ResourcePIterator itr=resources.begin(); itr!=resources.end(); itr++)
    {
        Computer* comp = dynamic_cast<Computer*>(*itr);
        if(comp && !compareString(comp->getName(), "localhost"))
        {
            row = *(m_refCombo->append());
            row[m_ColumnsCombo.m_col_choice] = comp->getName();          
        }
    }
 
    m_refModelCombos.push_back(m_refCombo);
    
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Node";
    row[m_Columns.m_col_value] = m_pModule->getHost();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Stdio";
    row[m_Columns.m_col_value] = m_pModule->getStdio();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    m_refModelCombos.push_back(m_refCombo);

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Workdir";
    row[m_Columns.m_col_value] = m_pModule->getWorkDir();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Prefix";
    row[m_Columns.m_col_value] = m_pModule->getBasePrefix();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    //Deployer
    m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    if(compareString(m_pModule->getBroker(), "yarpdev"))
    {
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "yarpdev";
    }
    else if(compareString(m_pModule->getBroker(), "icubmoddev"))
    {
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "icubmoddev";
    }
    else
    {
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "local";
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "yarprun";
    }
    m_refModelCombos.push_back(m_refCombo);

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Deployer";
    if(strlen(m_pModule->getBroker()))
        row[m_Columns.m_col_value] = m_pModule->getBroker();
    else if(compareString(m_pModule->getHost(), "localhost"))
        row[m_Columns.m_col_value] = "local";
        
    if(m_pModule->getNeedDeployer())
    {  
        row[m_Columns.m_col_editable] = false;
        row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    }    
    else
        row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Parameters";
    row[m_Columns.m_col_value] = m_pModule->getParam();
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    for(int i=0; i<m_pModule->argumentCount(); i++)
    {
        Gtk::TreeModel::Row comboRow;
        m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
        comboRow = *(m_refCombo->append());
        if(!m_pModule->getArgumentAt(i).isSwitch())
            comboRow[m_ColumnsCombo.m_col_choice] = m_pModule->getArgumentAt(i).getDefault();
        else
        {
            comboRow[m_ColumnsCombo.m_col_choice] = "on";    
            comboRow = *(m_refCombo->append());
            comboRow[m_ColumnsCombo.m_col_choice] = "off";
        }
        m_refModelCombos.push_back(m_refCombo);
     
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam();
        childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getValue();
        Glib::ustring strval = childrow[m_Columns.m_col_value];
        if(m_pModule->getArgumentAt(i).isRequired() 
            && !strval.size())
            childrow[m_Columns.m_col_color_item] = Gdk::Color("#BF0303");
        childrow[m_Columns.m_col_editable] = true;
        childrow[m_Columns.m_col_choices] = m_refModelCombos.back();
    }
    
    //updateParamteres();

    m_TreeView.expand_all();

}
void PropertiesTable::showModuleTab(Module *mod)
{
    modules.clear();
    disconnect(moduleProperties,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(onModItemChanged(QTreeWidgetItem*,int)));
    disconnect(moduleProperties,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onModItemDoubleClicked(QTreeWidgetItem*,int)));

    currentApplication = NULL;
    currentModule = mod;
    propertiesTab->clear();
    propertiesTab->addTab(moduleProperties,"Module Properties");
    propertiesTab->addTab(moduleDescription,"Description");
    moduleProperties->clear();
    moduleDescription->clear();

    appProperties->hide();
    moduleProperties->show();
    moduleDescription->show();

    modName = new QTreeWidgetItem(moduleProperties,QStringList() << "Name" << mod->getName());
    modNode = new QTreeWidgetItem(moduleProperties,QStringList() << "Node");
    modStdio = new QTreeWidgetItem(moduleProperties,QStringList() << "Stdio" << mod->getStdio());
    modWorkDir = new QTreeWidgetItem(moduleProperties,QStringList() << "Workdir" << mod->getWorkDir());
    modPrefix = new QTreeWidgetItem(moduleProperties,QStringList() << "Prefix" << mod->getBasePrefix());
    modDeployer = new QTreeWidgetItem(moduleProperties,QStringList() << "Deployer");
    modParams = new QTreeWidgetItem(moduleProperties,QStringList() << "Parameters" << mod->getParam());

    lastPrefix = mod->getBasePrefix();

    modStdio->setFlags(modStdio->flags() | Qt::ItemIsEditable);
    modWorkDir->setFlags(modWorkDir->flags() | Qt::ItemIsEditable);
    modPrefix->setFlags(modPrefix->flags() | Qt::ItemIsEditable);

    moduleProperties->addTopLevelItem(modName);
    moduleProperties->addTopLevelItem(modNode);
    moduleProperties->addTopLevelItem(modStdio);
    moduleProperties->addTopLevelItem(modWorkDir);
    moduleProperties->addTopLevelItem(modPrefix);
    moduleProperties->addTopLevelItem(modDeployer);
    moduleProperties->addTopLevelItem(modParams);

    if(deployerCombo){
        delete deployerCombo;
        deployerCombo = NULL;
    }

    if(nodeCombo){
        delete nodeCombo;
        nodeCombo = NULL;
    }
    deployerCombo = new QComboBox();
    nodeCombo = new QComboBox();

    deployerCombo->setEditable(true);
    nodeCombo->setEditable(true);

    if(compareString(mod->getBroker(),"yarpdev")){
        deployerCombo->addItem("yarpdev");
    }else if(compareString(mod->getBroker(),"icubmoddev")){
        deployerCombo->addItem("icubmoddev");
    }else{
        deployerCombo->addItem("local");
        deployerCombo->addItem("yarprun");
    }

    if(strlen(mod->getBroker())){
        deployerCombo->setCurrentText(mod->getBroker());
    }else if(compareString(mod->getHost(),"localhost")){
        deployerCombo->setCurrentText("local");
    }
    if(mod->getNeedDeployer()){
        deployerCombo->setEditable(false);
    }


    nodeCombo->addItem(mod->getHost());
    if(QString(mod->getHost()) != "localhost"){
        nodeCombo->addItem("localhost");
    }
    ResourcePContainer resources = manager->getKnowledgeBase()->getResources();
    for(ResourcePIterator itr=resources.begin(); itr!=resources.end(); itr++){
        Computer* comp = dynamic_cast<Computer*>(*itr);
        if(comp && !compareString(comp->getName(), "localhost")){
            nodeCombo->addItem(comp->getName());
        }
    }
    connect(nodeCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map()));
    connect(nodeCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map()));
    paramsSignalMapper->setMapping(nodeCombo,nodeCombo);

    connect(deployerCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map()));
    connect(deployerCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map()));
    paramsSignalMapper->setMapping(deployerCombo,deployerCombo);




     /*****************************/
     // Populate paramters
     for(int i=0;i<mod->argumentCount();i++){
         Argument a = mod->getArgumentAt(i);
         QTreeWidgetItem *it = new QTreeWidgetItem(modParams,QStringList() << a.getParam());
         QComboBox *paramCombo = new QComboBox();
         paramCombo->setEditable(true);
         paramCombo->addItem(a.getValue());
         if(strcmp(a.getDefault(),a.getValue()) != 0 ){
            paramCombo->addItem(a.getDefault());
         }
         moduleProperties->setItemWidget(it,1,paramCombo);
         connect(paramCombo, SIGNAL(editTextChanged(QString)), paramsSignalMapper, SLOT(map()));
         connect(paramCombo, SIGNAL(currentIndexChanged(int)), paramsSignalMapper, SLOT(map()));
         paramsSignalMapper->setMapping(paramCombo,paramCombo);
     }
     /*****************************/

    moduleProperties->setItemWidget(modDeployer,1,deployerCombo);
    moduleProperties->setItemWidget(modNode,1,nodeCombo);
    modParams->setExpanded(true);


    QTreeWidgetItem *nameItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Name" << mod->getName());
    QTreeWidgetItem *versionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Version" << mod->getVersion());
    QTreeWidgetItem *descriptionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Description" << mod->getDescription());
    QTreeWidgetItem *parametersItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Parameters");
    for(int i=0;i<mod->argumentCount();i++){
        Argument a = mod->getArgumentAt(i);
        QTreeWidgetItem *it = new QTreeWidgetItem(parametersItem,QStringList() << a.getParam() << a.getDescription());

    }

    QTreeWidgetItem *authorsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Authors" );
    for(int i=0;i<mod->authorCount();i++){
        Author a = mod->getAuthorAt(i);
        QTreeWidgetItem *it = new QTreeWidgetItem(authorsItem,QStringList() << a.getName() << a.getEmail());
    }

    QTreeWidgetItem *inputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Inputs" );
    for(int i=0;i<mod->inputCount();i++){
        InputData a = mod->getInputAt(i);

        QTreeWidgetItem *type = new QTreeWidgetItem(inputsItem,QStringList() << "Type" << a.getName());
        QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
        QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription());
        QTreeWidgetItem *req = new QTreeWidgetItem(type,QStringList() << "Required" << (a.isRequired() ? "yes" : "no"));
        Q_UNUSED(port);
        Q_UNUSED(desc);
        Q_UNUSED(req);
    }

    QTreeWidgetItem *outputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Outputs" );
    for(int i=0;i<mod->outputCount();i++){
        OutputData a = mod->getOutputAt(i); //TODO controllare

        QTreeWidgetItem *type = new QTreeWidgetItem(outputsItem,QStringList() << "Type" << a.getName());
        QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
        QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription());
        Q_UNUSED(port);
        Q_UNUSED(desc);
    }

    moduleDescription->addTopLevelItem(nameItem);
    moduleDescription->addTopLevelItem(versionItem);
    moduleDescription->addTopLevelItem(descriptionItem);
    moduleDescription->addTopLevelItem(parametersItem);
    moduleDescription->addTopLevelItem(authorsItem);
    moduleDescription->addTopLevelItem(inputsItem);
    moduleDescription->addTopLevelItem(outputsItem);

    connect(moduleProperties,SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(onModItemChanged(QTreeWidgetItem*,int)));
    connect(moduleProperties,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this,SLOT(onModItemDoubleClicked(QTreeWidgetItem*,int)));

}