diff --git a/Code-C/Makefile b/Code-C/Makefile index 0328aff..8b874a0 100644 --- a/Code-C/Makefile +++ b/Code-C/Makefile @@ -1,4 +1,5 @@ CC = gcc all: - $(CC) -g fileGestion.c getArray.c average.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main \ No newline at end of file + $(CC) -g fileGestion.c getArray.c average.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main + ./main < ../02400031.TXT \ No newline at end of file diff --git a/Code-C/average.c b/Code-C/average.c index 425419c..e9d8706 100644 --- a/Code-C/average.c +++ b/Code-C/average.c @@ -27,7 +27,7 @@ void averageCalculation(long **p, double averageArray[]){ * * @param rawDataFileName name of the raw data file to use to realize the calcul */ -void average(char* rawDataFileName){ +void averageThreadFunction(char* rawDataFileName){ long **p = getRawDataArray(rawDataFileName); double aver[nCol -1]; if(p !=NULL){ diff --git a/Code-C/average.h b/Code-C/average.h index 25be1e0..b130865 100644 --- a/Code-C/average.h +++ b/Code-C/average.h @@ -1,4 +1,4 @@ #include #include -void average(char* rawDataFileName); \ No newline at end of file +void averageThreadFunction(char* rawDataFileName); \ No newline at end of file diff --git a/Code-C/growthRate.c b/Code-C/growthRate.c new file mode 100644 index 0000000..951e2c2 --- /dev/null +++ b/Code-C/growthRate.c @@ -0,0 +1,23 @@ +#include "initialParameters.h" +#include "fileGestion.h" +#include "getArray.h" +/** + * @brief calculate de growth rate between to point next to each other + * + * @param dataArray array with data of points next to each other for each captor (dim : 2 * nCols) + * @param gRateArray array that contaigns results of the growth ratecalculation + */ +void growthRateCalculation(double **dataArray , double *gRateArray){ + double gRate = 0; + for(int i = 0 ; i < nCol-1 ; i++){ + gRate = (dataArray[1][i] - dataArray[2][i]) / period; + } +} + +void growthRateFunction(double *dataLign){ + double **dataArray; + //initialization + fill + double gRateArray[nCol-1]; + growthRateCalculation(dataArray , gRateArray); + appendDataInFile("growthRate.csv",gRateArray , nCol-1); +} \ No newline at end of file diff --git a/Code-C/growthRate.h b/Code-C/growthRate.h new file mode 100644 index 0000000..3a1f118 --- /dev/null +++ b/Code-C/growthRate.h @@ -0,0 +1 @@ +void growthRateFunction(); \ No newline at end of file diff --git a/Code-C/main.c b/Code-C/main.c index 1264c28..dcefc4b 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -5,6 +5,7 @@ #include "initialParameters.h" #include "queue.h" #include "average.h" +#include "growthRate.h" bool rawDataWriteFlag; int nRow = 500; @@ -28,7 +29,7 @@ void *threadCalculPower(void *vargp){ while(queueGetNextE(rawDataQueue) != NULL){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); - power(fileName); + powerFunction(fileName); remove(fileName); } } @@ -41,7 +42,7 @@ void *threadCalculAverage(void *vargp){ while(queueGetNextE(rawDataQueue) != NULL){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); - average(fileName); + averageThreadFunction(fileName); remove(fileName); } } @@ -54,27 +55,27 @@ void *threadCalculBoth(void *vargp){ while(queueGetNextE(rawDataQueue) != NULL){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); - power(fileName); - average(fileName); + powerFunction(fileName); + averageThreadFunction(fileName); remove(fileName); } } } -void *threadGrowthRate(void *vargp){ +void *threadCalculGrowthRate(void * vargp){ Pqueue rawDataQueue = firstRawDataQueue; char* fileName; while(rawDataWriteFlag){ while(queueGetNextE(rawDataQueue) != NULL){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); - GrowthRate(fileName); + double *dataLign = powerFunction(fileName); + growthRateFunction(dataLign); remove(fileName); } } } - int main(int argc , char** argv){ for(int i = 0 ; i < 8 ; i++){ diff --git a/Code-C/power.c b/Code-C/power.c index 6ac6709..7e6b1b3 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -5,7 +5,7 @@ #include "queue.h" /** - * @brief realize the power calcul + * @brief realize the powerThreadFunction calcul * * @param p array with all the values that will be used for the calcul * @param powerArray array where results are stocked @@ -30,7 +30,7 @@ void powerCalculation(long **p, double powerArray[]){ * @param N number of rows in the file * @param M number of columns in the file */ -double * power(char* rawDataFileName){ +double *powerFunction(char* rawDataFileName){ long **p = getRawDataArray(rawDataFileName); double pw[nCol-1]; if(p !=NULL){ diff --git a/Code-C/power.h b/Code-C/power.h index 85480f9..a2a134e 100644 --- a/Code-C/power.h +++ b/Code-C/power.h @@ -1,4 +1,4 @@ #include #include -void power(char* rawDataFileName); \ No newline at end of file +double *powerFunction(char* rawDataFileName); \ No newline at end of file