示例#1
0
void *monitor_init_process(int *argc, char **argv, void *data) {

	printf("#### init sampling driver - Pid is %i #### \n", getpid());

	assingContinuousThreadId();
	initShadowStack();

	initMeasurement();
	printResultsHeader();

	// warmup libtiming
	startMeasurement();
	stopMeasurement();
//	printResults("warmup");
	startMeasurement();
	stopMeasurement();
//	printResults("warmup");
	startMeasurement();
	stopMeasurement();
//	printResults("warmup");

	startMeasurement();


	return NULL;
}
示例#2
0
文件: gol.c 项目: FarK/GameOfLife
void iteration(struct GOL *gol)
{
	struct Cell *cell;
	unsigned int i;
	unsigned int count;
	unsigned int threadNum;
	double ccTime, wupTime, thTime;

	// TODO: it can be multithread?
	reviveCells(&gol->toRevive[0], gol->world);
	killCells(&gol->toKill[0], gol->world);

	ccTime = startMeasurement();
	#pragma omp parallel shared(gol) private(cell, count, threadNum, thTime)
	{
		thTime = startMeasurement();

		threadNum = omp_get_thread_num();

		for (cell = wit_first_split(&count, threadNum, gol->world);
		     wit_done_split(count, gol->world);
		     cell = wit_next_split(cell, &count, gol->numThreads))
		{
			switch (checkRule(cell, gol->rule)) {
			case GOL_REVIVE:
				addToList(cell, &gol->toRevive[threadNum]);
				break;
			case GOL_KILL:
				addToList(cell, &gol->toKill[threadNum]);
				break;
			case GOL_SURVIVE:
			case GOL_KEEP_DEAD:
			default:
				break;
			}
		}

		endMeasurement(thTime, threads[threadNum], gol->stats);
	}
	endMeasurement(ccTime, cellChecking, gol->stats);

	wupTime = startMeasurement();
	// Add lists
	for (i = 0; i < gol->numThreads; ++i) {
		reviveCells(&gol->toRevive[i], gol->world);
		freeList(&gol->toRevive[i]);
	}

	// Free lists
	for (i = 0; i < gol->numThreads; ++i) {
		killCells(&gol->toKill[i], gol->world);
		freeList(&gol->toKill[i]);
	}
	endMeasurement(wupTime, worldUpdate, gol->stats);
}
示例#3
0
void LevellingUtil::start()
{
    if(!m_isMeasuring) {
        startMeasurement();

        // Set up timeout timer
        connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(timeout()));
        //Set timeout to max time of measurement + 10 secs
        m_timeoutTimer.start(std::max(m_accelMeasurementCount * m_accelMeasurementRate, m_gyroMeasurementCount * m_gyroMeasurementRate) + 10000);
    }
}
示例#4
0
void ultraSonic_update(void)
{	
	error = 0;
	isMeasurementFinished = 0;

	timers_timer1Reset();

	startMeasurement(SENSOR0_TRIG_BIT);

	waitForResult();//!!!

	if(error)
		distances[0] = INFINITE_DISTANCE;
}
示例#5
0
float DS18B20::startAndWaitForTemperature(byte sensorIndex)
{
	startMeasurement(sensorIndex);
	delay(750);
	return getTemperature(sensorIndex);
}
示例#6
0
/*
This function initiates the connection to the serial port. If the connection is successful return 1, otherwise return -1
*/
int Pulsecor::connectToDevice(int dir)
{
//	std::vector<std::string> friendlyNames;
//	std::vector<unsigned int> ports;
//	if (CEnumerateSerial::UsingSetupAPI1(ports, friendlyNames))
//	{
//		for (size_t i=0; i<ports.size(); i++)
//		  _tprintf(_T("COM%d <%s>\n"), ports[i], friendlyNames[i].c_str());
//	}
	bool Done = serial.initialiseSerialPort(9600);
	if(!Done){
		return -1;
	}
	bool Connected  = false;
	char* zComNum = new char[20];
	std::string zComName = "";
	unsigned long len = 1024;
//    LPTSTR zbuffer = (LPTSTR)malloc(len * sizeof(TCHAR));

//	if(dir == 1)
//	{
//		int comPort = 0;
//		for ( size_t i = 0; i < ports.size(); i++) 
		//while(!Connected && comPort <= 20)
//		{			
//				comPort = ports[i];
				/*printf("Now checking port Number:  %d \n",comPort);
			
				sprintf(zComNum,"COM%d",comPort);
				DWORD result = QueryDosDevice((LPCSTR)zComNum, zbuffer, len);
				if(result == 0)
				{ // failed 
					DWORD err = ::GetLastError();
					if(err == ERROR_INSUFFICIENT_BUFFER)
					{ // reallocate 
						 len *= 2;
						 zbuffer = (LPTSTR)realloc(zbuffer, len * sizeof(TCHAR));
						 continue;
					} // reallocate 
				}
				// Convert a TCHAR string to a LPCSTR
				//CT2CA pszConvertedAnsiString (sPort);
				//zComName = std::string(pszConvertedAnsiString);					
				zComName = zComNum;					
				printf("Now checking port Name (1) :  %s \n",zbuffer);								
				//std::string str2 ("ProlificSerial");*/
//				std::string str2 ("ATEN");
//				size_t found;
				//found=zComName.find(str2);
//				found=friendlyNames[i].find(str2);
				
//				if (found!=std::string::npos)
	if(true){	
		int comPort=0;
		int res = serial.openComPort(comPort);
		if (res != -1) {
			usleep(600000);
			startMeasurement(170);
			//status.currentMode=3;
			sleep(3);
			int ret1 = pthread_create(&read_thread,NULL, &Pulsecor::threadFunction, this);
			sleep(6);								
			if(!(status.currentMode >2 && status.currentMode<6))
			{
				cout<<"canceled"<<endl;
				cancelMeasurement();
				cout<<"error finding comport"<<endl;							
				//comPort += 1;
			}
			else {
				std::cout << " connected to port " <<endl;// comPort << std::endl;
				Connected = true;
			}
		}
	}else{
		Connected = false;
	}  
				//if (Connected)
				//	break;
		//}
	//}
	/*else
	{
		int comPort = 20;
		while(!Connected && comPort >= 3)
		{
				printf("Now checking port Number:  %d \n",comPort);
				sprintf(zComNum,"COM%d",comPort);
				DWORD result = QueryDosDevice((LPCSTR)zComNum, zbuffer, len);
				if(result == 0)
				{ // failed 
					DWORD err = ::GetLastError();
					if(err == ERROR_INSUFFICIENT_BUFFER)
					{ // reallocate 
						 len *= 2;
						 zbuffer = (LPTSTR)realloc(zbuffer, len * sizeof(TCHAR));
						 continue;
					} // reallocate 
				}
				zComName = zbuffer;					
				printf("Now checking port Name (1) :  %s \n",zbuffer);								
				std::string str2 ("ProlificSerial");
				size_t found;
				found=zComName.find(str2);
				if (found!=std::string::npos)
				{		
					int res = serial.openComPort(comPort);
					if (res != -1 ) {
						int ret1 = pthread_create(&read_thread,NULL, &Pulsecor::threadFunction, this);
						Connected = true;
					}
					else comPort -= 1;
				}
				else
				{  
					//free(zbuffer);
					Connected = false;
					comPort -= 1;
				}  
		}

	}*/

	//free(zbuffer);
	//delete[] zComNum;
	Connected =true;
	if(Connected) return 1; else return -1;
}