int main(int argc, char ** argv) { size_t len = rand() % 200; uint maxv = 50 + rand() % 50; Array a(len,maxv); for(uint i=0;i<len;i++) { a.setField(i,rand()%maxv); } Mapper * mapper = new MapperCont(a, BitSequenceBuilderRG(20)); Mapper * mapper2 = new MapperNone(); mapper->use(); mapper2->use(); cout << "Test 1 : Wavelet tree with pointers" << endl; /*WaveletTree wt1(a,new wt_coder_huff(a, mapper),new BitSequenceBuilderDArray(), mapper);*/ WaveletTree wt1(a,new wt_coder_binary(a, mapper),new BitSequenceBuilderRG(20), mapper); cout << "bs.size() = " << wt1.getSize() << endl; testQuantileWT(a, wt1); cout << "Test 2 : Wavelet tree without pointers" << endl; WaveletTreeNoptrs wt3(a, new BitSequenceBuilderRRR(32), mapper); cout << "bs.size() = " << wt3.getSize() << endl; testQuantileWTNPTR(a, wt3); mapper->unuse(); mapper2->unuse(); fprintf(stdout,"ALL OK\n"); return 0; }
void Master::distributeSynapses(const Mapper& mapper, const network::Generator& net) { typedef std::vector<Synapse> svector; svector input; // dummy std::vector<svector> output(m_world.size()); unsigned queued = 0; //! \todo pass this in const unsigned bufferSize = 2 << 11; for(network::synapse_iterator s = net.synapse_begin(); s != net.synapse_end(); ++s, ++queued) { int sourceRank = mapper.rankOf(s->source); int targetRank = mapper.rankOf(s->target()); output.at(sourceRank).push_back(*s); if(sourceRank != targetRank) { output.at(targetRank).push_back(*s); } if(queued == bufferSize) { flushBuffer(SYNAPSE_VECTOR, input, output, m_world); queued = 0; } } flushBuffer(SYNAPSE_VECTOR, input, output, m_world); int tag = SYNAPSES_END; broadcast(m_world, tag, MASTER); }
/*! \brief Called by the vtkMitkRenderProp in order to start MITK rendering process. */ int mitk::VtkPropRenderer::Render(mitk::VtkPropRenderer::RenderType type) { // Do we have objects to render? if (this->GetEmptyWorldGeometry()) return 0; if (m_DataStorage.IsNull()) return 0; // Update mappers and prepare mapper queue if (type == VtkPropRenderer::Opaque) this->PrepareMapperQueue(); // go through the generated list and let the sorted mappers paint for (auto it = m_MappersMap.cbegin(); it != m_MappersMap.cend(); it++) { Mapper *mapper = (*it).second; mapper->MitkRender(this, type); } // Render text if (type == VtkPropRenderer::Overlay) { if (m_TextCollection.size() > 0) { m_TextRenderer->SetViewport(this->GetVtkRenderer()->GetViewport()); for (auto it = m_TextCollection.begin(); it != m_TextCollection.end(); ++it) m_TextRenderer->AddViewProp((*it).second); m_TextRenderer->Render(); } } return 1; }
/*! \brief Called by the vtkMitkRenderProp in order to start MITK rendering process. */ int mitk::VtkPropRenderer::Render(mitk::VtkPropRenderer::RenderType type) { // Do we have objects to render? if ( this->GetEmptyWorldGeometry()) return 0; if ( m_DataStorage.IsNull()) return 0; // Update mappers and prepare mapper queue if (type == VtkPropRenderer::Opaque) this->PrepareMapperQueue(); //go through the generated list and let the sorted mappers paint bool lastVtkBased = true; //bool sthVtkBased = false; for(MappersMapType::iterator it = m_MappersMap.begin(); it != m_MappersMap.end(); it++) { Mapper * mapper = (*it).second; VtkMapper* vtkmapper = dynamic_cast<VtkMapper*>(mapper); if(vtkmapper) { //sthVtkBased = true; if(!lastVtkBased) { Disable2DOpenGL(); lastVtkBased = true; } } else if(lastVtkBased) { Enable2DOpenGL(); lastVtkBased = false; } mapper->MitkRender(this, type); } this->UpdateOverlays(); if (lastVtkBased == false) Disable2DOpenGL(); // Render text if (type == VtkPropRenderer::Overlay) { if (m_TextCollection.size() > 0) { m_TextRenderer->SetViewport( this->GetVtkRenderer()->GetViewport() ); for (TextMapType::iterator it = m_TextCollection.begin(); it != m_TextCollection.end() ; it++) m_TextRenderer->AddViewProp((*it).second); m_TextRenderer->Render(); } } return 1; }
int solveGenerique(diet_profile_t* pb) { std::string authKey; std::string machineId; std::string optionValueSerialized; std::string listSerialized = ""; //IN Parameters diet_string_get(pb,0, authKey); diet_string_get(pb,1, machineId); diet_string_get(pb,2, optionValueSerialized); // reset profile to handle result diet_profile_reset(pb, 2); QueryParameters* options = NULL; List* list = NULL; try { //To parse the object serialized if (! vishnu::parseEmfObject(optionValueSerialized, options)) { throw TMSVishnuException(ERRCODE_INVALID_PARAM); } QueryType query(authKey); //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME); int mapperkey = mapper->code(query.getCommandName()); mapper->code(optionValueSerialized, mapperkey); std::string cmd = mapper->finalize(mapperkey); list = query.list(options); ::ecorecpp::serializer::serializer _ser; listSerialized = _ser.serialize_str(list); //OUT Parameter diet_string_set(pb,0, "success"); diet_string_set(pb,1, listSerialized); FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, ""); } catch (VishnuException& ex) { try { FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, ""); } catch (VishnuException& fe) { ex.appendMsgComp(fe.what()); } diet_string_set(pb,0, "error"); diet_string_set(pb,1, ex.what()); } delete options; delete list; return 0; }
void MappingManager::close(Mapper& mapper) { if(mapper.hasRules()) { bool ret = mapper.init() && mapper.close(); mapper.uninit(); if (ret) log(str(boost::format("Successfully removed port mappings from the %1% device with the %2% interface") % deviceString(mapper) % mapper.getName()), LogManager::LOG_INFO); else log(str(boost::format("Failed to remove port mappings from the %1% device with the %2% interface") % deviceString(mapper) % mapper.getName()), LogManager::LOG_WARNING); } }
/** * \brief Function to solve the jobSubmit service * \param pb is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveSubmitJob(diet_profile_t* pb) { std::string scriptContent; std::string machineId; std::string jsonEncodedOptions; std::string authKey; // get profile parameters diet_string_get(pb,0, authKey); diet_string_get(pb,1, machineId); diet_string_get(pb,2, scriptContent); diet_string_get(pb,3, jsonEncodedOptions); // reset the profile to send back result diet_profile_reset(pb, 2); try { JsonObject options(jsonEncodedOptions); std::string scriptPath = options.getStringProperty("scriptpath"); //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME); int mapperkey = mapper->code("vishnu_submit_job"); mapper->code(scriptPath, mapperkey); mapper->code(jsonEncodedOptions, mapperkey); std::string cmd = mapper->finalize(mapperkey); //FIXME: decode job and options ServerXMS* server = ServerXMS::getInstance(); JobServer jobServer(authKey, machineId, server->getSedConfig()); jobServer.setDebugLevel(server->getDebugLevel()); // Set the debug level std::string jobId = jobServer.submitJob(scriptContent, & options, server->getDefaultBatchOption()); diet_string_set(pb,0, "success"); diet_string_set(pb,1, JsonObject::serialize(jobServer.getJobInfo(jobId))); FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, jobId); } catch (VishnuException& ex) { try { FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, ""); } catch (VishnuException& fe) { ex.appendMsgComp(fe.what()); } diet_string_set(pb,0, "error"); diet_string_set(pb,1, ex.what()); } return 0; }
void dump_map(const Mapper&map, const char*file){ FILE* f = fopen(file, "w"); for(int y=0; y<map.height(); ++y){ for(int x=0; x<map.width(); ++x){ fprintf(f, "%5d", map(xyLoc{static_cast<std::int16_t>(x), static_cast<std::int16_t>(y)})); } fprintf(f, "\n"); } fclose(f); }
/** * \brief Function to list commands information * \return The pointer to the UMS_Data::ListCommands containing commands information * \return raises an exception on error */ UMS_Data::ListCommands* list(UMS_Data::ListCmdOptions_ptr option) { std::string query; std::vector<std::string>::iterator ii; std::vector<std::string> results; std::string description; query = "SELECT DISTINCT ctype, vsessionid, name, description, starttime, endtime, command.status" " FROM vsession, clmachine, command, users" " WHERE vsession.numsessionid=command.vsession_numsessionid" " AND vsession.clmachine_numclmachineid=clmachine.numclmachineid" " AND vsession.users_numuserid=users.numuserid"; UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance(); mlistObject = ecoreFactory->createListCommands(); //Creation of the object user UserServer userServer = UserServer(msessionServer); userServer.init(); //if the user exists if (!userServer.exist()) { UMSVishnuException e (ERRCODE_UNKNOWN_USER); throw e; } processOptions(userServer, option, query); query.append(" order by starttime"); //To get the list of commands from the database boost::scoped_ptr<DatabaseResult> ListOfCommands (mdatabase->getResult(query.c_str())); for (size_t i = 0; i < ListOfCommands->getNbTuples(); ++i) { results.clear(); results = ListOfCommands->get(i); ii = results.begin(); UMS_Data::Command_ptr command = ecoreFactory->createCommand(); vishnu::CmdType currentCmdType = static_cast<vishnu::CmdType>(vishnu::convertToInt(*ii)); command->setCommandId(convertCmdType(static_cast<vishnu::CmdType>(currentCmdType))); command->setSessionId(*(++ii)); command->setMachineId(*(++ii)); //MAPPER CREATION Mapper* mapper = MapperRegistry::getInstance()->getMapper(convertypetoMapperName(currentCmdType)); description = mapper->decode(*(++ii)); command->setCmdDescription(description); command->setCmdStartTime(convertToTimeType(*(++ii))); command->setCmdEndTime(convertToTimeType(*(++ii))); command->setStatus(vishnu::convertToInt(*(++ii))); mlistObject->getCommands().push_back(command); } return mlistObject; }
/** * \brief Function to solve the getListOfQueues service * \param pb is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveListOfQueues(diet_profile_t* pb) { std::string authKey; std::string machineId; std::string optionSerialized; std::string listQueuesSerialized; diet_string_get(pb,0, authKey); diet_string_get(pb,1, machineId); diet_string_get(pb,2, optionSerialized); // reset profile to handle result diet_profile_reset(pb, 2); TMS_Data::ListQueues_ptr listQueues = NULL; ListQueuesServer queryQueues(authKey, ServerXMS::getInstance()->getBatchType(), ServerXMS::getInstance()->getBatchVersion(), optionSerialized); try { //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME); int mapperkey = mapper->code("vishnu_list_queues"); mapper->code(machineId, mapperkey); mapper->code(optionSerialized, mapperkey); std::string cmd = mapper->finalize(mapperkey); listQueues = queryQueues.list(); ::ecorecpp::serializer::serializer _ser; listQueuesSerialized = _ser.serialize_str(listQueues); diet_string_set(pb,0, "success"); diet_string_set(pb,1, listQueuesSerialized); FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, ""); } catch (VishnuException& ex) { try { FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, ""); } catch (VishnuException& fe) { ex.appendMsgComp(fe.what()); } diet_string_set(pb,0, "error"); diet_string_set(pb,1, ex.what()); } return 0; }
void distributeFiringStimulus( const Mapper& mapper, const std::vector<unsigned>& fstim, std::vector<SimulationStep>& reqs) { for(std::vector<unsigned>::const_iterator i = fstim.begin(); i != fstim.end(); ++i) { nidx_t neuron = nidx_t(*i); assert(unsigned(mapper.rankOf(neuron) - 1) < reqs.size()); reqs.at(mapper.rankOf(neuron) - 1).forceFiring(neuron); } }
int main(int argc, char *argv[]) { if(argc == 2) { string filename(argv[1]); Mapper mapper; mapper.Start(false); mapper.SaveMap(filename); } else { cout << "Please supply the filename of the map to save." << endl; } }
int main(int argc, char **argv) { ros::init(argc, argv, "MapperNode"); ros::NodeHandle n; // create the mapper Mapper mapper; if ((argc > 1) && (strcmp(argv[1], "phase2") == 0)) { mapper.readMap(); mapper.setToLocalize(); } // create subscriber for distances ros::Subscriber dist_sub = n.subscribe("/amee/sensors/irdistances", 100, &Mapper::receive_distances, &mapper); ros::Subscriber odo_sub = n.subscribe("/amee/motor_control/odometry", 100, &Mapper::receiveOdometry, &mapper); ros::Subscriber state_sub = n.subscribe("/amee/follow_wall_states",10, &Mapper::receive_FollowWallState, &mapper); ros::Subscriber tag_sub = n.subscribe("/amee/tag",10, &Mapper::receive_tag, &mapper); ros::Subscriber command_sub = n.subscribe("/amee/map/mapper_commands",10, &Mapper::receive_MapperCommand, &mapper); ros::Publisher pose_pub = n.advertise<amee::Pose>("/amee/pose",5); ros::Publisher marker_pub = n.advertise<amee::MapVisualization>("/amee/map/visualization", 10); ros::Publisher graph_pub = n.advertise<amee::GraphMsg>("/amee/map/graph",10); ros::Publisher node_pub = n.advertise<amee::MapperEvent>("/amee/map/mapper_events",10); mapper.setVisualizationPublisher(marker_pub); mapper.setGraphPublisher(graph_pub); mapper.setPosePublisher(pose_pub); mapper.setNodePublisher(node_pub); ros::Rate loop_rate(30); //30 // testWallSegment(); while(ros::ok()){ // go to sleep for a short while loop_rate.sleep(); // call all callbacks ros::spinOnce(); // // map! mapper.doMapping(); // mapTest(marker_pub); } mapper.saveMap(); return 0; }
/** * \brief Function to solve the File transfer stop service * \param pb is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveFileTransferStop(diet_profile_t* pb) { char* sessionKey = NULL; char* optionsSerialized = NULL; std::string finishError =""; int mapperkey; std::string cmd = ""; std::string errorInfo =""; diet_string_get(diet_parameter(pb,0), &sessionKey, NULL); diet_string_get(diet_parameter(pb,1), &optionsSerialized, NULL); SessionServer sessionServer = SessionServer(std::string(sessionKey)); FMS_Data::StopTransferOptions_ptr options_ptr = NULL; try { //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(FMSMAPPERNAME); mapperkey = mapper->code("vishnu_stop_file_transfer"); mapper->code(std::string(optionsSerialized), mapperkey); cmd = mapper->finalize(mapperkey); if(!vishnu::parseEmfObject(std::string(optionsSerialized), options_ptr)) { SystemException(ERRCODE_INVDATA, "solve_fileTransferStop: options object is not well built"); } int vishnuId=ServerFMS::getInstance()->getVishnuId(); boost::shared_ptr<FileTransferServer> fileTransferServer(new FileTransferServer(sessionServer,vishnuId)); fileTransferServer->stopThread(*options_ptr); diet_string_set(diet_parameter(pb,2), strdup(errorInfo.c_str()), DIET_VOLATILE); sessionServer.finish(cmd, FMS, vishnu::CMDSUCCESS); } catch (VishnuException& e) { try { sessionServer.finish(cmd, FMS, vishnu::CMDFAILED); } catch (VishnuException& fe) { finishError = fe.what(); finishError +="\n"; } e.appendMsgComp(finishError); errorInfo = e.buildExceptionString(); diet_string_set(diet_parameter(pb,2), strdup(errorInfo.c_str()), DIET_VOLATILE); } return 0; }
void line(int x0,int y0, int x1, int y1, Mapper & mapper ) { int dx = std::abs(x1-x0); int dy = std::abs(y1-y0); int sx,sy,err; if (x0 < x1 ) { sx = 1; } else { sx = -1; } if (y0 < y1) { sy = 1; } else { sy = -1; } err = dx-dy; while(1) { mapper.map(x0,y0); if (x0 == x1 && y0 == y1) { break; } int e2 = 2*err; if (e2 > -dy) { err = err - dy; x0 = x0 + sx; } if (e2 < dx ) { err = err + dx; y0 = y0 + sy; } } }
/** * \brief Construct from a vector and a name. * * \param gv GridView to operate on (used to instantiate a * MultipleCodimMultipleGeomeTypeMapper, otherwise no * reference or copy is stored). Note that this must be the * GridView the vector applies to as well as the GridView * later used by the VTKWriter -- i.e. we do not implicitly * restrict or prolongate the data. * \param v_ Reference to the vector holding the data. The reference * is stored internally and must be valid for as long as * this functions evaluate method is used. * \param s_ Name of this function in the VTK file. * \param ncomps Number of components of the field represented by the * vector. */ P0VectorVTKFunction(const GV &gv, const V &v_, const std::string &s_, int ncomps = 1) : v(v_), s(s_), ncomps_(ncomps), mapper(gv) { if (v.size() != (unsigned int)(mapper.size() * ncomps_)) DUNE_THROW(Dune::IOError, "VectorP0VTKFunction: size mismatch"); }
/** * \brief Function to solve the File transfer stop service * \param profile is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveFileTransferStop(diet_profile_t* profile) { std::string sessionKey = ""; std::string optionsSerialized = ""; std::string cmd = ""; diet_string_get(profile,0, sessionKey); diet_string_get(profile,1, optionsSerialized); // reset the profile to handle result diet_profile_reset(profile, 2); SessionServer sessionServer = SessionServer(sessionKey); try { //MAPPER CREATION int mapperkey; Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::FMSMAPPERNAME); mapperkey = mapper->code("vishnu_stop_file_transfer"); mapper->code(optionsSerialized, mapperkey); cmd = mapper->finalize(mapperkey); FMS_Data::StopTransferOptions_ptr options_ptr = NULL; if(! vishnu::parseEmfObject(optionsSerialized, options_ptr)) { SystemException(ERRCODE_INVDATA, "solveFileTransferStop: options object is not well built"); } FileTransferServer fileTransferServer(sessionServer, ServerXMS::getInstance()->getVishnuId()); fileTransferServer.stopThread(*options_ptr); delete options_ptr; // set success result diet_string_set(profile, 0, "success"); diet_string_set(profile, 1, ""); sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDSUCCESS); } catch (VishnuException& err) { try { sessionServer.finish(cmd, vishnu::FMS, vishnu::CMDFAILED); } catch (VishnuException& fe) { err.appendMsgComp(fe.what()); } // set error result diet_string_set(profile, 0, "error"); diet_string_set(profile, 1, err.what()); } return 0; }
int main(int argc, char ** argv) { if(argc!=4) { cout << "Checks the array class generating <length> elements between 0 and <maxv> using <seed> as seed for the numbers generation" << endl << endl; cout << "usage: " << argv[0] << " <seed> <length> <maxv>" << endl; return 0; } srand(transform(string(argv[1]))); uint len = transform(string(argv[2])); uint maxv = transform(string(argv[3])); //cout << "maxv = " << maxv << endl; //cout << "len = " << len << endl; Array a(len,maxv); for(uint i=0;i<len;i++) { a.setField(i,rand()%maxv); } //BitmapsSequence bs(a,new MapperNone(),new BitSequenceBuilderRRR(33)); //testSequence(a, bs); Mapper * mapper = new MapperCont(a, BitSequenceBuilderRG(20)); Mapper * mapper2 = new MapperNone(); mapper->use(); mapper2->use(); cout << "Test 1 : Wavelet tree with pointers" << endl; // WaveletTree wt1(a,new wt_coder_binary(a, mapper),new BitSequenceBuilderRRR(32), mapper); WaveletTreeNoptrs wt1(a, new BitSequenceBuilderRRR(32), mapper); cout << "bs.size() = " << wt1.getSize() << endl; testSequence(a, wt1); cout << "Test 2 : Wavelet tree without pointers" << endl; // uint *tmp = new uint[a.getLength()]; // for (uint i=0; i < a.getLength(); i++) // tmp[i] = a.getField(i); // WaveletMatrix wt3(tmp, a.getLength(), new BitSequenceBuilderRRR(32), mapper); WaveletMatrix wt3(a, new BitSequenceBuilderRRR(32), mapper); // WaveletTreeNoptrs wt3(tmp, a.getLength(), new BitSequenceBuilderRRR(32), mapper); cout << "bs.size() = " << wt3.getSize() << endl; testSequence(a, wt3); mapper->unuse(); mapper2->unuse(); return 0; }
int ShellExporter::exporte(string oldSession, string &content){ vector<string>::iterator iter; vector<string> line; // Init the script content = "#!/bin/sh"; content += " \n"; // Check the user is alloed to export if (!muser.isAdmin() && !isAllowed(oldSession, muser)){ throw IMSVishnuException(ERRCODE_INVEXPORT, "The user is not allowed to export this session"); } // Check the session is closed if (!isClosed(oldSession)) { throw IMSVishnuException(ERRCODE_INVEXPORT, "The session id is invalid"); } // The request, ordered by starttime (=submission) string req = "SELECT command.ctype, command.description, command.starttime from " " command, vsession where vsession.numsessionid=command.vsession_numsessionid and " " vsession.vsessionid='"+oldSession+"' order by starttime asc"; boost::scoped_ptr<DatabaseResult> result (mdatabase->getResult(req.c_str())); // Adding all the results to the content for (size_t i = 0 ; i<result->getNbTuples(); i++) { line.clear(); line = result->get(i); iter = line.begin(); //MAPPER CREATION try { CmdType type = static_cast<CmdType>(convertToInt(*iter)); Mapper* mapper = MapperRegistry::getInstance()->getMapper(getMapperName(type)); content += mapper->decode(*(++iter)); } catch (SystemException &e) { throw (e); } content += " \n"; } return 0; }
void prepare(Mapper& mapper, Visitor& visitor, Envelope const& envelope, double box_buffer_distance) { #ifdef BOOST_GEOMETRY_BUFFER_TEST_SVG_USE_ALTERNATE_BOX // Create a zoomed-in view bg::model::box<Point> alternate_box; bg::read_wkt(BOOST_GEOMETRY_BUFFER_TEST_SVG_ALTERNATE_BOX, alternate_box); mapper.add(alternate_box); // Take care non-visible elements are skipped visitor.set_alternate_box(alternate_box); set_alternate_box(alternate_box); #else bg::model::box<Point> box = envelope; bg::buffer(box, box, box_buffer_distance); mapper.add(box); #endif boost::ignore_unused(visitor); }
basic_fm_index( string_type &string, Mapper &map, typename Mapper::is_mapper *p=0 ) : string_(&string), bwt_(map), inverse_sa0_((size_t)map.read64()) { }
/** * \brief Function to solve the jobInfo service * \param pb is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveJobInfo(diet_profile_t* pb) { std::string authKey; std::string machineId; std::string jobId; //IN Parameters diet_string_get(pb, 0, authKey); diet_string_get(pb, 1, machineId); diet_string_get(pb, 2, jobId); // reset the profile to send back result diet_profile_reset(pb, 2); try{ //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME); int mapperkey = mapper->code("vishnu_get_job_info"); mapper->code(machineId, mapperkey); mapper->code(jobId, mapperkey); std::string cmd = mapper->finalize(mapperkey); JobServer jobServer(authKey, machineId, ServerXMS::getInstance()->getSedConfig()); std::string jobSerialized = JsonObject::serialize(jobServer.getJobInfo(jobId)); diet_string_set(pb,1, jobSerialized); diet_string_set(pb,0, "success"); FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, ""); } catch (VishnuException& e) { try { FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, ""); } catch (VishnuException& fe) { e.appendMsgComp(fe.what()); } diet_string_set(pb,0, "error"); diet_string_set(pb,1, e.what()); } return 0; }
/** * \brief Function to solve the jobCancel service * \param pb is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveCancelJob(diet_profile_t* pb) { std::string authKey; std::string machineId; std::string optionSerialized; diet_string_get(pb,0, authKey); diet_string_get(pb,1, machineId); diet_string_get(pb,2, optionSerialized); // reset the profile to send back result diet_profile_reset(pb, 2); try { //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME); int mapperkey = mapper->code("vishnu_cancel_job"); mapper->code(optionSerialized, mapperkey); std::string cmd = mapper->finalize(mapperkey); ServerXMS* server = ServerXMS::getInstance(); JobServer jobServer(authKey, machineId, server->getSedConfig()); JsonObject options(optionSerialized); jobServer.cancelJob(&options); diet_string_set(pb,0, "success"); diet_string_set(pb,1, ""); FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, ""); } catch (VishnuException& ex) { try { FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, ""); } catch (VishnuException& fe) { ex.appendMsgComp(fe.what()); } diet_string_set(pb,0, "error"); diet_string_set(pb,1, ex.what()); } return 0; }
basic_two_stage_index( string_type &string, Mapper &map, typename Mapper::is_mapper *p=0 ) : string(&string), num_indexed_chars((size_t)map.read64()), index(map), addr(map) { }
int main(int argc, char **argv) { //Initialize ROS ros::init(argc, argv, "mapper"); // Create a Mapper object Mapper mapper; mapper.importGrassMap(); ros::spin(); /* while (ros::ok()) { mapper.spin(); } */ return 0; }
void MappingManager::renewLater(Mapper& mapper) { auto minutes = mapper.renewal(); if(minutes) { bool addTimer = !renewal; renewal = GET_TICK() + std::max(minutes, 10u) * 60 * 1000; if(addTimer) { TimerManager::getInstance()->addListener(this); } } else if(renewal) { renewal = 0; TimerManager::getInstance()->removeListener(this); } }
void MappingManager::close(Mapper& mapper) { if(mapper.hasRules()) { bool ret = mapper.init() && mapper.close(); mapper.uninit(); if (ret) log(STRING_F(MAPPER_REMOVING_SUCCESS, deviceString(mapper) % mapper.getName()), LogMessage::SEV_INFO); else log(STRING_F(MAPPER_REMOVING_FAILED, deviceString(mapper) % mapper.getName()), LogMessage::SEV_WARNING); } }
/** * \brief Function to solve the jobOutPutGetResult service * \param pb is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveJobOutPutGetResult(diet_profile_t* pb) { std::string authKey; std::string machineId; std::string optionsSerialized; std::string jobid; //IN Parameters diet_string_get(pb,0, authKey); diet_string_get(pb,1, machineId); diet_string_get(pb,2, optionsSerialized); diet_string_get(pb,3, jobid); // reset profile to handle result diet_profile_reset(pb, 2); try { //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME); int mapperkey = mapper->code("vishnu_get_job_output"); mapper->code(machineId, mapperkey); mapper->code(optionsSerialized, mapperkey); mapper->code(jobid, mapperkey); std::string cmd = mapper->finalize(mapperkey); //Start dealing with output JobOutputServer jobOutputServer(authKey, machineId); JsonObject options(optionsSerialized); TMS_Data::JobResult result = jobOutputServer.getJobOutput(&options, jobid); std::string jobFiles = vishnu::getResultFiles(result, false) ; std::string outputInfo = bfs::unique_path(boost::str(boost::format("%1%/vishnu-%2%-outdescr%3%") % boost::filesystem::temp_directory_path().string() % jobid % "%%%%%%%")).string(); vishnu::saveInFile(outputInfo, jobFiles); diet_string_set(pb,0, "success"); diet_string_set(pb,1, outputInfo); FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, ""); } catch (VishnuException& e) { try { FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, ""); } catch (VishnuException& fe) { e.appendMsgComp(fe.what()); } diet_string_set(pb,0, "error"); diet_string_set(pb,1, e.what()); } return 0; }
void post_map(Geometry const& geometry, Mapper& mapper) { typedef bg::detail::overlay::turn_info < typename bg::point_type<Geometry>::type > turn_info; std::vector<turn_info> turns; bg::detail::self_get_turn_points::no_interrupt_policy policy; bg::self_turns < bg::detail::overlay::assign_null_policy >(geometry, turns, policy); BOOST_FOREACH(turn_info const& turn, turns) { mapper.map(turn.point, "fill:rgb(255,128,0);stroke:rgb(0,0,100);stroke-width:1", 3); }
void map_self_ips(Mapper& mapper, Geometry const& geometry, RescalePolicy const& rescale_policy) { typedef bg::detail::overlay::turn_info < Point, typename bg::segment_ratio_type<Point, RescalePolicy>::type > turn_info; std::vector<turn_info> turns; bg::detail::self_get_turn_points::no_interrupt_policy policy; bg::self_turns < bg::detail::overlay::assign_null_policy >(geometry, rescale_policy, turns, policy); BOOST_FOREACH(turn_info const& turn, turns) { mapper.map(turn.point, "fill:rgb(255,128,0);stroke:rgb(0,0,100);stroke-width:1", 3); }