diff --git a/Code-C/getArray.c b/Code-C/getArray.c index 8b2087c..7389042 100644 --- a/Code-C/getArray.c +++ b/Code-C/getArray.c @@ -15,27 +15,23 @@ long **get(int N, int M) /* Allocate the array */ void fillArrayWithRawData(char *rawDataFileName,long** p, int N, int M) { int i, j; - char *buffer; size_t bufsize = 200; buffer = (char *)malloc(bufsize * sizeof(char)); char* token; FILE *f = fopen(rawDataFileName,"r"); + for(i = 0 ; i < N ; i++){ if (!getline(&buffer, &bufsize, f)) break; // condition d'arret de la boucle si fichier fini - //printf("buffer : %s token : ",buffer); j = 0; while((token = strsep(&buffer,",")) != NULL){ // séparation valeur par virgule initiale : csv - //printf(token); p[i][j] = atoi(token); - //printf("%d,", p[i][j]); - //printf("%d, " , p[i][j]); j++; } - //printf("\n\n"); } fclose(f); + } /** * @brief print all the element of a bidimensionnal array p of shape : N x M @@ -76,14 +72,11 @@ long **getRawDataArray(char* rawDataFileName , int N , int M){ long **p; p = get(N, M); fillArrayWithRawData(rawDataFileName,p ,N, M); - //printf("before test\n"); - if(checkArrayFullyFill(p,N,M)==0){ - //printf("after test 0\n"); + if(checkArrayFullyFill(p,N,M)){ clearRawData(N); return p; } else{ - //printf("after test 1\n"); return NULL; } } \ No newline at end of file diff --git a/Code-C/initialParameters.h b/Code-C/initialParameters.h index 9a2e2f4..ba11617 100644 --- a/Code-C/initialParameters.h +++ b/Code-C/initialParameters.h @@ -1,7 +1,7 @@ #include #include "queue.h" -extern bool rawDataWriteFlag , stopFlag; +extern bool rawDataWriteFlag; extern int nRow; extern int nCol; extern double freqEch; diff --git a/Code-C/main b/Code-C/main index fdb4b16..31dc9ce 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 a6c84b8..bccc3f9 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -5,7 +5,7 @@ #include "initialParameters.h" #include "queue.h" -bool rawDataWriteFlag = 0, stopFlag = 0; +bool rawDataWriteFlag; int nRow = 100000; int nCol = 9; double freqEch = 250; @@ -22,20 +22,21 @@ double period = 0; double invTimeBandWidth = 0; void *threadCalcul(void *vargp){ - printf("start thread calcul\n"); Pqueue rawDataQueue = firstRawDataQueue; - while(queueGetNextE(rawDataQueue) != NULL){ - printf("wile calcul\n"); - //pthread_mutex_lock(&mutex); - power(queueGetTabChar(rawDataQueue),nRow,nCol,period,invTimeBandWidth); - /*remove(queueGetTabChar(rawDataQueue)); - rawDataQueue = queueRmFrstE(rawDataQueue);*/ - - //pthread_mutex_unlock(&mutex); + while(rawDataWriteFlag){ + while(queueGetNextE(rawDataQueue) != NULL){ + char* fileName = queueGetTabChar(rawDataQueue); + //queuePrintE(rawDataQueue); + printf("%s\n",fileName); + power(fileName,nRow,nCol,period,invTimeBandWidth); + /*remove(queueGetTabChar(rawDataQueue)); + rawDataQueue = queueRmFrstE(rawDataQueue);*/ + } } } int main(int argc , char** argv){ + rawDataWriteFlag = true; period = 1 / freqEch; invTimeBandWidth = 1 /(nRow * period); @@ -45,7 +46,7 @@ int main(int argc , char** argv){ pthread_create(&rawData , NULL, simulateFlux, (void *)&rawData); pthread_t calcul; - //pthread_create(&calcul , NULL, threadCalcul, (void *)&calcul); + pthread_create(&calcul , NULL, threadCalcul, (void *)&calcul); pthread_exit(NULL); } \ No newline at end of file diff --git a/Code-C/power.c b/Code-C/power.c index 52153ec..4b58106 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -3,6 +3,7 @@ #include "fileGestion.h" #include "initialParameters.h" #include "queue.h" +#include void powerCalculation(long **p, double powerArray[] , int N, int M , double period , double invTimeBandwidth){ for(int i = 0; i < M-1; i++){ diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index 57f3596..28e1980 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -114,7 +114,6 @@ bool writeOneRawData(FILE *rawDataFile){ } void *simulateFlux(void *vargp){ - printf("start thread simul\n"); char *fileName = createNewRawDataFileName(); FILE *rawDataFile = fopen(fileName,"w+"); @@ -131,5 +130,6 @@ void *simulateFlux(void *vargp){ FILE *rawDataFile = fopen(fileName,"w+"); } } - queuePrintWholeQ(firstRawDataQueue); + //queuePrintWholeQ(firstRawDataQueue); + rawDataWriteFlag = false; }