99 lines
2.4 KiB
C
99 lines
2.4 KiB
C
#include <pthread.h>
|
|
#include <stdbool.h>
|
|
#include "simulateFlux.h"
|
|
#include "power.h"
|
|
#include "initialParameters.h"
|
|
#include "queue.h"
|
|
#include "average.h"
|
|
|
|
bool rawDataWriteFlag;
|
|
int nRow = 500;
|
|
int nCol = 1;
|
|
double freqEch = 250;
|
|
|
|
Pqueue firstRawDataQueue;
|
|
|
|
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);
|
|
power(fileName);
|
|
remove(fileName);
|
|
}
|
|
}
|
|
}
|
|
|
|
void *threadCalculAverage(void *vargp){
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char* fileName;
|
|
while(rawDataWriteFlag){
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
average(fileName);
|
|
remove(fileName);
|
|
}
|
|
}
|
|
}
|
|
|
|
void *threadCalculBoth(void *vargp){
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char* fileName;
|
|
while(rawDataWriteFlag){
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
power(fileName);
|
|
average(fileName);
|
|
remove(fileName);
|
|
}
|
|
}
|
|
}
|
|
|
|
void *threadGrowthRate(void *vargp){
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char* fileName;
|
|
while(rawDataWriteFlag){
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
GrowthRate(fileName);
|
|
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 /(nRow * 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, threadCalculBoth, (void *)&calcul);
|
|
|
|
pthread_exit(NULL);
|
|
} |