2022-06-09 17:34:24 +02:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "simulateFlux.h"
|
2022-06-01 12:32:04 +02:00
|
|
|
#include "power.h"
|
2022-06-07 14:28:32 +02:00
|
|
|
#include "initialParameters.h"
|
2022-06-10 15:05:04 +02:00
|
|
|
#include "queue.h"
|
2022-06-14 10:24:59 +02:00
|
|
|
#include "average.h"
|
2022-06-01 12:32:04 +02:00
|
|
|
|
2022-06-13 17:11:16 +02:00
|
|
|
bool rawDataWriteFlag;
|
2022-06-14 10:24:59 +02:00
|
|
|
int nRow = 500;
|
2022-06-14 18:01:52 +02:00
|
|
|
int nCol = 1;
|
2022-06-09 17:34:24 +02:00
|
|
|
double freqEch = 250;
|
|
|
|
|
2022-06-10 17:22:01 +02:00
|
|
|
Pqueue firstRawDataQueue;
|
2022-06-10 15:05:04 +02:00
|
|
|
|
2022-06-14 18:01:52 +02:00
|
|
|
bool selectionCaptors[] = {true,false,true,false,false,false,true,false};
|
2022-06-10 10:10:28 +02:00
|
|
|
|
2022-06-10 17:22:01 +02:00
|
|
|
int cptData = 0;
|
|
|
|
int cptFile = 1;
|
|
|
|
|
|
|
|
double period = 0;
|
|
|
|
double invTimeBandWidth = 0;
|
|
|
|
|
2022-06-14 10:24:59 +02:00
|
|
|
void *threadCalculPower(void *vargp){
|
2022-06-13 15:03:51 +02:00
|
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
2022-06-13 17:24:53 +02:00
|
|
|
char* fileName;
|
2022-06-13 17:11:16 +02:00
|
|
|
while(rawDataWriteFlag){
|
|
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
2022-06-13 17:24:53 +02:00
|
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
|
|
fileName = queueGetTabChar(rawDataQueue);
|
2022-06-14 18:01:52 +02:00
|
|
|
power(fileName);
|
2022-06-14 10:24:59 +02:00
|
|
|
remove(fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void *threadCalculAverage(void *vargp){
|
|
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
|
|
char* fileName;
|
|
|
|
while(rawDataWriteFlag){
|
|
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
|
|
fileName = queueGetTabChar(rawDataQueue);
|
2022-06-14 18:01:52 +02:00
|
|
|
average(fileName);
|
2022-06-14 10:24:59 +02:00
|
|
|
remove(fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void *threadCalculBoth(void *vargp){
|
|
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
|
|
char* fileName;
|
|
|
|
while(rawDataWriteFlag){
|
|
|
|
while(queueGetNextE(rawDataQueue) != NULL){
|
|
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
|
|
fileName = queueGetTabChar(rawDataQueue);
|
2022-06-14 18:01:52 +02:00
|
|
|
power(fileName);
|
|
|
|
average(fileName);
|
2022-06-14 10:24:59 +02:00
|
|
|
remove(fileName);
|
2022-06-13 17:11:16 +02:00
|
|
|
}
|
2022-06-13 15:03:51 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-10 17:22:01 +02:00
|
|
|
|
2022-06-15 12:01:51 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-14 18:01:52 +02:00
|
|
|
|
2022-06-01 12:32:04 +02:00
|
|
|
int main(int argc , char** argv){
|
2022-06-13 17:24:53 +02:00
|
|
|
|
2022-06-14 18:01:52 +02:00
|
|
|
for(int i = 0 ; i < 8 ; i++){
|
|
|
|
if(selectionCaptors[i]){
|
|
|
|
nCol++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-13 17:11:16 +02:00
|
|
|
rawDataWriteFlag = true;
|
2022-06-09 17:34:24 +02:00
|
|
|
|
2022-06-10 17:22:01 +02:00
|
|
|
period = 1 / freqEch;
|
|
|
|
invTimeBandWidth = 1 /(nRow * period);
|
2022-06-13 15:03:51 +02:00
|
|
|
firstRawDataQueue = queueCreateEmpty(); // change this for create empty
|
2022-06-10 15:50:27 +02:00
|
|
|
|
2022-06-09 17:34:24 +02:00
|
|
|
pthread_t rawData;
|
2022-06-14 10:46:12 +02:00
|
|
|
pthread_create(&rawData , NULL, threadSimulateFlux, (void *)&rawData);
|
2022-06-10 17:22:01 +02:00
|
|
|
|
2022-06-13 15:03:51 +02:00
|
|
|
pthread_t calcul;
|
2022-06-15 10:49:21 +02:00
|
|
|
pthread_create(&calcul , NULL, threadCalculBoth, (void *)&calcul);
|
2022-06-10 17:22:01 +02:00
|
|
|
|
2022-06-09 17:34:24 +02:00
|
|
|
pthread_exit(NULL);
|
2022-06-01 12:32:04 +02:00
|
|
|
}
|