125 lines
3.7 KiB
C
125 lines
3.7 KiB
C
#include <pthread.h>
|
|
#include <stdbool.h>
|
|
#include "simulateFlux.h"
|
|
#include "power.h"
|
|
#include "initialParameters.h"
|
|
#include "queue.h"
|
|
#include "average.h"
|
|
#include "growthRate.h"
|
|
#include "getArray.h"
|
|
|
|
bool rawDataWriteFlag;
|
|
int nRowRawData = 500;
|
|
int nRowGR = 150;
|
|
int nCol = 1;
|
|
double freqEch = 250;
|
|
|
|
Pqueue firstRawDataQueue;
|
|
//Captor 1 2 3 4 5 6 7 8
|
|
bool selectionCaptors[] = {true,false,true,false,false,false,true,false};
|
|
|
|
int cptData = 0;
|
|
int cptFile = 1;
|
|
|
|
double period = 0;
|
|
double invTimeBandWidth = 0;
|
|
|
|
void *threadCalculPower(void *vargp){
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char* fileName;
|
|
while(rawDataWriteFlag){
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
powerFunction(fileName, NULL);
|
|
remove(fileName);
|
|
}
|
|
}
|
|
}
|
|
|
|
void *threadCalculAverage(void *vargp){
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char* fileName;
|
|
while(rawDataWriteFlag){
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
averageFunction(fileName, NULL);
|
|
remove(fileName);
|
|
}
|
|
}
|
|
}
|
|
|
|
void *threadCalculBoth(void *vargp){
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char* fileName;
|
|
while(rawDataWriteFlag){
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
powerFunction(fileName, NULL);
|
|
averageFunction(fileName , NULL);
|
|
remove(fileName);
|
|
}
|
|
}
|
|
}
|
|
|
|
void *threadCalculGrowthRate(void * vargp){
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char* fileName;
|
|
//double pw[nCol-1];
|
|
double **dataLignPw = getDoubleArray(2,nCol);
|
|
double **dataLignAv = getDoubleArray(2,nCol);
|
|
|
|
int i = 0;
|
|
while(rawDataWriteFlag){
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
if(i < 2){
|
|
if(i == 1){
|
|
powerFunction(fileName, dataLignPw);
|
|
averageFunction(fileName , dataLignAv);
|
|
growthRateFunction(dataLignPw , "growthRatePw.csv");
|
|
growthRateFunction(dataLignPw,"growthRateAv.csv");
|
|
}else{
|
|
averageFunction(fileName , dataLignAv);
|
|
powerFunction(fileName, dataLignPw);
|
|
}
|
|
i++;
|
|
}else{
|
|
for(int y = 0; y < (nCol-1); y++){
|
|
dataLignPw[0][y] = dataLignPw[1][y];
|
|
dataLignAv[0][y] = dataLignAv[1][y];
|
|
}
|
|
powerFunction(fileName, dataLignPw);
|
|
averageFunction(fileName , dataLignAv);
|
|
growthRateFunction(dataLignPw,"growthRatePw.csv");
|
|
growthRateFunction(dataLignPw,"growthRateAv.csv");
|
|
}
|
|
//remove(fileName);
|
|
}
|
|
}
|
|
}
|
|
|
|
int main(int argc , char** argv){
|
|
|
|
for(int i = 0 ; i < 8 ; i++){
|
|
if(selectionCaptors[i]){
|
|
nCol++;
|
|
}
|
|
}
|
|
|
|
rawDataWriteFlag = true;
|
|
|
|
period = 1 / freqEch;
|
|
invTimeBandWidth = 1 /(nRowRawData * period);
|
|
firstRawDataQueue = queueCreateEmpty(); // change this for create empty
|
|
|
|
pthread_t rawData;
|
|
pthread_create(&rawData , NULL, threadSimulateFlux, (void *)&rawData);
|
|
pthread_t calcul;
|
|
pthread_create(&calcul , NULL, threadCalculGrowthRate, (void *)&calcul);
|
|
|
|
pthread_exit(NULL);
|
|
} |