add new thread growth rate

This commit is contained in:
quentin.perret 2022-06-15 11:57:15 +02:00
parent 33115049f6
commit 9cd8d2bc7e
8 changed files with 50 additions and 10 deletions

View file

@ -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
$(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
*/
void average(char* rawDataFileName){
void averageThreadFunction(char* rawDataFileName){
long **p = getRawDataArray(rawDataFileName);
double aver[nCol -1];
if(p !=NULL){

View file

@ -1,4 +1,4 @@
#include <math.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 "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,13 +55,26 @@ 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 *threadCalculGrowthRate(void * vargp){
Pqueue rawDataQueue = firstRawDataQueue;
char* fileName;
while(rawDataWriteFlag){
while(queueGetNextE(rawDataQueue) != NULL){
rawDataQueue = queueGetNextE(rawDataQueue);
fileName = queueGetTabChar(rawDataQueue);
double *dataLign = powerFunction(fileName);
growthRateFunction(dataLign);
remove(fileName);
}
}
}
int main(int argc , char** argv){

View file

@ -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
*/
void power(char* rawDataFileName){
double *powerFunction(char* rawDataFileName){
long **p = getRawDataArray(rawDataFileName);
double pw[nCol-1];
if(p !=NULL){
@ -38,4 +38,5 @@ void power(char* rawDataFileName){
appendDataInFile("powerData.csv",pw,nCol-1);
freeArray(p,nRow);
}
return pw;
}

View file

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