//
// C++ Implementation: CalculateProgress
//
// Description: 
//
//
// Author: Muylkens Toon <toon.muylkens@student.kuleuven.be>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "CalculateProgress.h"
// #include <stdio.h>
// #include <iostream>
// 
// using namespace std;
/**
*constructor
*/
CalculateProgress::CalculateProgress(QObject *parent, ConfigFileHandlerPowerTraining* filehandler, int nbPoints, QMutex *mutex):QThread(parent){
this->mutex=mutex;
this->setFileHandler(filehandler);
this->setNbPoints(nbPoints);
}

/**
*Method to set the pointer to the filehandler
*/
void CalculateProgress::setFileHandler(ConfigFileHandlerPowerTraining *file){
filehandler=file;
}

/**
*Method to set the number of poins to use
*/
void CalculateProgress::setNbPoints(int nbPoints){
NumberOfPoints=nbPoints;
}


/**
*Method neccecary for QThread
*/
 void CalculateProgress::run()
 {
	mutex->lock();
	t.start();
	float progressfloat = (filehandler->getprogress(NumberOfPoints));
 	QString progressstring = "";
 	progressstring.setNum(progressfloat);
	QString str;
	str.setNum(NumberOfPoints);
	emit finished(progressstring, QString(str));
	mutex->unlock();
	if(t.elapsed()>470){
	emit takingtoolong();
	}
 }
