add new thread growth rate
This commit is contained in:
parent
33115049f6
commit
9cd8d2bc7e
|
@ -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
|
|
@ -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){
|
||||||
|
|
|
@ -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
23
Code-C/growthRate.c
Normal 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
1
Code-C/growthRate.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
void growthRateFunction();
|
|
@ -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,13 +55,26 @@ 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 *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){
|
int main(int argc , char** argv){
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
void 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){
|
||||||
|
@ -38,4 +38,5 @@ void power(char* rawDataFileName){
|
||||||
appendDataInFile("powerData.csv",pw,nCol-1);
|
appendDataInFile("powerData.csv",pw,nCol-1);
|
||||||
freeArray(p,nRow);
|
freeArray(p,nRow);
|
||||||
}
|
}
|
||||||
|
return pw;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
void power(char* rawDataFileName);
|
double *powerFunction(char* rawDataFileName);
|
Loading…
Reference in a new issue