From 75639d3c4a4dcc01f137ff01306db24fdcb830b7 Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Mon, 13 Jun 2022 15:03:51 +0200 Subject: [PATCH] maj queue debug simul --- Code-C/Makefile | 5 ++-- Code-C/main | Bin 24400 -> 24632 bytes Code-C/main.c | 21 +++++++++++---- Code-C/power.c | 14 ---------- Code-C/power.h | 2 +- Code-C/queue.c | 60 +++++++++++++++++++++++++----------------- Code-C/queue.h | 31 +++++++++++----------- Code-C/rmRawData.sh | 6 +++++ Code-C/simulateFlux.c | 18 ++++++------- Code-C/simulateFlux.h | 2 +- 10 files changed, 86 insertions(+), 73 deletions(-) create mode 100644 Code-C/rmRawData.sh diff --git a/Code-C/Makefile b/Code-C/Makefile index de97bc3..abeb975 100644 --- a/Code-C/Makefile +++ b/Code-C/Makefile @@ -1,8 +1,7 @@ CC = gcc all: -# rm powerData.csv -# $(CC) simulateFlux.c fileGestion.c getArray.c power.c main.c -lm -o main $(CC) fileGestion.c getArray.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main -# $(CC) queue.c -o queue + +# $(CC) queue.c simulateFlux.c main.c -lm -lpthread -o main ./main < ../02400031.TXT \ No newline at end of file diff --git a/Code-C/main b/Code-C/main index 60acc4fafe389afe3f717d9c2e598f1b01d67fcd..f483ae6ca02198123fe1cdfdd62fa15217f4bffb 100755 GIT binary patch delta 7525 zcmZ`;3sh7`ny%Z>2nKA>U^nvURv_XNP|#>ZK|n7VB=|tZ7ZPa#vp^JK$z*lg4AI!z zc0_A7F*Ca3%p_Si$?SoUNmwU|7~O!AIU`Os3Fe6oNjgC%#F&H_iOr6vB zuls#p{q@)5)~&kT^QzX-skPX~v++!%Y-w1>`a{#74yy{6w^fHOrj9*klQ+j~e7rV0 ztS407_V5Dj)a0r;N;%3d(j>l!PcuDx`@Oe@-rJ@fu6*Zlx2x~c_b1}p7LDURQ&P-i zs7M(?YV9{{4`U|6rtsvT8QMa=GN_Da2itgekgmPJ9}2Q+gW~!Y&k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Eaq5m;@&q@Z1LdTYasQbSk@>V){A1q{z>;tw7UfyF-MEsBR*&t(_C8gi+b~W}b zFvEn6!(XM2P3lBT{6oB@SUDvKnI!RUwr!#86NF6REf!0uQ%awf(v@7g9#Rvr5F&dk zh2&XUyg)7ZwX|IzM_`Q<|5oDXiiZ(yxIt>ny}Dr1y6ijyz}^k_Um*R;U(Ourk>AcCddtP>KX0 z2@;Q!`LRLb?DD|$*U0%Umv}xsSg0!H{JWWbD=#6VOlY@fNPilohplqO_&wLk2>pL8 zPm-Qrl=}DONbyq`vb{8Yp&IdfNX?kD#39kWPb(Ly4Xu!}KCBzkhZE8&N8(o5R<~@c z1@~xHS_C2IC0;E@X^q7HE^$@PF+af}`&RhRB?+Bv-s1Cl_vxtXC=N(;{MdQ1e^`Ibx3UA0w2dWIE9{DtOkbRXlDKWjQ+6ra_hCC zEM3sUhX5VB#6{m)5=GA}nZ{uG9-yO^COZZ_2e#JMxSU1o!IEF;s>Fp~T>L94*4I4w zR7IVuves3xp|WOU&b-2c+`Nj(DU(w&2<-WDf$muvO8>lc+9dw;v6CuJs~*us)8c6% z-!3$|WWmUd51$kCpGwvSJ$#SQFG})F{%1$!+O@1Z#WZ?Z60KhLDm5*Spfi?dx4M`A zMu+=J#L85&|JvcFzoMl;{g)0uol9R`nHuPjTeO3oTbUWyCTqCutjZj?1NrYlyJ+dE z21C1?Lb_v>O7E;P2lkr9Z>Std1B_Q{Apic1Ys=oUxq&zhMWL5URq87< znFkKe$wH7sBg#`l(x!--pL&P2t}M@1lz#f^YHgH>-EdIYZaSO3Q!y# #include -//bool power(int N , int M, double periode , double timeBandwidth); +bool power(char* rawDataFileName,int N , int M, double periode , double invTimeBandwidth); void *threadCalcul(void *vargp); \ No newline at end of file diff --git a/Code-C/queue.c b/Code-C/queue.c index 8628b4d..3aff95f 100644 --- a/Code-C/queue.c +++ b/Code-C/queue.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "queue.h" /** @@ -12,7 +13,7 @@ */ struct queue { int charLen; - char * tabChar; + char* tabChar; Pqueue pNextE; }; @@ -39,9 +40,8 @@ Pqueue queueCreateEmpty(){ * * @param elem targeted element * @param _charLen size of char array - * @return Pqueue */ -Pqueue queueSetCharLen(Pqueue elem, int _charLen){ +void queueSetCharLen(Pqueue elem, int _charLen){ assert(elem); elem->charLen = _charLen; } @@ -52,17 +52,27 @@ Pqueue queueSetCharLen(Pqueue elem, int _charLen){ * @param elem targeted element * @param _charLen char array size * @param _tabChar pointer to static char array - * @return Pqueue */ -Pqueue queueSetTabChar(Pqueue elem, int _charLen, const char *_tabChar){ +void queueSetTabChar(Pqueue elem, int _charLen, const char *_tabChar){ assert(elem); assert(_tabChar); elem->charLen = _charLen; - elem->tabChar = (char *) malloc(_charLen * sizeof(char)); + elem->tabChar = calloc(_charLen , sizeof(char)); for(int i = 0; i < _charLen; i++){ - new->tabChar[i] = _tabChar[i]; + elem->tabChar[i] = _tabChar[i]; } } +/** + * @brief set next pqueue element + * + * @param elem target element + * @param next next element + */ +void queueSetNextE(Pqueue elem , Pqueue next){ + assert(elem); + assert(next); + elem -> pNextE = next; +} /************ GETTER ************/ @@ -115,12 +125,6 @@ Pqueue queueCreateE(int lenChar, const char* _tabChar){ return new; } -void setNextE(Pqueue elem , Pqueue next){ - assert(elem); - assert(next); - elem -> pNextE = next; -} - /** * @brief remove and free the last element of queue * @@ -175,18 +179,17 @@ Pqueue queueNextDelFrst(Pqueue elem){ * @param len the lenght of char array * @return Pqueue pointer to the last element */ -Pqueue queueAddLastQ(Pqueue elem, const char* str, int len){ +void queueAddLastQ(Pqueue elem, const char* str, int len){ assert(elem); assert(str); - Pqueue tmp = elem, previous = NULL; - while(elem->pNextE != NULL){ - previous = tmp; - tmp = queueGetNextE(tmp); + Pqueue next = elem, previous = NULL; + while(next->pNextE != NULL){ + previous = next; + next = queueGetNextE(next); } - tmp = queueCreateE(len); - tmp->tabChar = str; - tmp->charLen = len; - return tmp; + previous = next; + next = queueCreateE(len,str); + queueSetNextE(previous,next); } /** @@ -196,12 +199,21 @@ Pqueue queueAddLastQ(Pqueue elem, const char* str, int len){ */ void queuePrintE(Pqueue elem){ Pqueue next = queueGetNextE(elem); - printf("File Name : %s \n(size of the file name : %d)\n",elem -> tabChar , elem -> charLen ); + printf("\nFile 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"); + printf("No nextFile existing (null)\n"); + } +} + +void queuePrintWholeQ(Pqueue firstE){ + queuePrintE(firstE); + Pqueue elem = firstE; + while(queueGetNextE(elem) != NULL){ + elem = queueGetNextE(elem); + queuePrintE(elem); } } diff --git a/Code-C/queue.h b/Code-C/queue.h index c31f2ad..198710c 100644 --- a/Code-C/queue.h +++ b/Code-C/queue.h @@ -1,28 +1,27 @@ typedef struct queue *Pqueue; //Constructors -Pqueue createE(int lenChar, const char* _tabChar); -Pqueue createEmpty(); +Pqueue queueCreateE(int lenChar, const char* _tabChar); +Pqueue queueCreateEmpty(); + //Getters -Pqueue getNextE(Pqueue elem); -Pqueue getNextE(Pqueue elem); -char * gettabChar(Pqueue elem); +Pqueue queueGetNextE(Pqueue elem); +int queueGetCharLen(Pqueue elem); +char* queueGetTabChar(Pqueue elem); //Setters -void setCharLen(Pqueue elem , int _charLen); -void setTabChar(Pqueue elem , int _charLen , char *_tabChar); -void setNextE(Pqueue elem , Pqueue next); +void queueSetCharLen(Pqueue elem, int _charLen); +void queueSetTabChar(Pqueue elem, int _charLen, const char *_tabChar); +void queueSetNextE(Pqueue elem , Pqueue next); -Pqueue addLastQ(Pqueue elem, const char* str, int len); +void queueAddLastQ(Pqueue elem, const char* str, int len); //Removers -Pqueue rmLastE(Pqueue elem); -Pqueue rmFrstE(Pqueue elem); - -Pqueue nextDelFrst(Pqueue elem); - -Pqueue nextDelFrst(Pqueue elem); +Pqueue queueRmLastE(Pqueue elem); +Pqueue queueRmFrstE(Pqueue elem); +Pqueue queueNextDelFrst(Pqueue elem); //print function -void printE(Pqueue elem); \ No newline at end of file +void queuePrintE(Pqueue elem); +void queuePrintWholeQ(Pqueue firstE); \ No newline at end of file diff --git a/Code-C/rmRawData.sh b/Code-C/rmRawData.sh new file mode 100644 index 0000000..d734d9a --- /dev/null +++ b/Code-C/rmRawData.sh @@ -0,0 +1,6 @@ +#!/bin/bash +cd ../RawDataFiles +for i in * +do + rm $i +done \ No newline at end of file diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index 0eea048..51173d8 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -30,18 +30,18 @@ char* convertIntegerToChar(int N) char *createNewRawDataFileName(){ char *fileName = "../RawDataFiles/RawData"; - char *extension = ".csv"; + char *extension = ".csv\0"; char *fileNumber = convertIntegerToChar(cptFile); char fileNameNumber[strlen(fileName)+strlen(fileNumber)]; - char *fullFileName = malloc( (strlen(fileNameNumber)+strlen(extension)) * sizeof(char*) ); + char *fullFileName = malloc((strlen(fileNameNumber)+strlen(extension)) * sizeof(char*)); strcpy( fileNameNumber, fileName ); strcat( fileNameNumber, fileNumber ); strcpy( fullFileName, fileNameNumber ); strcat( fullFileName, extension ); - + return fullFileName; } @@ -114,21 +114,21 @@ bool writeOneRawData(FILE *rawDataFile){ } void *simulateFlux(void *vargp){ + printf("start thread simul\n"); + char *fileName = createNewRawDataFileName(); FILE *rawDataFile = fopen(fileName,"w+"); - Pqueue rawDataQueue = createE(strlen(fileName)); while(writeOneRawData(rawDataFile)){ if(cptData == nRow){ - fclose(rawDataFile); + printf("in if\n"); cptData = 0; cptFile++; //create struct here - char *fileName = createNewRawDataFileName(); + queueAddLastQ(firstRawDataQueue , fileName , strlen(fileName)); + //prepare next file now + fileName = createNewRawDataFileName(); FILE *rawDataFile = fopen(fileName,"w+"); - rawDataQueue = addLastQ(rawDataQueue , fileName , strlen(fileName)); - printE(rawDataQueue); - } } } diff --git a/Code-C/simulateFlux.h b/Code-C/simulateFlux.h index dd2b3d7..de271bd 100644 --- a/Code-C/simulateFlux.h +++ b/Code-C/simulateFlux.h @@ -16,6 +16,6 @@ typedef struct { extern int cptData; extern int cptFile; -char* convertIntegerToChar(int N); +char *convertIntegerToChar(int N); bool writeOneRawData(FILE *f); void *simulateFlux(void *vargp); \ No newline at end of file