diff --git a/Code-C/average.c b/Code-C/average.c index dd83fe7..425419c 100644 --- a/Code-C/average.c +++ b/Code-C/average.c @@ -10,10 +10,10 @@ * @param averageArray array where results are stocked */ void averageCalculation(long **p, double averageArray[]){ - for(int i = 0; i < nCol-1; i++){ + for(int i = 1; i < nCol; i++){ int j = 0; averageArray[i] = 0; - while(j < nRow){ + while(j < nRow -1){ averageArray[i] += p[i][j]; j++; } diff --git a/Code-C/getArray.c b/Code-C/getArray.c index 77a71ba..eeaac8e 100644 --- a/Code-C/getArray.c +++ b/Code-C/getArray.c @@ -70,9 +70,9 @@ bool checkArrayFullyFill(long **p, int N){ * @param N number of rows in array */ void freeArray(long **p, int N) { - int i; - for(i = 0 ; i < N ; i++) + for(int i = 0 ; i < N ; i++){ free(p[i]); + } free(p); } @@ -87,14 +87,12 @@ void freeArray(long **p, int N) { long **getRawDataArray(char* rawDataFileName){ long **p; p = get(nRow, nCol); - printf("before fill\n"); fillArrayWithRawData(rawDataFileName,p ,nRow, nCol); - printf("after fill\n"); - if(checkArrayFullyFill(p,nRow, nCol)){ + //if(checkArrayFullyFill(p,nRow)){ //clearRawData(N); return p; - } + /*} else{ return NULL; - } + }*/ } \ No newline at end of file diff --git a/Code-C/getArray.h b/Code-C/getArray.h index 6a0c836..02810a9 100644 --- a/Code-C/getArray.h +++ b/Code-C/getArray.h @@ -8,4 +8,4 @@ long **getRawDataArray(char *rawDataFileName); void printArrayData(long** p, int N, int M); void freeArray(long **p, int N); -bool checkArrayFullyFill(long **p, int N , int M); \ No newline at end of file +bool checkArrayFullyFill(long **p, int N ); \ No newline at end of file diff --git a/Code-C/initialParameters.h b/Code-C/initialParameters.h index 546b17a..96201f5 100644 --- a/Code-C/initialParameters.h +++ b/Code-C/initialParameters.h @@ -6,6 +6,8 @@ extern int nRow; extern int nCol; extern double freqEch; +extern int cptFile; + extern double period; extern double invTimeBandWidth; diff --git a/Code-C/main b/Code-C/main index 7652bd4..46f740e 100755 Binary files a/Code-C/main and b/Code-C/main differ diff --git a/Code-C/main.c b/Code-C/main.c index 6065f7c..a66d853 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -69,7 +69,6 @@ int main(int argc , char** argv){ nCol++; } } - printf("%d\n" , nCol); rawDataWriteFlag = true; @@ -81,7 +80,7 @@ int main(int argc , char** argv){ pthread_create(&rawData , NULL, threadSimulateFlux, (void *)&rawData); pthread_t calcul; - pthread_create(&calcul , NULL, threadCalculPower, (void *)&calcul); + pthread_create(&calcul , NULL, threadCalculBoth, (void *)&calcul); pthread_exit(NULL); } \ No newline at end of file diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index 07a350c..0016a69 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -83,6 +83,16 @@ int64_t millis() return ((int64_t) now.tv_sec) * 1000 + ((int64_t) now.tv_nsec) / 1000000; } + +int lastIndexCaptor(){ + int lastIndex = 0; + for(int i = 1 ; i < 8 ; i++){ + if(selectionCaptors[i]){ + lastIndex = i; + } + } + return lastIndex; +} /** * @brief write one lign of rawData in the file @param rawDataFile (simulate of freq of the Vegetal Signals Captor) * @@ -107,6 +117,7 @@ bool writeOneRawData(FILE *rawDataFile){ strncpy(&buff[8], buff2, 18); } } + int lastIndex = lastIndexCaptor(); for (int i = 1; i < 9; i++){ if(selectionCaptors[i]){ value.octet1 = buff[3*i+1]; @@ -117,7 +128,7 @@ 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)); - if(i==8){ + if(i==lastIndex){ fprintf(rawDataFile, "%d\n", values[i]/256); } else{