177 lines
4.6 KiB
C
177 lines
4.6 KiB
C
#include <pthread.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "include/simulateFlux.h"
|
|
#include "include/power.h"
|
|
#include "include/initialParameters.h"
|
|
#include "include/queue.h"
|
|
#include "include/average.h"
|
|
#include "include/growthRate.h"
|
|
#include "include/getArray.h"
|
|
|
|
bool rawDataWriteFlag;
|
|
int nRowRawData = 5000;
|
|
int nRowGR = 150;
|
|
int nCol = 1;
|
|
double freqEch = 250;
|
|
|
|
int nbRowBinFile = 900011;
|
|
int nbRowIgnore = 19;
|
|
|
|
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;
|
|
int cptValue = 0;
|
|
|
|
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);
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void *threadCalculAverage(void *vargp)
|
|
{
|
|
Pqueue rawDataQueue = firstRawDataQueue;
|
|
char *fileName;
|
|
|
|
while (rawDataWriteFlag)
|
|
{
|
|
while (queueGetNextE(rawDataQueue) != NULL)
|
|
{
|
|
rawDataQueue = queueGetNextE(rawDataQueue);
|
|
fileName = queueGetTabChar(rawDataQueue);
|
|
printf("%s\n", fileName);
|
|
averageFunction(fileName, NULL);
|
|
remove(fileName);
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
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);
|
|
printf("%s\n", fileName);
|
|
if (i < 2)
|
|
{
|
|
if (i == 1)
|
|
{
|
|
powerFunction(fileName, dataLignPw);
|
|
averageFunction(fileName, dataLignAv);
|
|
growthRateFunction(dataLignPw, "growthRatePw.csv");
|
|
growthRateFunction(dataLignAv, "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);
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
if (selectionCaptors[i])
|
|
{
|
|
nCol++;
|
|
}
|
|
}
|
|
printf("%d", nCol);
|
|
|
|
rawDataWriteFlag = true;
|
|
|
|
period = 1 / freqEch;
|
|
invTimeBandWidth = 1 / (nRowRawData * period);
|
|
firstRawDataQueue = queueCreateEmpty(); // change this for create empty
|
|
|
|
pthread_t rawData;
|
|
if (pthread_create(&rawData, NULL, threadSimulateFlux, "threadSimulflux") != 0)
|
|
{
|
|
perror("threadSimulflux() error");
|
|
exit(1);
|
|
}
|
|
|
|
pthread_t calculAverage;
|
|
if (pthread_create(&calculAverage, NULL, threadCalculAverage, "threadCalculAverage"))
|
|
{
|
|
perror("threadCalculAverage() error");
|
|
exit(1);
|
|
}
|
|
|
|
// pthread_t calculGrowthRate;
|
|
// if (pthread_create(&calculGrowthRate, NULL, threadCalculGrowthRate, "threadCalculGrowthRate"))
|
|
// {
|
|
// perror("threadcalculGrowthRate() error");
|
|
// exit(1);
|
|
// }
|
|
|
|
pthread_exit(NULL);
|
|
} |