diff --git a/Code-C/Makefile b/Code-C/Makefile index a5707fc..ddfb997 100644 --- a/Code-C/Makefile +++ b/Code-C/Makefile @@ -3,6 +3,6 @@ CC = gcc all: # rm powerData.csv # $(CC) simulateFlux.c fileGestion.c getArray.c power.c main.c -lm -o main - $(CC) simulateFlux.c main.c -lpthread -o main + $(CC) queue.c simulateFlux.c main.c -lpthread -o main # $(CC) queue.c -o queue ./main < ../02400031.TXT \ No newline at end of file diff --git a/Code-C/initialParameters.h b/Code-C/initialParameters.h index e4bb21e..b91c822 100644 --- a/Code-C/initialParameters.h +++ b/Code-C/initialParameters.h @@ -1,4 +1,5 @@ #include +#include "queue.h" extern bool rawDataWriteFlag , stopFlag; extern int nRow; @@ -8,4 +9,4 @@ extern double freqEch; extern int selectionCaptors[]; extern int sizeSelectionArray; -extern bool flag; +extern Pqueue firstRawDataQueue; diff --git a/Code-C/main b/Code-C/main index c46c7d2..3b69e1e 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 7f0e0f2..cc23244 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -1,16 +1,17 @@ #include #include #include "simulateFlux.h" -#include "getArray.h" -#include "fileGestion.h" #include "power.h" #include "initialParameters.h" +#include "queue.h" bool rawDataWriteFlag = 0, stopFlag = 0; int nRow = 100000; int nCol = 9; double freqEch = 250; +Pqueue firstRawDataQueue = NULL; + int selectionCaptors[] = {1,2,3,4,5,6,7,8}; int sizeSelectionArray = 8; @@ -18,9 +19,10 @@ int main(int argc , char** argv){ double period = 1 / freqEch; double invTimeBandWidth = 1 /(nRow * period); - + Pqueue new = createE +/* pthread_t rawData; pthread_create(&rawData , NULL, simulateFlux, (void *)&rawData); pthread_exit(NULL); - while(power(nRow,nCol,period,invTimeBandWidth)){} +*/ } \ No newline at end of file diff --git a/Code-C/queue.c b/Code-C/queue.c index 91ccede..0d680d4 100644 --- a/Code-C/queue.c +++ b/Code-C/queue.c @@ -1,4 +1,5 @@ #include +#include #include #include "queue.h" @@ -23,7 +24,7 @@ typedef struct queue *Pqueue; * @param lenChar size of char array that will be created * @return Pqueue new element created */ -Pqueue createE(int lenChar){ +Pqueue createE(int lenChar , char* _tabChar){ Pqueue new = (Pqueue) malloc(sizeof(struct queue)); assert(new); /* ???? tab char create or give pointer ???*/ @@ -39,11 +40,33 @@ Pqueue createE(int lenChar){ * @param elem current element * @return Pqueue next element */ -Pqueue pNextE(Pqueue elem){ +Pqueue getNextE(Pqueue elem){ assert(elem); return elem->pNextE; } +int getCharLen(Pqueue elem){ + assert(elem); + return elem->charLen; +} + +char *gettabChar(Pqueue elem){ + assert(elem); + return elem->tabChar; +} + +Pqueue setCharLen(Pqueue elem , int _charLen){ + assert(elem); + elem->charLen = _charLen; +} + +Pqueue setTabChar(Pqueue elem , int _charLen , char *_tabChar){ + assert(elem); + elem->charLen = _charLen; + elem->tabChar = (char *) malloc(_charLen * sizeof(char)); + elem->tabChar = _tabChar; +} + /** * @brief remove and free the last element of queue * @@ -55,7 +78,7 @@ Pqueue rmLastE(Pqueue elem){ Pqueue tmp = elem, previous = NULL; while(elem->pNextE != NULL){ previous = tmp; - tmp = pNextE(tmp); + tmp = getNextE(tmp); } free(tmp->tabChar); free(tmp); @@ -104,7 +127,7 @@ Pqueue addLastQ(Pqueue elem, const char* str, int len){ Pqueue tmp = elem, previous = NULL; while(elem->pNextE != NULL){ previous = tmp; - tmp = pNextE(tmp); + tmp = getNextE(tmp); } tmp = createE(len); tmp->tabChar = str; @@ -112,3 +135,14 @@ Pqueue addLastQ(Pqueue elem, const char* str, int len){ return tmp; } +void printE(Pqueue elem){ + Pqueue next = getNextE(elem); + printf("File Name : %s \n(size of the file name : %d)\n",elem -> tabChar , elem -> charLen ); + if(next != NULL){ + printf("Next File : %s\n", next ->tabChar); + } + else{ + printf("No nextFile existing\n"); + } +} + diff --git a/Code-C/queue.h b/Code-C/queue.h index 0c14a50..5736138 100644 --- a/Code-C/queue.h +++ b/Code-C/queue.h @@ -1 +1,13 @@ typedef struct queue *Pqueue; +Pqueue createE(int lenChar); +Pqueue createEEmpty(); //create a new element but all variables in are null, use to create the first element of the queue in the main before define the elements in +// seter /getter pour la struct +// constructeur avec 2 paramètres : strlen et tabchar +Pqueue getNextE(Pqueue elem); +Pqueue setCharLen(Pqueue elem , int _charLen); +Pqueue setTabChar(Pqueue elem , int _charLen , char *_tabChar); +Pqueue rmLastE(Pqueue elem); +Pqueue rmFrstE(Pqueue elem); +Pqueue nextDelFrst(Pqueue elem); +Pqueue addLastQ(Pqueue elem, const char* str, int len); +void printE(Pqueue elem); \ No newline at end of file diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index 5c94eff..e5538eb 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -1,5 +1,6 @@ #include "simulateFlux.h" #include "initialParameters.h" +#include "queue.h" int cptData = 0; int cptFile = 1; @@ -30,7 +31,7 @@ char* convertIntegerToChar(int N) } char *createNewRawDataFileName(){ - char *fileName = "RawData"; + char *fileName = "../RawDataFiles/RawData"; char *extension = ".csv"; char *fileNumber = convertIntegerToChar(cptFile); @@ -117,6 +118,11 @@ bool writeOneRawData(FILE *rawDataFile){ void *simulateFlux(void *vargp){ char *fileName = createNewRawDataFileName(); FILE *rawDataFile = fopen(fileName,"w+"); + Pqueue rawDataQueue = createE(strlen(fileName)); + setTabChar(rawDataQueue , strlen(fileName) , fileName); + firstRawDataQueue = rawDataQueue; + printE(rawDataQueue); + while(writeOneRawData(rawDataFile)){ if(cptData == nRow){ fclose(rawDataFile); @@ -124,9 +130,12 @@ void *simulateFlux(void *vargp){ cptFile++; //create struct here char *fileName = createNewRawDataFileName(); - printf(fileName); - printf("\n"); FILE *rawDataFile = fopen(fileName,"w+"); + rawDataQueue = addLastQ(rawDataQueue , fileName , strlen(fileName)); + + printE(rawDataQueue); } } + printf("\n"); + printE(firstRawDataQueue); }