Example #1
0
int 
layout_test_simple(struct dm_disk_if *d) {
  int i, lbn, count = 0, runlbn = 0;
  struct dm_pbn pbn, trkpbn = {0,0,0};
  int bad = 0;

  for(i = 0; i < d->dm_sectors; i++) {
    int lbn2;
    dm_angle_t skew, zerol;
    struct dm_mech_state track;
    dm_ptol_result_t rc;

    startClock(0);
    rc = d->layout->dm_translate_ltop(d, i, MAP_FULL, &pbn, 0);
    stopClock(0);
    if(rc == DM_NX) {
      printf("*** %s %d -> NX\n", __func__, i);
      bad++;
      continue;
    }
    
    startClock(1);
    lbn2 = d->layout->dm_translate_ptol(d, &pbn, 0);
    stopClock(1);
    if(lbn2 == DM_NX) {
      printf("*** layout_test_simple %d -> (%d,%d,%d) -> NX\n",
	     i, pbn.cyl, pbn.head, pbn.sector);
      bad++;
      continue;
    }

    if(i != lbn2) {
      printf("*** layout_test_simple: %8d -> (%8d, %3d, %4d) -> %8d\n", 
	     i, pbn.cyl, pbn.head, pbn.sector, lbn2);
      bad++;
    }
    else {
      //      printf("%8d <-> (%8d, %3d, %4d)\n", 
      //	     c, pbn.cyl, pbn.head, pbn.sector);
      if((lbn2 > 0)
	 && (trkpbn.head == pbn.head)
	 && (trkpbn.cyl == pbn.cyl)
	 && ((trkpbn.sector+count) == pbn.sector)) { count++;  }
      else {
	//	printf("l %d %d %d %d %d\n", runlbn, trkpbn.cyl, trkpbn.head, trkpbn.sector, count);
	runlbn = i;
	trkpbn = pbn;
	count = 1;
      }
    }    

    fflush(stdout);
  }


  return bad;
}
Example #2
0
bool RTCx::setClock(const struct tm *tm, timeFunc_t func) const
{
  // Find which register to read from
  uint8_t sz = 0;
  uint8_t reg = getRegister(func, sz);
  
  if (sz == 0)
    return false; // not supported

  if (func == TIME)
    stopClock();

  uint8_t osconEtc = 0;
  if (device == MCP7941x)
    // Preserve OSCON, VBAT, VBATEN on MCP7941x
    osconEtc = readData((uint8_t)0x03) & 0x38;
  
  // Write everything *except* the second
  Wire.beginTransmission(address);
  Wire.write(reg + 1);
  Wire.write(decToBcd(tm->tm_min));
  Wire.write(decToBcd(tm->tm_hour)); // Forces 24h mode
  Wire.write(decToBcd(tm->tm_wday + 1) | osconEtc);
  Wire.write(decToBcd(tm->tm_mday));
  Wire.write(decToBcd(tm->tm_mon + 1)); // leap year read-only on MCP7941x
  Wire.write(decToBcd(tm->tm_year % 100));
  Wire.endTransmission();

  if (func == TIME)
    startClock(decToBcd(tm->tm_sec));
  else
    writeData(reg, decToBcd(tm->tm_sec));
  return true;
}
Example #3
0
void MainWindow::stopTracking()
{
    if (isTracking) {
        stopClock();
        getTrackBtn()->setText("Start");
        trackingClock->reset();
        trackingClock->stop();
    }
}
Example #4
0
void RTCx::clearVBAT(void) const
{
  if (device == MCP7941x) {
    stopClock();
    uint8_t d = readData((uint8_t)0x03);
    d &= 0xef;
    writeData((uint8_t)0x03, d);
    uint8_t s = readData((uint8_t)0);
    startClock(s);
  }
}
Example #5
0
void RTCx::enableBatteryBackup(bool enable) const
{
  if (device == MCP7941x) {
    stopClock();
    uint8_t d = readData((uint8_t)0x03);
    if (enable)
      d |= 0x08;
    else
      d &= 0xf7;
    writeData((uint8_t)0x03, d);
    uint8_t s = readData((uint8_t)0);
    startClock(s);
  }
}
void Tresenv::sim_step()
{
    // implement graceful exit when Ctrl-C is hit during simulation. We want
    // to finish the current event, then normally exit via callFinish() etc
    // so that simulation results are not lost.
    installSignalHandler();
    
    startClock();
    sigint_received = false;
    disable_tracing = true;
    
    cSimpleModule *mod;
    try
    {

        mod = simulation.selectNextModule();
        if (!mod)
            throw cTerminationException("scheduler interrupted while waiting");
        
        // execute event
        simulation.doOneEvent(mod);
        printEventBanner(mod);
        checkTimeLimits();
        if (sigint_received)
            throw cTerminationException("SIGINT or SIGTERM received, exiting");

    }
    catch (std::exception& e)
    {
        disable_tracing = false;
        stoppedWithException(e);
        displayException(e);
    }
    
    
    disable_tracing = false;
    stopClock();
    deinstallSignalHandler();
}
Example #7
0
MainWindow::~MainWindow()
{
    stopClock();
    stopCPU();
    delete ui;
}
Example #8
0
void MainWindow::stopExecution()
{
    stopClock();
    stopCPU();
}
Example #9
0
HighPrecisionClock::~HighPrecisionClock() {
    stopClock();
}
Example #10
0
int Detector::detectFaces(ClassifierInterface* ci, const std::string img_path, double ac, int draw, int save){	
	SubwindowGenerator sg(img_path,_wr,_shift_step);
	IntegralImage ii(img_path);

	startClock();
	ulong total_sw,total_faces;
	std::vector<Subwindow> lista = sg.generateSubwindows(_ng);
	stopClock("Generating Windows");

	total_faces=0;
	total_sw = lista.size();

	int res;		
	int cur_gen=-1;
	std::vector<int*> faces_boxes;
	std::vector<int*> scenes_boxes;
	startClock();
	for(register int i=0;i<lista.size();++i){		
		// printf("NEW SUBWINDOW\n");

		if(cur_gen!=lista[i]._cur_ng){
			ci->resize(lista[i]._ce);
			cur_gen = lista[i]._cur_ng;
		}

		if(ac<0){
			res = ci->isFace(ii,(lista[i]));
		}else{
			res = ci->isFace(ii,(lista[i]),ac);
		}

		if(res==1){						
			faces_boxes.push_back(new int[4]);
			lista[i].cropBox( faces_boxes[faces_boxes.size()-1] );		
			total_faces+=1;
		}else{
			scenes_boxes.push_back(new int[4]);
			lista[i].cropBox( scenes_boxes[scenes_boxes.size()-1] );			
		}
	}
	stopClock("Detection Time");

	if(draw==1){
		int** boxes_array = (int**) malloc(faces_boxes.size()*sizeof(int*));
		for(register int i=0;i<faces_boxes.size();i++){
			boxes_array[i] = faces_boxes[i];
		}
		std::string save_path = Config::PROJECT_PATH + "/analysis/detector_output/img_det.pgm";
		drawRectangles(img_path.c_str(),faces_boxes.size(),boxes_array,"white", save, save_path.c_str() );
		free(boxes_array);

		// int** boxes_array = (int**) malloc(scenes_boxes.size()*sizeof(int*));
		// for(register int i=0;i<scenes_boxes.size();i++){
		// 	boxes_array[i] = scenes_boxes[i];
		// }
		// drawRectangles(img_path.c_str(),scenes_boxes.size(),boxes_array,"red");
		// free(boxes_array);		
	}

	printf("\nSW: %lu FACES: %lu\n",total_sw,total_faces);
	return total_faces;
}