add timeFile + ignore last values
This commit is contained in:
parent
8ecdd37619
commit
e06c7602e0
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
BIN
Code-C/main
BIN
Code-C/main
Binary file not shown.
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,40 +109,51 @@ bool writeOneRawData(FILE *rawDataFile){
|
|||
quartet value;
|
||||
|
||||
if(fread(&buff, 26, 1, stdin)) {
|
||||
fprintf(rawDataFile , "%d,", millis());
|
||||
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();
|
||||
for (int i = 1; i < 9; i++){
|
||||
if(selectionCaptors[i-1]){
|
||||
value.octet1 = buff[3*i+1];
|
||||
value.octet2 = buff[3*i+2];
|
||||
value.octet3 = buff[3*i+3];
|
||||
value.octet4 = 0;
|
||||
|
||||
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));
|
||||
|
||||
if(i-1==lastIndex){
|
||||
fprintf(rawDataFile, "%d\n", values[i]/256);
|
||||
}
|
||||
else{
|
||||
fprintf(rawDataFile, "%d,", values[i]/256);
|
||||
//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 ###...#");
|
||||
} else {
|
||||
strncpy(buff, &buff[18], 8);
|
||||
strncpy(&buff[8], buff2, 18);
|
||||
}
|
||||
}
|
||||
int lastIndex = lastIndexCaptor();
|
||||
for (int i = 1; i < 9; i++){
|
||||
if(selectionCaptors[i-1]){
|
||||
value.octet1 = buff[3*i+1];
|
||||
value.octet2 = buff[3*i+2];
|
||||
value.octet3 = buff[3*i+3];
|
||||
value.octet4 = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
cptData++;
|
||||
//sleep(0.004); //simul freq here
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue