// ---------------------------------------------------------------------- void SimulationTaskLocalizationEvaluation:: run( SimulationController& sc ) throw( std::runtime_error ) { require_world( sc ); HeaderInfo header; Results results; header.collect_information( sc, *this ); results.collect_information( sc, *this ); print( header, results ); print_ps( sc, header ); write_out( sc, header, results ); }
// ---------------------------------------------------------------------- void TreeCreationTask:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { require_world( sc ); bool tree_routing_set = false; bool filename_set = false; string tree_routing_instance = sc.environment().optional_string_param("routing_instance","",&tree_routing_set); string filename = sc.environment().optional_string_param("tree_creation_filename","",&filename_set); TreeRouting* routing_instance = NULL; if( tree_routing_set ) { RoutingBaseHandle rbh = routing::routing_keeper_w(sc).find_w(tree_routing_instance); routing_instance = dynamic_cast<TreeRouting*>( rbh.get() ); if( ! routing_instance ) { ERROR(this->logger(),"The given routing is no TreeRouting!"); abort(); } routing_instance->init( sc.world_w() ); } if( tree_routing_set && filename_set ) { create_tree_from_file(sc,*routing_instance,filename); return; } int sink_id = sc.environment().required_int_param("sink_id"); const Node* sink = sc.world().find_node_by_id( sink_id ); if( tree_routing_set && ( ! filename_set ) ) { create_tree_in_tree_routing( *routing_instance, *sink ); return; } if( ( ! tree_routing_set ) && filename_set ) { int max_hops = sc.environment().optional_int_param("max_hops",INT_MAX); create_tree_in_file( sc, filename, *sink, max_hops ); return; } }
// ---------------------------------------------------------------------- void ExampleTask:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { require_world( sc ); double count = 0; for( shawn::World::const_node_iterator it = sc.world().begin_nodes(); it != sc.world().end_nodes(); ++it ) { count++; } INFO( logger(), "visited " << count << " nodes" ); }
// ---------------------------------------------------------------------- void VisualizationTaskCreate:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { Visualization* vis; require_world(sc); std::string name = sc.environment().optional_string_param( "vis", "visualization" ); visualization_keeper_w(sc).add(vis=new Visualization(name)); std::string type = sc.environment().optional_string_param( "node_type", "default" ); DrawableNodeFactoryHandle dnfh = sc.keeper_by_name_w<DrawableNodeKeeper>("DrawableNodeKeeper") ->find_w(sc.environment().optional_string_param("drawable_nodes", type)); sc.world_w().add_node_change_listener(*vis); vis->set_world( sc.world() ); vis->init(); DEBUG( logger(), "created visualization '" << name << "'" ); GroupElement* ge = new GroupElement( "all.nodes" ); ge->init(); vis->add_element(ge); for( shawn::World::const_node_iterator it = sc.world().begin_nodes(); it != sc.world().end_nodes(); ++it ) { DrawableNode *dn = dnfh->create(*it); dn->init(); vis->add_element(dn); ge->add_element(*dn); } }