Beispiel #1
0
int event_setup() {
#if !defined(CONFIG_IPHONE_4) && !defined(CONFIG_IPAD)
	// In our implementation, we set TicksPerSec when we setup the clock
	// so we don't have to do it here

	init_event_list();

	Timers[EventTimer].handler2 = eventTimerHandler;

	// Initialize the timer hardware for something that goes off once every 100 Hz.
	// The handler for the timer will reset it so it's periodic
	timer_init(EventTimer, TicksPerSec/100, 0, 0, 0, FALSE, FALSE, FALSE, FALSE, TRUE);

	// Turn the timer on
	timer_on_off(EventTimer, ON);
#else
        RTCHasInit = TRUE;
	init_event_list();

//        SET_REG(TIMER_REGISTER_TICK, TIMER_STATE_MANUALUPDATE);
        interrupt_install(TIMER_IRQ, eventTimerHandler, 0);
        interrupt_enable(TIMER_IRQ);
#endif

	return 0;
}
Beispiel #2
0
int event_setup() {
	// In our implementation, we set TicksPerSec when we setup the clock
	// so we don't have to do it here

	init_event_list();

	Timers[EventTimer].handler2 = eventTimerHandler;

	// Initialize the timer hardware for something that goes off once every 100 Hz.
	// The handler for the timer will reset it so it's periodic
	timer_init(EventTimer, TicksPerSec/100, 0, 0, 0, FALSE, FALSE, FALSE, FALSE, TRUE);

	// Turn the timer on
	timer_on_off(EventTimer, ON);
	return 0;
}
Beispiel #3
0
int main(int argc, char* argv[]) {

 //this variable collects all user options
  MultiviewOptions options;

  parse_args(argc, argv, &options); 
  record_args(options);

#ifdef INTERPOLATE_RESULT 
  viewsheds = (Nvis*) malloc((options->NVIEWSHEDS+10)*sizeof(Nvis)); 
  assert(viewsheds);
#endif 


  //read input raster 
  printf("reading input grid %s ", options.input_name); 
  Grid *ingrid = read_grid_from_arcascii_file(options.input_name);
  assert(ingrid); 
  printf("..done\n");

  //number of rows and columns in the grid 
  int nrows, ncols;  
  nrows = ingrid->hd->nrows; 
  ncols = ingrid->hd->ncols; 
  printf("grid: rows = %d, cols = %d\n", nrows, ncols);

  if (options.NVIEWSHEDS ==0) 
    options.NVIEWSHEDS = nrows * ncols; 

  //create an output grid 
  Grid* outgrid = create_empty_grid(); 
  assert(outgrid);
  //outgrid->hd = create_empty_header(); 
  //the header is allocated in create_empty_grid()
  copy_header(outgrid->hd, *(ingrid->hd)); 
  alloc_grid_data(outgrid); 


  /* **************************************** */
  /* INITIALIZE EVENT LIST */
  /* **************************************** */

  /*allocate the eventlist to hold the maximum number of events possible*/
  Event* eventList;
  eventList = (Event*) malloc(ncols * nrows * 3 * sizeof(Event));
  assert(eventList);
  
  /*initialize the eventList with the info common to all viewpoints */
  long  nevents;
  Rtimer initTime; 
  rt_start(initTime);
  nevents  = init_event_list(eventList, ingrid );
  printf("nb events = %ld\n", nevents);
  rt_stop(initTime); 
  print_init_timings(initTime); 
  
 

  /* ****************************** */   
  /* compute the viewshed of the i % DO_EVERY point  */
  /* ****************************** */   
  
  assert(options.NVIEWSHEDS > 0);
  int DO_EVERY = nrows * ncols/ options.NVIEWSHEDS; 
  /* start going through the data and considering each point, in turn,
     as a viewshed */
 
  if (options.SWEEP_MODE == SWEEP_DISTRIBUTE)  {
    assert(options.BASECASE_THRESHOLD >0 && options.NUM_SECTORS >0);
    compute_multiviewshed_distribution(options, DO_EVERY,
				       ingrid, outgrid,  nevents, eventList); 
  }
  else { 
    compute_multiviewshed_radial(options, DO_EVERY, ingrid, outgrid, 
				 nevents, eventList);
  }


  /* ****************************** */
  /*all sweeping and computing done - clean up */
  free(eventList);

  //write output grid to file 
  save_grid_to_arcascii_file(outgrid, options.output_name); 

  //clean up 
  destroy_grid(ingrid); 
  destroy_grid(outgrid); 


#ifdef INTERPOLATE_RESULT
  //for NVIEWSHEDS small, the resulting map is basically all empty;
  //the interpolate function extends each non-empty output viewshed
  //value to a ball centered at that point
  interpolate_raster(outgrid, output_name); 
#endif

  exit(0); 
}