void ConfigFileWriter::writeRouterModelFile(std::string filename, NodeSet& ns) { std::fstream out; std::set<std::string>::iterator it = ns.modelsUsed().begin(); if (it != ns.modelsUsed().end()) { out.open(filename.c_str(), std::fstream::out | std::fstream::trunc); } while (it != ns.modelsUsed().end()) { ParameterMap* parameters = Config::instance().getModelParameterList(*it); const Parameter& model = parameters->getParameter("ROUTER-MODEL"); if (model != Parameter::unknownParameter) { out << model << std::endl; ParameterMap::iterator pit = parameters->begin(); while (pit != parameters->end()) { if (pit->first != "ROUTER-MODEL") out << pit->second << std::endl; pit++; } out << std::endl; } it++; } }
bool CSVWriter::init(const ParameterMap& params, const Ports<StreamInfo>& inp) { assert(inp.size()==1); const StreamInfo& in = inp[0].data; string outputFile = getStringParam("File", params); m_precision = getIntParam("Precision",params); if (m_precision > (BUFSIZE-10)) { cerr << "WARNING: precision is too large ! use precision " << BUFSIZE - 10 << endl; m_precision = BUFSIZE - 10; } int res = preparedirs(outputFile.c_str()); if (res!=0) return false; m_fout.open(outputFile.c_str(), ios_base::trunc); if (!m_fout.is_open() || m_fout.bad()) return false; if (getStringParam("Metadata",params)=="True") { // write metadata at the beginnig of the file string paramStr = getStringParam("Attrs",params); map<string,string> params = decodeAttributeStr(paramStr); ostringstream oss; for (map<string,string>::const_iterator it=params.begin();it!=params.end();it++) oss << "% " << it->first << "=" << it->second << endl; m_fout.write(oss.str().c_str(),oss.str().size()); } return true; }
bool SpecificWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { printf("<<< setParametersAndPossibleActivation\n"); // We didn't reactivate the component reactivated = false; // Update parameters params.clear(); for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { printf("param:%s value:%s\n", it->first.c_str(), it->second.value.c_str()); params[it->first] = it->second; } printf("----\n"); try { action = ""; for (uint i=0; i<params["action"].value.size(); i++) { action += params["action"].value[i]; if (i+2<params["action"].value.size()) { if (params["action"].value[i+1] == '_' and params["action"].value[i+2] == '_') break; } } std::transform(action.begin(), action.end(), action.begin(), ::tolower); // // action = params["action"].value; if (action == "graspobject") { active = true; } else { active = true; } } catch (...) { printf("exception in setParametersAndPossibleActivation %d\n", __LINE__); return false; } // Check if we should reactivate the component if (active) { active = true; reactivated = true; } printf("setParametersAndPossibleActivation >>>\n"); return true; }
bool SpecificWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { printf("<<< setParametersAndPossibleActivation\n"); // We didn't reactivate the component reactivated = false; // Update parameters params.clear(); for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { params[it->first] = it->second; } try { action = params["action"].value; std::transform(action.begin(), action.end(), action.begin(), ::tolower); //TYPE YOUR ACTION NAME if (action == "actionname") { active = true; } else { active = true; } } catch (...) { printf("exception in setParametersAndPossibleActivation %d\n", __LINE__); return false; } // Check if we should reactivate the component if (active) { active = true; reactivated = true; } printf("setParametersAndPossibleActivation >>>\n"); return true; }
bool GenericWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { // We didn't reactivate the component reactivated = false; // Update parameters for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { params[it->first] = it->second; } try { // Action p.action = createAction(params["action"].value); // Fill received plan p.plan.clear(); QStringList actionList = QString::fromStdString(params["plan"].value).split(QRegExp("[()]+"), QString::SkipEmptyParts); for (int32_t actionString=0; actionString<actionList.size(); actionString++) { std::vector<string> elementsVec; QStringList elements = actionList[actionString].remove(QChar('\n')).split(QRegExp("\\s+"), QString::SkipEmptyParts); for (int32_t elem=0; elem<elements.size(); elem++) { elementsVec.push_back(elements[elem].toStdString()); } p.plan.push_back(elementsVec); } } catch (...) { return false; } // Check if we should reactivate the component if (isActive()) { activate(p); reactivated = true; } return true; }
bool SpecificWorker::setParametersAndPossibleActivation(const ParameterMap &prs, bool &reactivated) { // We didn't reactivate the component reactivated = false; // Update parameters params.clear(); for (ParameterMap::const_iterator it=prs.begin(); it!=prs.end(); it++) { params[it->first] = it->second; } try { action = params["action"].value; std::transform(action.begin(), action.end(), action.begin(), ::tolower); if (action == "findobjectvisually") { active = true; } else { active = true; } } catch (...) { return false; } // Check if we should reactivate the component if (active) { active = true; reactivated = true; } return true; }
int LuaBinding::ActorAdd() { const char* actorAlias = NULL; Vector2i actorPosition; if (!Peek(1, &actorAlias) || !Peek(2, &actorPosition)) { return ERROR_TYPE_PARAMETER; } const char* actorName = NULL; Peek(3, &actorName); ParameterMap parameters; Peek(4, ¶meters); IWorldContext* worldContext = System::QueryWorldContext(); if (worldContext == NULL) { return ERROR_TYPE_STATE; } const boost::shared_ptr<Actor> actor = worldContext->AddActor(actorAlias, actorPosition, actorName).lock(); if (!actor) { return ERROR_TYPE_STATE; } const boost::shared_ptr<ActorPropertyScript> property = actor->GetProperty<ActorPropertyScript>().lock(); if (property) { for (ParameterMap::iterator iter = parameters.begin(); iter != parameters.end(); ++iter) { property->SetParameter(iter->first.c_str(), iter->second); } } Push(actor->GetId()); return 1; }
void printParams(ostream& out, const ParameterMap& params) { for (ParameterMap::const_iterator pit=params.begin(); pit!=params.end(); pit++) out << " " << pit->first << "=\"" << pit->second << "\""; }