add timeFile + ignore last values

This commit is contained in:
quentin.perret 2022-06-17 17:38:53 +02:00
parent 8ecdd37619
commit e06c7602e0
7 changed files with 54 additions and 35 deletions

View file

@ -1,5 +1,5 @@
CC = gcc
all:
$(CC) -g fileGestion.c getArray.c average.c growthRate.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main
$(CC) -g -Wall fileGestion.c getArray.c average.c growthRate.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main
./main < ../02400031.TXT

View file

@ -17,6 +17,7 @@ void averageCalculation(long **p, double averageArray[]){
averageArray[i] += p[i][j];
j++;
}
//printf("%f , %f\n", averageArray[i] , averageArray[i] / nRowRawData);
averageArray[i] /= nRowRawData;
}
}

View file

@ -53,7 +53,7 @@ void printArrayData(long** p, int N, int M) {
for(i = 0 ; i < N ; i++){
printf("line n°%d : " , i);
for(int j = 0 ; j < M ; j++){
printf("%d , " , p[i][j]);
printf("%ld , " , p[i][j]);
if(j==(M-1)) printf("\n");
}
}

View file

@ -6,9 +6,11 @@ extern int nRowRawData;
extern int nRowGR;
extern int nCol;
extern double freqEch;
extern int nbRowBinFile;
extern int nbRowIgnore;
extern int cptFile;
extern int cptValue;
extern double period;
extern double invTimeBandWidth;

Binary file not shown.

View file

@ -14,12 +14,16 @@ 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;
@ -97,7 +101,7 @@ void *threadCalculGrowthRate(void * vargp){
growthRateFunction(dataLignPw,"growthRatePw.csv");
growthRateFunction(dataLignPw,"growthRateAv.csv");
}
//remove(fileName);
remove(fileName);
}
}
}

View file

@ -93,6 +93,7 @@ int lastIndexCaptor(){
}
return lastIndex;
}
/**
* @brief write one lign of rawData in the file @param rawDataFile (simulate of freq of the Vegetal Signals Captor)
*
@ -108,7 +109,12 @@ bool writeOneRawData(FILE *rawDataFile){
quartet value;
if(fread(&buff, 26, 1, stdin)) {
fprintf(rawDataFile , "%d,", millis());
//printf("%d\n",cptValue);
if(cptValue < nbRowBinFile - nbRowIgnore){
FILE *timeFile = fopen("timeFile.csv" , "a+");
fprintf(timeFile , "%ld\n", millis());
fclose(timeFile);
fprintf(rawDataFile , "%ld,", millis());
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
if (!(fread(&buff2, 18, 1, stdin))) {
fprintf(stderr, "Erreur lecture après ###...#");
@ -127,23 +133,29 @@ bool writeOneRawData(FILE *rawDataFile){
valbin[i] = buff[3*i+1]*256*256*256 + buff[3*i+2]*256*256 + buff[3*i+3]*256;
memcpy(&values[i], &valbin[i], sizeof(uint32_t));
FILE* allRawDataFile = fopen("AllRawData.csv" , "a+");
if(i-1==lastIndex){
fprintf(rawDataFile, "%d\n", values[i]/256);
fprintf(allRawDataFile, "%d\n", values[i]/256);
}
else{
fprintf(rawDataFile, "%d,", values[i]/256);
fprintf(allRawDataFile, "%d,", values[i]/256);
}
fclose(allRawDataFile);
}
}
cptData++;
//sleep(0.004); //simul freq here
cptValue++;
return true;
}
else {
return false;
}
}
}
void *threadSimulateFlux(void *vargp){