merge add thread growth rate

This commit is contained in:
Aurélien Gauthier 2022-06-15 12:03:46 +02:00
commit c66535111d
8 changed files with 39 additions and 13 deletions

View file

@ -1,4 +1,5 @@
CC = gcc CC = gcc
all: all:
$(CC) -g fileGestion.c getArray.c average.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main $(CC) -g fileGestion.c getArray.c average.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main
./main < ../02400031.TXT

View file

@ -27,7 +27,7 @@ void averageCalculation(long **p, double averageArray[]){
* *
* @param rawDataFileName name of the raw data file to use to realize the calcul * @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); long **p = getRawDataArray(rawDataFileName);
double aver[nCol -1]; double aver[nCol -1];
if(p !=NULL){ if(p !=NULL){

View file

@ -1,4 +1,4 @@
#include <math.h> #include <math.h>
#include <stdbool.h> #include <stdbool.h>
void average(char* rawDataFileName); void averageThreadFunction(char* rawDataFileName);

23
Code-C/growthRate.c Normal file
View file

@ -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);
}

1
Code-C/growthRate.h Normal file
View file

@ -0,0 +1 @@
void growthRateFunction();

View file

@ -5,6 +5,7 @@
#include "initialParameters.h" #include "initialParameters.h"
#include "queue.h" #include "queue.h"
#include "average.h" #include "average.h"
#include "growthRate.h"
bool rawDataWriteFlag; bool rawDataWriteFlag;
int nRow = 500; int nRow = 500;
@ -28,7 +29,7 @@ void *threadCalculPower(void *vargp){
while(queueGetNextE(rawDataQueue) != NULL){ while(queueGetNextE(rawDataQueue) != NULL){
rawDataQueue = queueGetNextE(rawDataQueue); rawDataQueue = queueGetNextE(rawDataQueue);
fileName = queueGetTabChar(rawDataQueue); fileName = queueGetTabChar(rawDataQueue);
power(fileName); powerFunction(fileName);
remove(fileName); remove(fileName);
} }
} }
@ -41,7 +42,7 @@ void *threadCalculAverage(void *vargp){
while(queueGetNextE(rawDataQueue) != NULL){ while(queueGetNextE(rawDataQueue) != NULL){
rawDataQueue = queueGetNextE(rawDataQueue); rawDataQueue = queueGetNextE(rawDataQueue);
fileName = queueGetTabChar(rawDataQueue); fileName = queueGetTabChar(rawDataQueue);
average(fileName); averageThreadFunction(fileName);
remove(fileName); remove(fileName);
} }
} }
@ -54,27 +55,27 @@ void *threadCalculBoth(void *vargp){
while(queueGetNextE(rawDataQueue) != NULL){ while(queueGetNextE(rawDataQueue) != NULL){
rawDataQueue = queueGetNextE(rawDataQueue); rawDataQueue = queueGetNextE(rawDataQueue);
fileName = queueGetTabChar(rawDataQueue); fileName = queueGetTabChar(rawDataQueue);
power(fileName); powerFunction(fileName);
average(fileName); averageThreadFunction(fileName);
remove(fileName); remove(fileName);
} }
} }
} }
void *threadGrowthRate(void *vargp){ void *threadCalculGrowthRate(void * vargp){
Pqueue rawDataQueue = firstRawDataQueue; Pqueue rawDataQueue = firstRawDataQueue;
char* fileName; char* fileName;
while(rawDataWriteFlag){ while(rawDataWriteFlag){
while(queueGetNextE(rawDataQueue) != NULL){ while(queueGetNextE(rawDataQueue) != NULL){
rawDataQueue = queueGetNextE(rawDataQueue); rawDataQueue = queueGetNextE(rawDataQueue);
fileName = queueGetTabChar(rawDataQueue); fileName = queueGetTabChar(rawDataQueue);
GrowthRate(fileName); double *dataLign = powerFunction(fileName);
growthRateFunction(dataLign);
remove(fileName); remove(fileName);
} }
} }
} }
int main(int argc , char** argv){ int main(int argc , char** argv){
for(int i = 0 ; i < 8 ; i++){ for(int i = 0 ; i < 8 ; i++){

View file

@ -5,7 +5,7 @@
#include "queue.h" #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 p array with all the values that will be used for the calcul
* @param powerArray array where results are stocked * @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 N number of rows in the file
* @param M number of columns in the file * @param M number of columns in the file
*/ */
double * power(char* rawDataFileName){ double *powerFunction(char* rawDataFileName){
long **p = getRawDataArray(rawDataFileName); long **p = getRawDataArray(rawDataFileName);
double pw[nCol-1]; double pw[nCol-1];
if(p !=NULL){ if(p !=NULL){

View file

@ -1,4 +1,4 @@
#include <math.h> #include <math.h>
#include <stdbool.h> #include <stdbool.h>
void power(char* rawDataFileName); double *powerFunction(char* rawDataFileName);