当前位置: 首页>>代码示例>>C++>>正文


C++ shawn::SimulationController类代码示例

本文整理汇总了C++中shawn::SimulationController的典型用法代码示例。如果您正苦于以下问题:C++ SimulationController类的具体用法?C++ SimulationController怎么用?C++ SimulationController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimulationController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init_topology_elevation

  void init_topology_elevation( shawn::SimulationController& sc )
  {
     std::cout << "init_topology_elevation" << std::endl;

     sc.simulation_task_keeper_w().add( new ConstantElevationTask );
     sc.simulation_task_keeper_w().add( new XYZFileElevationTask );
  }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:7,代码来源:elevation_init.cpp

示例2: init_distest

extern "C" void init_distest( shawn::SimulationController& sc )
{
	sc.distance_estimate_keeper_w().add( new shawn::NeighborhoodIntersectionDistanceEstimate );
	sc.simulation_task_keeper_w().add( new distest::DistanceEstimateTask );
	sc.simulation_task_keeper_w().add( new distest::MultihopDistanceEstimateTask );
	sc.simulation_task_keeper_w().add( new distest::TestTask );
}
开发者ID:MarcStelzner,项目名称:shawn,代码行数:7,代码来源:distest_init.cpp

示例3: run

   // ----------------------------------------------------------------------
   void
   CreateDynamicEdgesTransmissionRangeTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);
      GroupElement* all_edges = new GroupElement("all.edges");
      visualization_w().add_element(all_edges);

      std::string pref = sc.environment().
            optional_string_param("prefix",DrawableEdgeDynamic::PREFIX);
      std::string node_prefix = sc.environment().
            optional_string_param("node_prefix",DrawableNodeDefault::PREFIX);

      std::string _source_regex = sc.environment().optional_string_param("source_regex", ".*");
      std::string _target_regex = sc.environment().optional_string_param("target_regex", ".*");

      const shawn::Node &dummy = *(visualization().world().begin_nodes());
      std::cout << "Regex: " << _source_regex << std::endl;
      DrawableEdgeDynamicTransmissionRange* ded =
                        new DrawableEdgeDynamicTransmissionRange(dummy,dummy, pref, node_prefix, _source_regex, _target_regex);
      ded->init();
      visualization_w().add_element(ded);
      all_edges->add_element(*ded);
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:26,代码来源:vis_create_dynamic_edges_transmission_range.cpp

示例4: run

   // ----------------------------------------------------------------------
   void
   CreateEstimatedEdgesTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      VisualizationTask::run(sc);

      std::string pref = sc.environment().
         optional_string_param("prefix",DrawableEdgeEstimated::PREFIX);
      std::string node_prefix =
         sc.environment().
         optional_string_param("node_prefix",DrawableNodeDefault::PREFIX);
      GroupElement* grp = group(sc);

      for( shawn::World::const_node_iterator
              it    = visualization().world().begin_nodes(),
              endit = visualization().world().end_nodes();
           it != endit; ++it )
      {
         if( it->has_est_position())
         {
            const DrawableNode* dn = drawable_node(*it, node_prefix);
            DrawableEdgeEstimated* dee = new DrawableEdgeEstimated(*it, *dn, 
               DrawableEdgeEstimated::PREFIX);
            dee->init();
            visualization_w().add_element(dee);
            if( grp != NULL )
               grp->add_element(*dee);
         }
      }
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:32,代码来源:vis_create_estimated_edges.cpp

示例5: create_tree_in_file

		// ----------------------------------------------------------------------
		void
			TreeCreationTask::
			create_tree_in_file( shawn::SimulationController& sc,
								 const std::string& filename,
								 const shawn::Node& sink,
								 int max_hops )
			throw()
		{
			// Avoid appending
			bool append = sc.environment().optional_bool_param("append",false);
			if(!append)
			{
				remove( filename.c_str() );
			}
			// Init stuff
//			double now = sink.current_time();
			NodesToExamineMap nodes_to_examine;
			TreeCreationHopsToSinkResult& result = *( new TreeCreationHopsToSinkResult( sc.world_w() ) );
			ofstream file_op(filename.c_str(),ios::app);
			// Treat the sink
			file_op << sink.id() << "\t"
					<< sink.id() << "\t"
					<< sink.id() << "\t"
					<< 0 << "\t"
					<< sink.real_position().x() << "\t"
					<< sink.real_position().y() << endl;
			result[sink].hops_ = 0;
			nodes_to_examine.insert( NodesToExamineMapValueType(0,&sink) );
			// Main loop
			while( ! nodes_to_examine.empty() )
			{
				NodesToExamineMapIterator min_it = nodes_to_examine.begin();
				const shawn::Node* min_node = min_it->second;
				nodes_to_examine.erase( min_it );
				for( World::const_adjacency_iterator adj_it = min_node->begin_adjacent_nodes();
					 adj_it != min_node->end_adjacent_nodes(); ++adj_it )
				{
					int hops = result[*min_node].hops_ + 1;
					if( hops < result[*adj_it].hops_ )
					{
						assert( result[*adj_it].hops_ == INT_MAX );
						result[*adj_it].hops_ = hops;
						file_op << adj_it->id() << "\t"
								<< sink.id() << "\t"
								<< min_node->id() << "\t"
								<< hops << "\t"
								<< adj_it->real_position().x() << "\t"
								<< adj_it->real_position().y() << endl;
						if( hops < max_hops )
						{
							nodes_to_examine.insert( NodesToExamineMapValueType( hops, &(*adj_it) ) );
						}
					}
				}
			}
			file_op.clear();
			file_op.close();
			delete &result;
		}
开发者ID:MarcStelzner,项目名称:shawn,代码行数:60,代码来源:tree_creation_task.cpp

示例6: AutoElements

   AutoElements::
   AutoElements( shawn::SimulationController& sc,
                 Visualization& vis )
      throw( std::runtime_error )
      : current_ ( NULL )
#ifdef HAVE_BOOST_REGEX
      , regex_   ( NULL )
#endif
   {
      std::string parm;

      tag_ = sc.environment().optional_string_param("tag", "");

      parm=sc.environment().optional_string_param("elem","");
      if( !parm.empty()  )
         {
            mode_=Single;
            current_ = vis.element_w(parm);
            if( current_.is_null() )
               throw std::runtime_error(std::string("no such element: ") + parm );
            return;
         }

      parm=sc.environment().optional_string_param("elem_regex","");
      std::string tagregex = sc.environment().optional_string_param("tag_regex","");
      if( !parm.empty() || (!tagregex.empty() && !tag_.empty()))
         {
#ifdef HAVE_BOOST_REGEX
            if(tag_.empty() || tagregex.empty())
               mode_=Regex;
            else
               mode_=TagRegex;

            try {
               if(mode_==Regex)
                  regex_= new boost::regex(parm);
               else
                  regex_= new boost::regex(tagregex);
            } 
            catch(...) {
               throw std::runtime_error(std::string("regular expression is bad"));
            }

            vis_cur_=vis.elements().begin();
            vis_end_=vis.elements().end();
            advance_infeasible();

            return;
#else
            throw std::runtime_error(std::string("no regexp support compiled in"));
#endif
         }
       

      throw std::runtime_error(std::string("specify elements (either $elem or $elem_regex)"));
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:56,代码来源:vis_auto_elements.cpp

示例7: run

   // ----------------------------------------------------------------------
   void
   ConstantElevationTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      double val = sc.environment().required_double_param("height");
      std::string n = sc.environment().optional_string_param("name","");

      elevation_keeper_w(sc).add( new ConstantElevation(val,n) );
   }
开发者ID:honr,项目名称:shawn,代码行数:11,代码来源:constant_elevation_task.cpp

示例8: run

   // ----------------------------------------------------------------------
   void
   XYZFileElevationTask::
   run( shawn::SimulationController& sc )
      throw( std::runtime_error )
   {
      std::string fn       = sc.environment().required_string_param("file");
      std::string outn     = sc.environment().required_string_param("name");
      std::string xyplacen = sc.environment().optional_string_param("xy_placement",KEY_SCALE);
      std::string zplacen  = sc.environment().optional_string_param("z_placement",KEY_SCALE);
      bool xyplace_box;
      bool zplace_box;

      if( xyplacen == KEY_BOX )      xyplace_box = true;
      else if( xyplacen==KEY_SCALE ) xyplace_box = false;
      else throw runtime_error(string("$xy_placement must be ")+KEY_SCALE+string(" or ")+KEY_BOX);

      if( zplacen == KEY_BOX )      zplace_box = true;
      else if( zplacen==KEY_SCALE ) zplace_box = false;
      else throw runtime_error(string("$z_placement must be ")+KEY_SCALE+string(" or ")+KEY_BOX);

      XYZFile* data = new XYZFile;
      Vec base_point;
      Vec scale_vec;
      XYZFileElevation* elev;
      try {
         data->read(fn);

         if( (data->x_dimension()<2) || (data->y_dimension()<2) )
            {
               ostringstream oss;
               oss << "XYZ data must have at least 2x2 grid points, but "
                   << fn << " just contains "
                   << data->x_dimension() << "x" << data->y_dimension();
               throw runtime_error(oss.str());
            }

         if( xyplace_box ) xy_place_box(sc,*data,base_point,scale_vec);
         else xy_place_scale(sc,*data,base_point,scale_vec);

         if( zplace_box ) z_place_box(sc,*data,base_point,scale_vec);
         else z_place_scale(sc,*data,base_point,scale_vec);

         elev = new XYZFileElevation(data,
                                     base_point,
                                     scale_vec.x(),scale_vec.y(),scale_vec.z(),
                                     outn);
      }
      catch( runtime_error& )
	  {
         delete data;
         throw;
      }

      elevation_keeper_w(sc).add( elev );
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:56,代码来源:xyz_file_elevation_task.cpp

示例9: init_examples

extern "C" void init_examples( shawn::SimulationController& sc )
{
	std::cout << "Initialising examples" << std::endl;
	
	sc.simulation_task_keeper_w().add( new exampletask::ExampleTask );
	sc.simulation_task_keeper_w().add( new examples::ConnectivityTask );
	
	helloworld::HelloworldProcessorFactory::register_factory(sc);
	helloworld::HelloworldRandomProcessorFactory::register_factory(sc);
	
	sc.simulation_task_keeper_w().add( new examples::tagtest::TagTestTask );
}
开发者ID:honr,项目名称:shawn,代码行数:12,代码来源:examples_init.cpp

示例10: start_server

   // --------------------------------------------------------------------
   bool
   TestbedServiceServer::
   start_server( const shawn::SimulationController& sc )
   {
      host_ = sc.environment().required_string_param( "testbedservice_server_host" );
      port_ = sc.environment().required_int_param( "testbedservice_server_port" );
      TestbedServiceServer::WorkerThread::wsdl_path =
         sc.environment().required_string_param( "testbedservice_wsdl" );

      runner_ = new boost::thread( boost::bind( &WorkerThread::run, &worker_, host_, port_ ) );
      return true;
   }
开发者ID:honr,项目名称:shawn,代码行数:13,代码来源:testbedservice_server.cpp

示例11: z_place_scale

 // ----------------------------------------------------------------------
 void
 XYZFileElevationTask::
 z_place_scale( shawn::SimulationController& sc,
               const XYZFile& f,
               shawn::Vec& bp, shawn::Vec& s )
    throw( std::runtime_error )
 {
    bp = Vec( bp.x(), bp.y(),
              sc.environment().optional_double_param("z_base",0.0) );
    s = Vec( s.x(), s.y(),
             sc.environment().optional_double_param("z_scale",1.0) );
 }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:13,代码来源:xyz_file_elevation_task.cpp

示例12: create_tree_from_file

		// ----------------------------------------------------------------------
		void
			TreeCreationTask::
			create_tree_from_file( shawn::SimulationController& sc,
								   routing::tree::TreeRouting& routing_instance,
								   const std::string& filename )
			throw()
		{
			double now = sc.world().current_time();
			ifstream file_in;
			file_in.open(filename.c_str(),ifstream::in);
			if(!file_in)
			{
				ERROR(this->logger(),"Unable to open file " + filename + "!");
				abort();
			}
			string buf;
			while( getline(file_in,buf) )
			{
				StrTok tok(buf,"\t ");
				double line[6];
				int i = 0;
				for(StrTok::iterator it = tok.begin(); it != tok.end(); ++it)
				{
					line[i++] = conv_string_to_double(*it);
				}
				shawn::Node* node = sc.world_w().find_node_by_id_w( (int)line[0] );
				shawn::Node* sink = sc.world_w().find_node_by_id_w( (int)line[1] );
				shawn::Node* neighbor = sc.world_w().find_node_by_id_w( (int)line[2] );
				int hops_to_sink = (int)line[3];
				double node_x = line[4];
				double node_y = line[5];
				double node_real_pos_x = conv_string_to_double(conv_double_to_string(node->real_position().x()));
				double node_real_pos_y = conv_string_to_double(conv_double_to_string(node->real_position().y()));
				if( !( node && sink && neighbor ) )
				{
					ERROR(this->logger(),"Error while reading file!");
					abort();
				}
				if( node_x != node_real_pos_x ||
					node_y != node_real_pos_y )
				{
					ERROR(this->logger(),"Position mismatch! Read x: "
						  + conv_double_to_string(node_x)
						  + ", y: " + conv_double_to_string(node_y)
						  + " Real position x: " + conv_double_to_string(node_real_pos_x)
						  + ", y: " + conv_double_to_string(node_real_pos_y));
					abort();
				}
				routing_instance.tree_routing_table_update(*node,*sink,TreeRoutingTableInfo(*neighbor,hops_to_sink,now));
			}
			INFO(this->logger(),"Reading from file: " + filename + " succeeded!");
		}
开发者ID:MarcStelzner,项目名称:shawn,代码行数:53,代码来源:tree_creation_task.cpp

示例13: init_reading

extern "C" void init_reading( shawn::SimulationController& sc )
{
   // Keepers
    sc.add_keeper(new reading::ReadingKeeper());
    sc.add_keeper(new reading::SensorKeeper());

   // Sensors
    sc.keeper_by_name_w<reading::SensorKeeper>("SensorKeeper")->add( new reading::SimpleSensorDoubleFactory );
    sc.keeper_by_name_w<reading::SensorKeeper>("SensorKeeper")->add( new reading::SimpleSensorIntegerFactory );

   // Test
   reading::RandomDoubleTestProcessorFactory::register_factory(sc);
   sc.simulation_task_keeper_w().add( new reading::SimulationTaskReadingDoubleTestCreate );
}
开发者ID:honr,项目名称:shawn,代码行数:14,代码来源:reading_init.cpp

示例14: init_processor_factories

 // ----------------------------------------------------------------------
 void
 DefaultNodeGenerator::
 init_processor_factories( shawn::SimulationController& sc,
                           ProcessorFactoryList& pfl )
    throw( std::runtime_error )
 {
    shawn::StrTok tok( sc.environment().optional_string_param( "processors", "" ), ", " );
    for ( shawn::StrTok::iterator it = tok.begin(), end = tok.end();
          it != end;
          ++it )
    {
       shawn::ProcessorFactoryHandle pfh = sc.processor_keeper_w().find_w( *it );
       assert( pfh != NULL ); // not found throws...
       pfl.push_back( pfh );
    }
 }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:17,代码来源:default_node_gen.cpp

示例15: xy_place_scale

   // ----------------------------------------------------------------------
   void
   XYZFileElevationTask::
   xy_place_scale( shawn::SimulationController& sc,
                 const XYZFile& f,
                 shawn::Vec& bp, shawn::Vec& s )
      throw( std::runtime_error )
   {
      double scale = sc.environment().optional_double_param("xy_scale",1.0);

      bp = Vec( sc.environment().optional_double_param("x1",0.0),
                sc.environment().optional_double_param("y1",0.0),
                bp.z() );
      s = Vec( sc.environment().optional_double_param("x_scale",scale),
               sc.environment().optional_double_param("y_scale",scale),
               s.z() );
   }
开发者ID:MarcStelzner,项目名称:shawn,代码行数:17,代码来源:xyz_file_elevation_task.cpp


注:本文中的shawn::SimulationController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。