Пример #1
0
int main() {
	int i;
	double libc, fire;
	struct firedns_state state, *s = &state;
	firedns_init(s);
	firedns_add_servers_from_resolv_conf(s);

	printf("Testing %d firedns_resolveip4list(\"%s\"):\n",TESTS,TEST_HOST);
	start_time();
	for (i = 0; i < TESTS; i++)
		firedns_resolveip4list(s, TEST_HOST);
	fire = end_time();

	printf("Testing %d gethostbyname(\"%s\"):\n",TESTS,TEST_HOST);
	start_time();
	for (i = 0; i < TESTS; i++)
		gethostbyname(TEST_HOST);
	libc = end_time();

	if (libc > fire)
		printf("Speedup: %d%%\n",(int) (((libc - fire) / libc) * 100.0));
	else
		printf("Slowdown: %d%%\n",(int) (((fire - libc) / libc) * 100.0));

	return 0;
}
Пример #2
0
/** Return the run start time as given by the 'start_time' or 'run_start'
 * property.
 *  'start_time' is tried first, falling back to 'run_start' if the former isn't
 * found.
 *  @returns The start time of the run
 *  @throws std::runtime_error if neither property is defined
 */
const Kernel::DateAndTime LogManager::startTime() const {
  const std::string start_prop("start_time");
  if (hasProperty(start_prop)) {
    try {
      DateAndTime start_time(getProperty(start_prop)->value());
      if (start_time != DateAndTimeHelpers::GPS_EPOCH) {
        return start_time;
      }
    } catch (std::invalid_argument &) { /*Swallow and move on*/
    }
  }

  const std::string run_start_prop("run_start");
  if (hasProperty(run_start_prop)) {
    try {
      DateAndTime start_time(getProperty(run_start_prop)->value());
      if (start_time != DateAndTimeHelpers::GPS_EPOCH) {
        return start_time;
      }
    } catch (std::invalid_argument &) { /*Swallow and move on*/
    }
  }

  throw std::runtime_error("No valid start time has been set for this run.");
}
Пример #3
0
void prolongate( int level ) {
	int i,j;
	const int prolongation_vars[1] = { VAR_POTENTIAL };
	int icell;
	int num_level_cells;
	int *level_cells;

	cart_assert( level >= min_level+1 );

	start_time( WORK_TIMER );

	select_level( level-1, CELL_TYPE_LOCAL | CELL_TYPE_REFINED, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(i,icell,j), shared(num_level_cells,level_cells,cell_vars,cell_child_oct)
	for ( i = 0; i < num_level_cells; i++ ) {
		icell = level_cells[i];

		for ( j = 0; j < num_children; j++ ) {
			cell_potential( cell_child(icell,j) ) = cell_interpolate( icell, j, VAR_POTENTIAL );
		}
	}
	cart_free( level_cells );

	end_time( WORK_TIMER );

	/* update buffers */
	start_time( PROLONGATE_UPDATE_TIMER );
	update_buffer_level( level, prolongation_vars, 1 );
	end_time( PROLONGATE_UPDATE_TIMER );
}
Пример #4
0
        /*
         * the main method
         * receives a Flow message and prints out its associated information
         * If the message belongs to another class, an exception is thrown.
         */
        virtual void _receive_msg(std::shared_ptr<const Msg>&& m, int /* index */)
        {
            if ( m->type() == MSG_ID(Flow) )
            {
                auto flow = static_cast<const Flow *>(m.get());
                std::stringstream ss;
                const FlowKey& fk = flow->key();
                int duration = flow->end_time() - flow->start_time();
                ss<<"packets="<<flow->packets() << ",";
                ss<<"bytes="<<flow->bytes() << ",";
                ss<<"start="<<flow->start_time() << ",";
                ss<<"end="<<flow->end_time() << ",";
                ss<<"duration.us="<<duration<< ",";
                ss<<"source.ip4="<<ip_to_string(fk.src_ip4)<< ",";
                ss<<"source.port="<<fk.src_port<< ",";
                ss<<"destination.ip4="<<ip_to_string(fk.dst_ip4)<< ",";
                ss<<"destination.port="<<fk.dst_port;
                /*
                ss<<"Flow of  "<< flow->packets() << " packets and "<<flow->bytes()<<" bytes begin at "<<flow->start_time()<<" end at "<<flow->end_time()<< "duration (ms.) "<<duration <<std::endl;
                ss<<"SRC IP "<<ip_to_string(fk.src_ip4)<<" SRC port "<<fk.src_port<<std::endl;
                ss<<"DST IP "<<ip_to_string(fk.dst_ip4)<<" DST port "<<fk.dst_port<<std::endl;
                //ss<<"protocol "<<fk.proto<<std::endl;
                */
                blocklog(ss.str(),log_info);


            }
                else
            {
                throw std::runtime_error("Flowprinter: wrong message type");
            }
        }
Пример #5
0
int main(int argc,char *argv[])
{
  FILE      *fp;
  int       nnn[] = { 8, 10, 12, 15, 16, 18, 20, 24, 25, 27, 30, 32, 36, 40,
		      45, 48, 50, 54, 60, 64, 72, 75, 80, 81, 90, 100 };
#define NNN asize(nnn)
  int       *niter;
  int       i,j,n,nit,ntot,n3;
  double    t,nflop;
  double    *rt,*ct;
  t_complex ***g;
  real      ***h;
  
  snew(rt,NNN);
  snew(ct,NNN);
  snew(niter,NNN);
  
  for(i=0; (i<NNN); i++) {
    n = nnn[i];
    fprintf(stderr,"\rReal %d     ",n);
    if (n < 16)
      niter[i] = 100;
    else if (n < 26)
      niter[i] = 50;
    else if (n < 51)
      niter[i] = 10;
    else
      niter[i] = 5;
    nit = niter[i];
      
    h   = mk_rgrid(n+2,n,n);
    start_time();
    for(j=0; (j<nit); j++) {
      testrft(stdout,h,n,n,n,(j==0));
    }
    update_time();
    rt[i] = node_time();
    free_rgrid(h,n,n);
    
    fprintf(stderr,"\rComplex %d     ",n);
    g   = mk_cgrid(n,n,n);
    start_time();
    for(j=0; (j<nit); j++) {
      testfft(stdout,g,n,n,n,(j==0));
    }
    update_time();
    ct[i] = node_time();
    free_cgrid(g,n,n);
  }
  fprintf(stderr,"\n");
  fp=xvgropen("timing.xvg","FFT timings per grid point","n","t (s)");
  for(i=0; (i<NNN); i++) {
    n3 = 2*niter[i]*nnn[i]*nnn[i]*nnn[i];
    fprintf(fp,"%10d  %10g  %10g\n",nnn[i],rt[i]/n3,ct[i]/n3);
  }
  gmx_fio_fclose(fp);
  
  return 0;
}
Пример #6
0
void compute_accelerations_particles( int level ) {
	int i, j;
	double a2half;
	const int accel_vars[nDim] = { VAR_ACCEL, VAR_ACCEL+1, VAR_ACCEL+2 };
	int neighbors[num_neighbors];
	int L1, R1;
	double phi_l, phi_r;
	int icell;
	int num_level_cells;
	int *level_cells;

	start_time( GRAVITY_TIMER );
	start_time( PARTICLE_ACCEL_TIMER );
	start_time( WORK_TIMER );

#ifdef COSMOLOGY
	a2half = -0.5*abox[level]*abox[level]*cell_size_inverse[level];
#else
	a2half = -0.5 * cell_size_inverse[level];
#endif

	select_level( level, CELL_TYPE_LOCAL, &num_level_cells, &level_cells );
#pragma omp parallel for default(none), private(icell,j,neighbors,L1,R1,phi_l,phi_r), shared(num_level_cells,level_cells,level,cell_vars,a2half)
	for ( i = 0; i < num_level_cells; i++ ) {
		icell = level_cells[i];

		cell_all_neighbors( icell, neighbors );
		for ( j = 0; j < nDim; j++ ) {
			L1 = neighbors[2*j];
			R1 = neighbors[2*j+1];

			if ( cell_level(L1) < level ) {
				phi_l = 0.8*cell_potential(L1) + 0.2*cell_potential(icell);
			} else {
				phi_l = cell_potential(L1);
			}

			if ( cell_level(R1) < level ) {
				phi_r = 0.8*cell_potential(R1)+0.2*cell_potential(icell);
			} else {
				phi_r = cell_potential(R1);
			}

			cell_accel( icell, j ) = (float)(a2half * ( phi_r - phi_l ) );
		}
	}
	cart_free( level_cells );

	end_time( WORK_TIMER );

	/* update accelerations */
	start_time( PARTICLE_ACCEL_UPDATE_TIMER );
	update_buffer_level( level, accel_vars, nDim );
	end_time( PARTICLE_ACCEL_UPDATE_TIMER );

	end_time( PARTICLE_ACCEL_TIMER );
	end_time( GRAVITY_TIMER );
}
Пример #7
0
void	draw_main()
#endif
{
	debugmessage("draw_main","");

	start_time();
	draw_nodes();
	stop_time("draw_main draw_nodes");
	start_time();
	draw_edges();
	stop_time("draw_main draw_edges");
}
Пример #8
0
void rtOtvetSingleSourceEddingtonTensor(int level)
{
  int i, j, l, index, cell;
  int num_level_cells, *level_cells;
  double eps1, eps2, dr2, pos[nDim];

  start_time(WORK_TIMER);

  eps1 = 0.01*cell_size[rtSingleSourceLevel]*cell_size[rtSingleSourceLevel];
  eps2 = 9*cell_size[rtSingleSourceLevel]*cell_size[rtSingleSourceLevel];

  select_level(level,CELL_TYPE_LOCAL,&num_level_cells,&level_cells);

#pragma omp parallel for default(none), private(index,cell,pos,dr2,i,j,l), shared(level,num_level_cells,level_cells,rtSingleSourceValue,rtSingleSourcePos,eps1,eps2,cell_vars)
  for(index=0; index<num_level_cells; index++)
    {
      cell = level_cells[index];
      cell_center_position(cell,pos);

      dr2 = eps1;
      for(i=0; i<nDim; i++)
	{
	  pos[i] -= rtSingleSourcePos[i];
	  if(pos[i] >  0.5*num_grid) pos[i] -= num_grid;
	  if(pos[i] < -0.5*num_grid) pos[i] += num_grid;
	  dr2 += pos[i]*pos[i];
	}

      cell_var(cell,RT_VAR_OT_FIELD) = rtSingleSourceValue/(4*M_PI*dr2);
      
      dr2 += nDim*eps2;
      for(l=j=0; j<nDim; j++)
	{
	  for(i=0; i<j; i++)
	    {
	      cell_var(cell,rt_et_offset+l++) = pos[i]*pos[j]/dr2;
	    }
	  cell_var(cell,rt_et_offset+l++) = (eps2+pos[j]*pos[j])/dr2;
	}
    }

  cart_free(level_cells);

  end_time(WORK_TIMER);

  start_time(RT_SINGLE_SOURCE_UPDATE_TIMER);
  update_buffer_level(level,rtOtvetETVars,rtNumOtvetETVars);
  end_time(RT_SINGLE_SOURCE_UPDATE_TIMER);
}
Пример #9
0
Файл: med.c Проект: btb/d2x
// Returns 1 if OK to trash current mine.
int SafetyCheck()
{
	int x;
			
	if (mine_changed) {
		stop_time();				
		x = nm_messagebox( "Warning!", 2, "Cancel", "OK", "You are about to lose work." );
		if (x<1) {
			start_time();
			return 0;
		}
		start_time();
	}
	return 1;
}
Пример #10
0
Файл: rt.c Проект: sleitner/cart
void rtInitRun()
{
#ifdef RT_TEST
  frt_real Yp = 1.0e-10;
#else
  frt_real Yp = constants->Yp;
#endif
  frt_real Tmin = gas_temperature_floor;
  frt_real D2GminH2 = rt_dust_to_gas_floor*(constants->Dsun/constants->Zsun);
  frt_real CluFacH2 = rt_clumping_factor;
  frt_real CohLenH2 = rt_coherence_length;
  frt_real fGal = rt_uv_emissivity_stars;
  frt_real fQSO = rt_uv_emissivity_quasars;
  frt_intg IPOP = rt_stellar_pop;
  frt_intg IREC = 0;
  frt_intg IOUNIT = 81;

  start_time(WORK_TIMER);

  frtCall(initrun2)(&Yp,&Tmin,&D2GminH2,&CluFacH2,&CohLenH2,&fGal,&fQSO,&IPOP,&IREC,&IOUNIT);

  end_time(WORK_TIMER);

#ifdef RT_TRANSFER
  rtInitRunTransfer();
#endif
}
Пример #11
0
Файл: sort.c Проект: robinrob/c
void do_mergesort_words(char *w[], int n)
{
	printf("\nmergesort_words:\n");
	start_time();
	mergesort_words(w, n);
	print_time();
}
Пример #12
0
int writeFile(int use, int dsize)
{
    int  p;

    if (largeFile) start_time();

    if (useCache)
    {
        handle = open(testFile, O_WRONLY | O_CREAT | O_TRUNC,
                      S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
    }
    else
    {
        handle = open(testFile, O_WRONLY | O_CREAT | O_TRUNC | O_DIRECT | O_SYNC,
                      S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP| S_IROTH | S_IWOTH); // O_DIRECT | O_SYNC
    }
    if (handle == -1)
    {
        sprintf(resultchars, " Cannot open %s for writing\n", testFile);
        return 0;
    }

    for (p=0; p<use; p++)
    {
        if (write(handle, dataOut, dsize) != dsize )
        {
            sprintf(resultchars," Error writing file %s block %d\n", testFile, p+1);
            return 0;
        }
    }
    close(handle);

    if (largeFile) end_time();
    return 1;
}
Пример #13
0
int readFile(int use, int dsize)
{
    int p;

    if (largeFile) start_time();

    handle = open(testFile, O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
    if (handle == -1)
    {
        sprintf(resultchars, " Cannot open %s for reading\n", testFile);
        return 0;
    }

    for (p=0; p<use; p++)
    {
        if (read(handle, dataIn, dsize) == -1)
        {
            sprintf(resultchars," Error reading file %s block %d\n", testFile, p+1);
            return 0;
        }

    }
    close(handle);
    if (largeFile) end_time();
    return 1;
}
Пример #14
0
// update_rate() is called from select_task() while holding a compile queue lock.
void AdvancedThresholdPolicy::update_rate(jlong t, methodOop m) {
  if (is_old(m)) {
    // We don't remove old methods from the queue,
    // so we can just zero the rate.
    m->set_rate(0);
    return;
  }

  // We don't update the rate if we've just came out of a safepoint.
  // delta_s is the time since last safepoint in milliseconds.
  jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
  jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement
  // How many events were there since the last time?
  int event_count = m->invocation_count() + m->backedge_count();
  int delta_e = event_count - m->prev_event_count();

  // We should be running for at least 1ms.
  if (delta_s >= TieredRateUpdateMinTime) {
    // And we must've taken the previous point at least 1ms before.
    if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) {
      m->set_prev_time(t);
      m->set_prev_event_count(event_count);
      m->set_rate((float)delta_e / (float)delta_t); // Rate is events per millisecond
    } else
      if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) {
        // If nothing happened for 25ms, zero the rate. Don't modify prev values.
        m->set_rate(0);
      }
  }
}
bool UpperBodyPlanner::checkTrajectory(const moveit_msgs::RobotTrajectory& input_trajectory, moveit_msgs::RobotTrajectory& output_trajectory) {
    moveit_msgs::RobotTrajectory check_trajectory = input_trajectory;
    int input_traj_size = input_trajectory.joint_trajectory.points.size();
    if (input_traj_size == 0) {
        ROS_ERROR("No points in the trajectory.");
        singularity_check = true;
        return false;
    }
    else if (input_traj_size == 1) {
        ROS_INFO("1 point in the trajectory.");
        output_trajectory = check_trajectory;
        singularity_check = true;
        return true;
    }
    int i = 0;
    singularity_check = true;
    while (i < (check_trajectory.joint_trajectory.points.size() - 1)) {
        //std::cout << "Checking point number is: " << i << std::endl;
        Eigen::VectorXd front = stdVec2EigenXd(check_trajectory.joint_trajectory.points[i].positions);
        Eigen::VectorXd back = stdVec2EigenXd(check_trajectory.joint_trajectory.points[i + 1].positions);
        Eigen::VectorXd difference = front - back;
        if (difference.norm() == 0) {
            //std::cout << "The point " << i << " and " << i + 1 << " is too close." << std::endl;
            //std::cout << "Erase point " << i + 1 << " points" << std::endl;
            check_trajectory.joint_trajectory.points.erase(check_trajectory.joint_trajectory.points.begin() + (i + 1));
        }
        else {
            if (difference.norm() >= 0.5) {
                ROS_WARN("Hit singularity");
                singularity_check = false;
            }
            i++;
        }
    }
    //double fix_time = check_trajectory.joint_trajectory.points[0].time_from_start.toSec();
    double fix_time = path_step / move_velocity;
    Eigen::VectorXd velocity_cmd = Eigen::VectorXd::Zero(7);
    double start_t = 0;
    for (int j = 0; j < check_trajectory.joint_trajectory.points.size(); j++) {
        if (j == 0) {
            start_t = start_t + 2 * fix_time;
            velocity_cmd = Eigen::VectorXd::Zero(7);
        }
        else if (j == (check_trajectory.joint_trajectory.points.size() - 1)) {
            start_t = start_t + 2 * fix_time;
            velocity_cmd = Eigen::VectorXd::Zero(7);
        }
        else {
            Eigen::VectorXd current_joint_angle = stdVec2EigenXd(check_trajectory.joint_trajectory.points[j + 1].positions);
            Eigen::VectorXd last_joint_angle = stdVec2EigenXd(check_trajectory.joint_trajectory.points[j].positions);
            velocity_cmd = (current_joint_angle - last_joint_angle) / fix_time;
        }
        start_t = start_t + fix_time;
        ros::Duration start_time((start_t));
        check_trajectory.joint_trajectory.points[j].time_from_start = start_time;
        check_trajectory.joint_trajectory.points[j].velocities = EigenXd2stdVec(velocity_cmd);
    }
    output_trajectory = check_trajectory;
    return true;
}
Пример #16
0
void HeaderManipulation::inputCB(const topic_tools::ShapeShifter::ConstPtr &input)
{
    ROS_DEBUG("HeaderManipulation inputCB");
    ros::Time start_time(ros::Time::now());
    // Initialize.
    if (!output_advertised_) {
        ROS_INFO("Output not advertised. Setting up publisher now.");
        ros::AdvertiseOptions opts("output", 1, input->getMD5Sum(),
                                   input->getDataType(), input->getMessageDefinition());
        boost::mutex::scoped_lock pub_lock(pub_mutex_);
        generic_pub_ = private_nh_.advertise(opts);
        output_advertised_ = true;
    }
    // Copy shape shifter data to array.
    uint8_t msg_buffer[input->size()];
    ros::serialization::OStream o_stream(msg_buffer, input->size());
    input->write(o_stream);
    // Manipulate (header) data.
    manipulateRawData(msg_buffer);
    // Read data from array to StampedMsg
    boost::shared_ptr<StampedMsg> stamped_msg(new StampedMsg());
    stamped_msg->second = start_time;
    ros::serialization::IStream i_stream(msg_buffer, input->size());
    stamped_msg->first.read(i_stream);
    // Push StampedMsg to Buffer for multithreaded publishing.
    boost::mutex::scoped_lock buffer_lock(buffer_mutex_);
    stamped_msg_buffer_.push(stamped_msg);
    ROS_DEBUG("all done");
}
Пример #17
0
void init_ga(int num_circles)
{
	char *end_time_str;
	struct timespec tp1, tp2;
	int idx;
	if(_is_initialized)
		return;

	printfl(IA_INFO,
	    "initializing for genetic algorithm, this may take some time....");
	_is_initialized = true;
	circle_pool = calloc(GEN_SIZE, sizeof(struct ia_circles *));
	start_time(&tp1);

	for(idx = 0; idx < GEN_SIZE; idx++) {
		circle_pool[idx] = calloc(1, sizeof(struct ia_circles));
		init_circles(circle_pool[idx], num_circles);
	}

	for(idx = 0; idx < GEN_SIZE; idx++) {
		//for(jdx = 0; jdx < 2; jdx++) {
		//	_seed_mutate(&circle_pool[idx]);
		//}
		refresh_circles(circle_pool[idx]);
		sort_circles(circle_pool[idx]);
	}

	end_time_str = end_time(&tp1, &tp2, "time");
	printfi("%s\nsee, that didn't take too long, did it?\n", end_time_str);
	free(end_time_str);
}
Пример #18
0
void redbook_first_song_func()
{
    stop_time();
    Song_playing = -1; // Playing Redbook tracks will not modify Song_playing. To repeat we must reset this so songs_play_level_song does not think we want to re-play the same song again.
    songs_play_level_song(1, 0);
    start_time();
}
Пример #19
0
int	GotoGameScreen()
{
	stop_time();

//@@	init_player_stats();
//@@
//@@	Player_init.pos = Player->pos;
//@@	Player_init.orient = Player->orient;
//@@	Player_init.segnum = Player->segnum;	
	
// -- must always save gamesave.sav because the restore-objects code relies on it
// -- that code could be made smarter and use the original file, if appropriate.
//	if (mine_changed) 
	if (gamestate_not_restored == 0) {
		gamestate_not_restored = 1;
		save_level("GAMESAVE.LVL");
		editor_status("Gamestate saved.\n");
	}

	ai_reset_all_paths();

	start_time();

	ModeFlag = 3;
	return 1;
}
Пример #20
0
void save_screen_shot(int automap_flag)
{
	static int savenum=0;
	char savename[13+sizeof(SCRNS_DIR)];
	unsigned char *buf;

	if (!GameArg.DbgGlReadPixelsOk){
		if (!automap_flag)
			HUD_init_message_literal(HM_DEFAULT, "glReadPixels not supported on your configuration");
		return;
	}

	stop_time();

	if (!PHYSFSX_exists(SCRNS_DIR,0))
		PHYSFS_mkdir(SCRNS_DIR); //try making directory

	do
	{
		sprintf(savename, "%sscrn%04d.tga",SCRNS_DIR, savenum++);
	} while (PHYSFSX_exists(savename,0));

	if (!automap_flag)
		HUD_init_message(HM_DEFAULT, "%s 'scrn%04d.tga'", TXT_DUMPING_SCREEN, savenum-1 );

#ifndef OGLES
	glReadBuffer(GL_FRONT);
#endif

	buf = d_malloc(grd_curscreen->sc_w*grd_curscreen->sc_h*3);
	write_bmp(savename,grd_curscreen->sc_w,grd_curscreen->sc_h,buf);
	d_free(buf);

	start_time();
}
Пример #21
0
static int handle_call_after(struct task *task, struct breakpoint *bp)
{
	struct timespec start;

	(void)bp;

	if (!task->breakpoint)
		return 0;

	if (unlikely(options.verbose > 1))
		start_time(&start);

#if HW_BREAKPOINTS > 0
	disable_scratch_hw_bp(task, bp);
#endif

	if (task->libsym->func->report_out)
		task->libsym->func->report_out(task, task->libsym);

	if (unlikely(options.verbose > 1))
		set_timer(&start, &report_out_time);

	task->breakpoint = NULL;
	task->libsym = NULL;

	return 0;
}
Пример #22
0
int state_save_all(int between_levels)
{
	char filename[128], desc[DESC_LENGTH+1];

	if ( Game_mode & GM_MULTI )	{
#ifdef MULTI_SAVE
		if ( FindArg( "-multisave" ) )
			multi_initiate_save_game();
		else
#endif  
			HUD_init_message( "Can't save in a multiplayer game!" );
		return 0;
	}

	mprintf(( 0, "CL=%d, NL=%d\n", Current_level_num, Next_level_num ));
	
	stop_time();

	if (!state_get_save_file(filename,desc,0))	{
		start_time();
		return 0;
	}
		
	return state_save_all_sub(filename, desc, between_levels);
}
Пример #23
0
  void writeGeotiff()
  {
    ros::Time start_time (ros::Time::now());

    std::stringstream ssStream;

    nav_msgs::GetMap srv_map;
    if (map_service_client_.call(srv_map))
    {
      ROS_INFO("GeotiffNode: Map service called successfully");
      const nav_msgs::OccupancyGrid& map (srv_map.response.map);

      std::string map_file_name = p_map_file_base_name_;
      std::string competition_name;
      std::string team_name;
      std::string mission_name;
      std::string postfix;
      if (n_.getParamCached("/competition", competition_name) && !competition_name.empty()) map_file_name = map_file_name + "_" + competition_name;
      if (n_.getParamCached("/team", team_name)               && !team_name.empty())        map_file_name = map_file_name + "_" + team_name;
      if (n_.getParamCached("/mission", mission_name)         && !mission_name.empty())     map_file_name = map_file_name + "_" + mission_name;
      if (pn_.getParamCached("map_file_postfix", postfix)     && !postfix.empty())          map_file_name = map_file_name + "_" + postfix;
      if (map_file_name.substr(0, 1) == "_") map_file_name = map_file_name.substr(1);
      if (map_file_name.empty()) map_file_name = "GeoTiffMap";
      geotiff_writer_.setMapFileName(map_file_name);
      bool transformSuccess = geotiff_writer_.setupTransforms(map);

      if(!transformSuccess){
        ROS_INFO("Couldn't set map transform");
        return;
      }

      geotiff_writer_.setupImageSize();

      if (p_draw_background_checkerboard_){
        geotiff_writer_.drawBackgroundCheckerboard();
      }

      geotiff_writer_.drawMap(map, p_draw_free_space_grid_);
      geotiff_writer_.drawCoords();

      //ROS_INFO("Sum: %ld", (long int)srv.response.sum);
    }
    else
    {
      ROS_ERROR("Failed to call map service");
      return;
    }

    for (size_t i = 0; i < plugin_vector_.size(); ++i){
      plugin_vector_[i]->draw(&geotiff_writer_);
    }

    geotiff_writer_.writeGeotiffImage();
    running_saved_map_num_++;

    ros::Duration elapsed_time (ros::Time::now() - start_time);

    ROS_INFO("GeoTiff created in %f seconds", elapsed_time.toSec());
  }
Пример #24
0
Файл: rt.c Проект: sleitner/cart
void rtInitStep(double dt)
{
  frt_real uDen = units->number_density;
  frt_real uLen = units->length;
  frt_real uTime = units->time;
  frt_real dtCode = dt;

#ifdef COSMOLOGY
  frt_real aExp = abox[min_level];
  frt_real daExp = abox_from_tcode(tl[min_level]+dt) - abox[min_level];
  frt_real HExp = Hubble(aExp)/units->time;
#else
  frt_real aExp = 1.0;
  frt_real daExp = 0.0;
  frt_real HExp = 0.0;
#endif

  start_time(WORK_TIMER);

  frtCall(stepbegin)(&uDen,&uLen,&uTime,&aExp,&HExp,&daExp,&dtCode);

  end_time(WORK_TIMER);

#ifdef RT_TRANSFER
  rtInitStepTransfer();
#endif

  rtUpdateTables();

#ifdef RT_DEBUG
  switch(rt_debug.Mode)
    {
    case 1:
      {
	int i, cell;
	cell = cell_find_position(rt_debug.Pos);
	cart_debug("In cell-level debug for cell %d/%d",cell,cell_level(cell));
	cart_debug("RT_HVAR_OFFSET: %d",RT_HVAR_OFFSET);
#ifdef RT_VAR_SOURCE
	cart_debug("RT_VAR_SOURCE: %d",RT_VAR_SOURCE);
#endif
	cart_debug("rt_grav_vars_offset: %d",rt_grav_vars_offset);
#ifdef RT_TRANSFER
	cart_debug("rt_num_vars: %d",rt_num_vars);
#if (RT_TRANSFER_METHOD == RT_METHOD_OTVET)
	cart_debug("RT_VAR_OT_FIELD: %d",RT_VAR_OT_FIELD);
	cart_debug("rt_et_offset: %d",rt_et_offset);
	cart_debug("rt_field_offset: %d",rt_field_offset);
#endif
#endif
	for(i=0; i<num_vars; i++)
	  {
	    cart_debug("Var[%d] = %g",i,cell_var(cell,i));
	  }
	break;
      }
    }
#endif /* RT_DEBUG */
}
Пример #25
0
TEST_F(SemaphoreTest, timedwait) {
  semaphore->post();
  ASSERT_TRUE(semaphore->timedwait(0.1));
  Time start_time(Time::now());
  semaphore->timedwait(0.1);
  Time elapsed_time(Time::now() - start_time);
  ASSERT_GE(elapsed_time, Time(0.1));
}
Пример #26
0
void timer_start(int np) {

      int n = np;

      start_time(n) = RCCE_wtime();

      return;
}
Пример #27
0
void Control::initTime()
{
    QSqlQuery query;
    QDateTime start_date_time;
    query.exec("select min(DATE),min(TIME) from DATAS");
    if(query.next()){
        int min_date = query.value(0).toInt();
        int min_time = query.value(1).toInt();
        int year = min_date / 10000;
        int month = min_date % 10000 / 100;
        int day = min_date % 100;
        int h = min_time / 10000;
        QTime start_time(h,0);
        QDate start_date(2000 +year,month,day);
        start_date_time = QDateTime(start_date,start_time);
    }

    query.exec("select max(DATE),max(TIME) from DATAS");
    QDateTime end_date_time;
    if(query.next()){
        int max_date = query.value(0).toInt();
        int max_time = query.value(1).toInt();
        int year = max_date / 10000;
        int month = max_date % 10000 / 100;
        int day = max_date % 100;
        int h = max_time / 10000;
        QTime end_time(h,0);
        QDate end_date(2000 +year,month,day);
        end_date_time = QDateTime(end_date,end_time);
    }
    ui->startDateTimeEdit->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit->setMaximumDateTime(end_date_time);

    ui->startDateTimeEdit_2->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit_2->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit_2->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit_2->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit_2->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit_2->setMaximumDateTime(end_date_time);

    ui->startDateTimeEdit_3->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit_3->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit_3->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit_3->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit_3->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit_3->setMaximumDateTime(end_date_time);

    ui->startDateTimeEdit_4->setDisplayFormat("yyyy-M-d HH");
    ui->endDateTimeEdit_4->setDisplayFormat("yyyy-M-d HH");
    ui->startDateTimeEdit_4->setMinimumDateTime(start_date_time);
    ui->startDateTimeEdit_4->setMaximumDateTime(end_date_time);
    ui->endDateTimeEdit_4->setMinimumDateTime(start_date_time);
    ui->endDateTimeEdit_4->setMaximumDateTime(end_date_time);
}
Пример #28
0
void joy_delay()
{
	stop_time();
//	timer_delay(.25);
	delay(250);				// changed by allender because	1) more portable
							//								2) was totally broken on PC
	joy_flush();
	start_time();
}
Пример #29
0
Файл: rt.c Проект: sleitner/cart
void rtAfterAssignDensity2(int level, int num_level_cells, int *level_cells)
{
  start_time(RT_AFTER_DENSITY_TIMER);

#ifdef RT_TRANSFER
  rtAfterAssignDensityTransfer(level,num_level_cells,level_cells);
#endif

  end_time(RT_AFTER_DENSITY_TIMER);
}
Пример #30
0
Файл: main.c Проект: robinrob/c
void sort(int **a, int n_piv)
{
	int i;
	start_time();
	printf("Quicksorting ...\n");
	for (i = 0; i < N_ARR; ++i) {
		quicksort(a[i], a[i] + N_ELEM - 1, n_piv);
	}
	print_time();
}