add timeFile + ignore last values
This commit is contained in:
parent
8ecdd37619
commit
e06c7602e0
|
@ -1,5 +1,5 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
all:
|
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
|
./main < ../02400031.TXT
|
|
@ -17,6 +17,7 @@ void averageCalculation(long **p, double averageArray[]){
|
||||||
averageArray[i] += p[i][j];
|
averageArray[i] += p[i][j];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
//printf("%f , %f\n", averageArray[i] , averageArray[i] / nRowRawData);
|
||||||
averageArray[i] /= nRowRawData;
|
averageArray[i] /= nRowRawData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ void printArrayData(long** p, int N, int M) {
|
||||||
for(i = 0 ; i < N ; i++){
|
for(i = 0 ; i < N ; i++){
|
||||||
printf("line n°%d : " , i);
|
printf("line n°%d : " , i);
|
||||||
for(int j = 0 ; j < M ; j++){
|
for(int j = 0 ; j < M ; j++){
|
||||||
printf("%d , " , p[i][j]);
|
printf("%ld , " , p[i][j]);
|
||||||
if(j==(M-1)) printf("\n");
|
if(j==(M-1)) printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,11 @@ extern int nRowRawData;
|
||||||
extern int nRowGR;
|
extern int nRowGR;
|
||||||
extern int nCol;
|
extern int nCol;
|
||||||
extern double freqEch;
|
extern double freqEch;
|
||||||
|
extern int nbRowBinFile;
|
||||||
|
extern int nbRowIgnore;
|
||||||
|
|
||||||
extern int cptFile;
|
extern int cptFile;
|
||||||
|
extern int cptValue;
|
||||||
extern double period;
|
extern double period;
|
||||||
extern double invTimeBandWidth;
|
extern double invTimeBandWidth;
|
||||||
|
|
||||||
|
|
BIN
Code-C/main
BIN
Code-C/main
Binary file not shown.
|
@ -14,12 +14,16 @@ int nRowGR = 150;
|
||||||
int nCol = 1;
|
int nCol = 1;
|
||||||
double freqEch = 250;
|
double freqEch = 250;
|
||||||
|
|
||||||
|
int nbRowBinFile = 900011;
|
||||||
|
int nbRowIgnore = 19;
|
||||||
|
|
||||||
Pqueue firstRawDataQueue;
|
Pqueue firstRawDataQueue;
|
||||||
//Captor 1 2 3 4 5 6 7 8
|
//Captor 1 2 3 4 5 6 7 8
|
||||||
bool selectionCaptors[] = {true,false,true,false,false,false,true,false};
|
bool selectionCaptors[] = {true,false,true,false,false,false,true,false};
|
||||||
|
|
||||||
int cptData = 0;
|
int cptData = 0;
|
||||||
int cptFile = 1;
|
int cptFile = 1;
|
||||||
|
int cptValue = 0;
|
||||||
|
|
||||||
double period = 0;
|
double period = 0;
|
||||||
double invTimeBandWidth = 0;
|
double invTimeBandWidth = 0;
|
||||||
|
@ -97,7 +101,7 @@ void *threadCalculGrowthRate(void * vargp){
|
||||||
growthRateFunction(dataLignPw,"growthRatePw.csv");
|
growthRateFunction(dataLignPw,"growthRatePw.csv");
|
||||||
growthRateFunction(dataLignPw,"growthRateAv.csv");
|
growthRateFunction(dataLignPw,"growthRateAv.csv");
|
||||||
}
|
}
|
||||||
//remove(fileName);
|
remove(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ int lastIndexCaptor(){
|
||||||
}
|
}
|
||||||
return lastIndex;
|
return lastIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief write one lign of rawData in the file @param rawDataFile (simulate of freq of the Vegetal Signals Captor)
|
* @brief write one lign of rawData in the file @param rawDataFile (simulate of freq of the Vegetal Signals Captor)
|
||||||
*
|
*
|
||||||
|
@ -108,40 +109,51 @@ bool writeOneRawData(FILE *rawDataFile){
|
||||||
quartet value;
|
quartet value;
|
||||||
|
|
||||||
if(fread(&buff, 26, 1, stdin)) {
|
if(fread(&buff, 26, 1, stdin)) {
|
||||||
fprintf(rawDataFile , "%d,", millis());
|
//printf("%d\n",cptValue);
|
||||||
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
|
if(cptValue < nbRowBinFile - nbRowIgnore){
|
||||||
if (!(fread(&buff2, 18, 1, stdin))) {
|
FILE *timeFile = fopen("timeFile.csv" , "a+");
|
||||||
fprintf(stderr, "Erreur lecture après ###...#");
|
fprintf(timeFile , "%ld\n", millis());
|
||||||
} else {
|
fclose(timeFile);
|
||||||
strncpy(buff, &buff[18], 8);
|
fprintf(rawDataFile , "%ld,", millis());
|
||||||
strncpy(&buff[8], buff2, 18);
|
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
|
||||||
|
if (!(fread(&buff2, 18, 1, stdin))) {
|
||||||
|
fprintf(stderr, "Erreur lecture après ###...#");
|
||||||
|
} else {
|
||||||
|
strncpy(buff, &buff[18], 8);
|
||||||
|
strncpy(&buff[8], buff2, 18);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
int lastIndex = lastIndexCaptor();
|
||||||
int lastIndex = lastIndexCaptor();
|
for (int i = 1; i < 9; i++){
|
||||||
for (int i = 1; i < 9; i++){
|
if(selectionCaptors[i-1]){
|
||||||
if(selectionCaptors[i-1]){
|
value.octet1 = buff[3*i+1];
|
||||||
value.octet1 = buff[3*i+1];
|
value.octet2 = buff[3*i+2];
|
||||||
value.octet2 = buff[3*i+2];
|
value.octet3 = buff[3*i+3];
|
||||||
value.octet3 = buff[3*i+3];
|
value.octet4 = 0;
|
||||||
value.octet4 = 0;
|
|
||||||
|
valbin[i] = buff[3*i+1]*256*256*256 + buff[3*i+2]*256*256 + buff[3*i+3]*256;
|
||||||
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));
|
||||||
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
|
||||||
|
|
||||||
if(i-1==lastIndex){
|
cptValue++;
|
||||||
fprintf(rawDataFile, "%d\n", values[i]/256);
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
fprintf(rawDataFile, "%d,", values[i]/256);
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cptData++;
|
|
||||||
//sleep(0.004); //simul freq here
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue