From 52bded653488ac579a948071f8bddf76896df18f Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Mon, 13 Jun 2022 17:11:16 +0200 Subject: [PATCH 1/6] almost debug second thread --- Code-C/getArray.c | 13 +++---------- Code-C/initialParameters.h | 2 +- Code-C/main | Bin 24632 -> 24600 bytes Code-C/main.c | 23 ++++++++++++----------- Code-C/power.c | 1 + Code-C/simulateFlux.c | 4 ++-- 6 files changed, 19 insertions(+), 24 deletions(-) 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 fdb4b168bbc5f9156fe034b1d95e48e07e446b48..31dc9ce46809548b4d233859cd21ed2c5066e57b 100755 GIT binary patch delta 3731 zcmZ8k4Nz3q6~1@%`G>lTLY9ZXf{37yQ36O*6dgq$3L-T$qTo+Q4Q&`JjwICyB0-7U z6>H|isMHuu)3Iqyh7QpvCJJVvXpLh2ijAgdz&!sFq*gG&yngrHi$(9u-tWHiedoM$ z&;8lm!*zUT9p4ticm92poA=+`kJ)WArSs$dF;B^-he*2PXuz+w?-aC50{s{xt z(%VJfEu4L@#&kUGY5I9Jx0+i7Bu z5%Pt*r)_elWwkr!r`5GPU4xF$n?YalS}NA31^WGHS-zaN4PRQP_bUSthd!_@YKsbd z%5@x3nOV_cS%x>Q(M2CKUz8rM@iK@sd3x*`ok+!9BdCyrfCKAy23#NYyr}suHS1x)dDD)2SnPS?U)s z)EZLL8DPKX0l?h-UprEpjP#yRrAyUkQq?L{FHqI67`;TWzm)8&l6_sUN%ZxwNIhGy zOC_5l*#&~VPwtQiJzB7Zk{u@5aKRp@?2zHHU3VX^+6|Dk>!kkNP&?oA0CP3%37HbS zPq42@wpg<31gqbr!mtq(5*jh6y&WO3Ok$C)(X7x|Jyls18dN zmnvPT{!Gt@y^&Jt&zK;YdHas-)ydX`*}40s^fSCCv15D>C1)VHIS{7JFqwIOn(pB| zmeRtTQ}((rCvRGlQK`KvhmAgM)L6zaqxnDE1#UppCNaZ3KZxg#@z@|9|3FJ4a!ZpQ z8XJXiqfC`cx==Ifr4YR;qPU)!4(d z-&UnnXLwtT%H_=qr_%W04g456A~X3|nj0C!XVR}DBa@yTET(lz7Ux_rjK-$A;?agr6KBlu*4qd17`L4#aX6b-$cl`L zn<%7}NVhVl(Wso&PsT^-z2{92IG?5?fV~uLG1^N>5p>^ zZ>v#$E8OswK&gEVGn_haF78fXthjJ6kM1!0u8XVIrJWvKDzZ$fg@-TDCHg^qgg0i_ zeOaHB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`?sC|`w}GX7!tT=peEZLxa$RnF2MQY^0z`~L4uzP4jY4#g}(;yO*CcZ z++jD-YJpPn)LKU9Jig3Q9Ws+L*B~`{vgZ~CN@wYx=2gKIJ3mSKEzO>vhIH4?zkrmz zDw`#lZjh6tWLmVqK%3>5t=UP^73M?whDr+z(i65flLQBBjVsvUK>0Zb62e%d5OsEj&>W25MHl9KptD{_#-4&LXuri5s*_h-Q?~Ck*lyC-lz}x&DUmGg;X0iu^4U z_8FR;(C>4@Qe>gAib(xJXqF250y8%(7WOst0rs^;u#JLUFK*m#7%Met^%1RZ)AX02 zXIUJ46ThOJ3k}(1DBtfp;-t2Uxk80KIF=hy#VpCfeoEZjJfY8^)}g?*x7Ap8kErn&&5T#fkWP0Kd-E4jVEI937w}s zzatPY+p*=7hyC~;@q^`QVNI#rSsz+F=>@X`r1kWz!n9$1D>^`r6{blC=!3$f{{tpE BvNr$# 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; } From ce37306f657d11e3a4f56b1b5a063f5f4daa792a Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Mon, 13 Jun 2022 17:24:53 +0200 Subject: [PATCH 2/6] thread calcul ok --- Code-C/getArray.c | 2 +- Code-C/main | Bin 24600 -> 24600 bytes Code-C/main.c | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Code-C/getArray.c b/Code-C/getArray.c index 7389042..9b78b07 100644 --- a/Code-C/getArray.c +++ b/Code-C/getArray.c @@ -73,7 +73,7 @@ long **getRawDataArray(char* rawDataFileName , int N , int M){ p = get(N, M); fillArrayWithRawData(rawDataFileName,p ,N, M); if(checkArrayFullyFill(p,N,M)){ - clearRawData(N); + //clearRawData(N); return p; } else{ diff --git a/Code-C/main b/Code-C/main index 31dc9ce46809548b4d233859cd21ed2c5066e57b..942736ddaf9d6663f5a37cdb8b2c96efb169fe37 100755 GIT binary patch delta 2354 zcmY*a4Nz276uuXI=m@wgu)-p^tP7-|;ZKN~X5{SfKvAoqBD187Y^KzH$eD_W!0h?l zWI9<|nK?E6P7}3FIy7U8nnF#wHD=pC&S<_wb3;m|sMmMijb_`KJ>R?M`_8%No_p_m z+aq#&M0OlY%3S4{?;gJ+qdhs}_^$6q-hcM}BcEIvwvy(!WKr0kzDkqHv?Xh&t1MfH z2G`{72HmwbV(p?i*?R5|S&2S<(6;+sHv}X7E_d1idLjEud64e)E=u?OVcTZyE4mpR zG>+@WVJnXgdwo;eFWREbEe+7h1t1^jd+~kj{(-|-!V;VQ%p_Kz^Zvl^_)_@!m2A+Wd<#? z_N3u9gD3Uv`y{JS?X@(JvwGnVP<84mFi8cD;=osbbJE9E`n{~GQmXGVog&TytVikD z36s5>n7vN1&nxyNW*1UyLLg@av-OI-MX{@y9q}7^a`U}2n7&KVg^Dg_x`&qLPAW;} zGXB@h0g#;!Dt#=&DdlT`^)Nl3du7gB%x+R_vtrwr4Ghqo6AQ?j=T95zcUm&YJ&03f zUWvDWgPv1CR=Sh&9KhN_X5IvMyV6^%Z^JWvl$+~4hNPXZtB@yDNQgtGQeWN`3%4=5 zN3k;$JDb@rIaO;@uWIT#R_#@)6r~EV>K$4$ac7D#P6#H2b&=e@Z11-J#>alO?Y>kT zqNm`p8eXpONm)i$<@e5i)6H8OjOih5k9v%n+N|k9p!6I5b~@RO(-7mOyndd?2QcjB z;SRdlU)Q|wKWCJk(|IUkdROlV9`1J7V25tj#t^qxSI7R%U!XE;IrFgVD^{Add*SN% zSJkFe(FE7Kjw;x(#5k#kZtq=DL9-`y%Wkq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t(}-S-5BoqAy?p?ULp+wP4M!uzdl$ABF`*G)pCprRBQ1l9r5P`3%# z0^9-o2-pF<3hV{W#E!&(dx5SALd?QOmjeF`tOK3{ZUXMdSGWV{!?)WpLEI@G!Jrq3 zf8a0<15;zRouvuU2&@2h0~>%kZj{G>U;f*+Ujn{{{&xWjJ8Nf>^gqOJw{WtnEpAcL z#JIJSZjR@K5Lx)G!DqdjWSLLqksomvEkyi=8WFEk3*yVvjyOo&Wj?=l!M5je=?%9g zW#%}cLq3wf^2s~MkGP!{B92lcVgq>7K{RPUVhNop&-MQmEod7*b6krvHP8GgT2tAXJbR-q=TS@5Wf`E&#y+{5+|^aG zff}o;+>^4oR)`Y{#8GU=6fs$pQ+M?ixsvA8RLQrgr6yf|OuI3zpn;k#GEDW0OXOD+ zUR>h$@l1Fs6o?e`mmN;#t3(_9W${LNo~oDlwJ6JM%VuU D7QJhw diff --git a/Code-C/main.c b/Code-C/main.c index bccc3f9..2aa513f 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -23,11 +23,11 @@ double invTimeBandWidth = 0; void *threadCalcul(void *vargp){ Pqueue rawDataQueue = firstRawDataQueue; + char* fileName; while(rawDataWriteFlag){ while(queueGetNextE(rawDataQueue) != NULL){ - char* fileName = queueGetTabChar(rawDataQueue); - //queuePrintE(rawDataQueue); - printf("%s\n",fileName); + rawDataQueue = queueGetNextE(rawDataQueue); + fileName = queueGetTabChar(rawDataQueue); power(fileName,nRow,nCol,period,invTimeBandWidth); /*remove(queueGetTabChar(rawDataQueue)); rawDataQueue = queueRmFrstE(rawDataQueue);*/ @@ -36,6 +36,7 @@ void *threadCalcul(void *vargp){ } int main(int argc , char** argv){ + rawDataWriteFlag = true; period = 1 / freqEch; From 6cd7513501da78c2d6d216c4645c368c8ef56748 Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Mon, 13 Jun 2022 17:35:00 +0200 Subject: [PATCH 3/6] remove file during traitment --- Code-C/main | Bin 24600 -> 24600 bytes Code-C/main.c | 2 -- Code-C/power.c | 1 + Code-C/queue.c | 4 +--- Code-C/queue.h | 2 +- 5 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Code-C/main b/Code-C/main index 942736ddaf9d6663f5a37cdb8b2c96efb169fe37..b7250cc5072f814d1b5c12a495bc4320d1294683 100755 GIT binary patch delta 2470 zcmZWrZEO_P8a}5mc0t;0k$&v9yW6Gqlgd_W=|?EAV8ir_R%wAEg2Y8*6jMJcaZSiywO(V-7#(uBb2eW#O;szsqP8?$VT~Rn zjUug`Q-zDj*(*Fj)c!vVcocXT^wn(!3CHskBSB#-d zOVfZXu~MjtrD~g0wF%Wdbi(Q6i|M>GF#l@=I#sC|n_<1j-vDF#CCh0dk+@wZ{y5#T9Re7y{1sN~3v42zbwc)L+_zGVE75ThH9Fsw z*}BYb71=%-awYI}bk&tUzfEX9mYRE|rbuW8gkww7pzQQBLUll@qNOTbsP@rncN)*2 z&F(Dz5q;>6PkwP6)sOYmsoF1U%Wo;F)@0zd3^B>iY0#ZC_w`uD4#Ek0>QAf0751Fl zdUNYtj$+HU-IAPyWOy1vZzE(pP6eJ^*CJG~Hf^|DHD3|wkI^}J@uFRp?-uRgJ{}2{EsM;qcwu5TD^_v#n3igX&o_OQ~YWLtI@wmrgOFLA( zZUA`)RqZSp)snle@GNYeB*K^=-?+w$$ho-l5+_GuFsK-r$L@yo3 ztWSj=yEBnTw@(uj=ncOa1=BKT&7K$v4x45RELxhzZT4-i!c$ky&0?&ji)+dt4W`{w zKUM0DMo6*xBf~H2aqW=k%3s-x6&-1O3X3ozn)$EurrE1(1Sc+CNw{egjT?xpqqq$s z?Ff2PMNgz>OnL2gYl6ll`e(YUehiN6|2Df~AdJ#ih99}J0_gz4Z;Ac^p5?2(m)F`l2$K;k|RH=CyO!R6PhY;b@!+} zR;d;?%5E@^+W$B-C#AVB~L`h9y+4M<&moC{#w5_UZ)1{>OgpDW!80^dz2h zJAiMa(_KIhmS_+-0A#l@Rv3CHua~=aica{WV_uC|6m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C-hHn{^&_M=!nSP0JmCQQa2aRG{k0XSm?1)@3~dpK!~$JRZ)*AYJnM zrU!&Hh;)N>eQK~OPR7@ctJ(=8ADpgu5dh<0`TuBsjx(NNs0T)n!l_V0P8v^oHDPR; zw8NJ-ZQ5AVjzQCG4UF*Crja#o0oi0n7#RyhYVrXC)A_*Rt8t5!1N$XijfCLrJa`-2P^BEIyIwlDGUDuE;S*a0Wl)r*mXS>up zWGm+Z05wu%w6d6<7iO|bl3A7lRImD(wPU8Q!-f1h6)sZ)b9 z_QAZYCjTa0fH>n=s37ln?E6KpM>W5B-Zbsw7@L5wMZjucEieJWHvqQ)+khcp2k;`W z515awivS5|k7ld@C!z=_4pA-eTi^!Z-*7bBfDT-X4&ZuVAFv=Geco) z1+WZw7`O_k;GKC6*o!y!b>MDnQW!V|yE_0hfGh?z3#~5c=57)-@F&?{h+2>s6SXTL zHjc3jnBKrm+C~0S5C4kRqP;>bX#Y(6(Vn5MQcw2(&zYw9UA*nR$#S;58={ao@!1|; zOxb9kCI4(s)X-1##2lCMBgmQ50`o((A8kB!p7&c&&!gl!J$!(Q?_8)15K zH{^*_aXKZirAT5TOJXI|vhW5cdRjd{eyR8;fo}~xT3O+Y%9NvC3G66#O?b?puF6#2 zNZ(XGh<9vm)k40PTB=g{N7Rn~OgdY&g*Q`ubs_%;Y1M^JhbSk$G6^gNn;_zZ>C5UZ z{5z_wDdhIh(={H>tEhcZq4Tm&Do>0$Y$-1pU13(N^m?C)mu%r*gx*^6QUc#db5|9PZyc>fV`$^51LJ-H^Z%WS diff --git a/Code-C/main.c b/Code-C/main.c index 2aa513f..86ff80a 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -29,8 +29,6 @@ void *threadCalcul(void *vargp){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); power(fileName,nRow,nCol,period,invTimeBandWidth); - /*remove(queueGetTabChar(rawDataQueue)); - rawDataQueue = queueRmFrstE(rawDataQueue);*/ } } } diff --git a/Code-C/power.c b/Code-C/power.c index 4b58106..7852277 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -26,6 +26,7 @@ bool power(char* rawDataFileName,int N , int M, double periode , double invTimeB powerCalculation(p,pw,N,M,periode,invTimeBandwidth); writePowerData(pw,8); freeArray(p,N); + remove(rawDataFileName); return true; } else{ diff --git a/Code-C/queue.c b/Code-C/queue.c index 3aff95f..432807e 100644 --- a/Code-C/queue.c +++ b/Code-C/queue.c @@ -150,12 +150,10 @@ Pqueue queueRmLastE(Pqueue elem){ * @param elem target to remove (the element need to be the first) * @return Pqueue the second element after remove first */ -Pqueue queueRmFrstE(Pqueue elem){ +void queueRmFrstE(Pqueue elem){ assert(elem); - Pqueue tmp = elem->pNextE; free(elem->tabChar); free(elem); - return tmp; } /** diff --git a/Code-C/queue.h b/Code-C/queue.h index 198710c..c2ec7a5 100644 --- a/Code-C/queue.h +++ b/Code-C/queue.h @@ -19,7 +19,7 @@ void queueAddLastQ(Pqueue elem, const char* str, int len); //Removers Pqueue queueRmLastE(Pqueue elem); -Pqueue queueRmFrstE(Pqueue elem); +void queueRmFrstE(Pqueue elem); Pqueue queueNextDelFrst(Pqueue elem); //print function From 05a9142c7ee76560537a0cf9e83cbed0c305bec3 Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Tue, 14 Jun 2022 10:24:59 +0200 Subject: [PATCH 4/6] add average thread --- Code-C/Makefile | 2 +- Code-C/average.c | 32 ++++++++++++++++++++++++++++++++ Code-C/average.h | 4 ++++ Code-C/fileGestion.c | 4 ++-- Code-C/fileGestion.h | 2 +- Code-C/main | Bin 24600 -> 24840 bytes Code-C/main.c | 35 ++++++++++++++++++++++++++++++++--- Code-C/power.c | 3 +-- Code-C/power.h | 3 +-- Code-C/simulateFlux.c | 2 +- 10 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 Code-C/average.c create mode 100644 Code-C/average.h diff --git a/Code-C/Makefile b/Code-C/Makefile index abeb975..6107882 100644 --- a/Code-C/Makefile +++ b/Code-C/Makefile @@ -1,7 +1,7 @@ CC = gcc all: - $(CC) fileGestion.c getArray.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main + $(CC) fileGestion.c getArray.c average.c power.c queue.c simulateFlux.c main.c -lm -lpthread -o main # $(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/average.c b/Code-C/average.c new file mode 100644 index 0000000..7d228fd --- /dev/null +++ b/Code-C/average.c @@ -0,0 +1,32 @@ +#include "average.h" +#include "getArray.h" +#include "fileGestion.h" +#include "initialParameters.h" +#include "queue.h" +#include + +void averageCalculation(long **p, double averageArray[] , int N, int M){ + for(int i = 0; i < M-1; i++){ + int j = 0; + averageArray[i] = 0; + while(j < N){ + averageArray[i] += p[i][j]; + j++; + } + averageArray[i] /= N; + //printf("%f\n", powerArray[i]); + } +} +bool average(char* rawDataFileName,int N , int M){ + long **p = getRawDataArray(rawDataFileName,N, M); + double aver[8]; + if(p !=NULL){ + averageCalculation(p,aver,N,M); + writeDataInFile("averageData.csv",aver,8); + freeArray(p,N); + return true; + } + else{ + return false; + } +} \ No newline at end of file diff --git a/Code-C/average.h b/Code-C/average.h new file mode 100644 index 0000000..7ae6f90 --- /dev/null +++ b/Code-C/average.h @@ -0,0 +1,4 @@ +#include +#include + +bool average(char* rawDataFileName,int N , int M); \ No newline at end of file diff --git a/Code-C/fileGestion.c b/Code-C/fileGestion.c index 5a54c0c..1d1d73d 100644 --- a/Code-C/fileGestion.c +++ b/Code-C/fileGestion.c @@ -26,8 +26,8 @@ void clearRawData(int nRow){ * @param powerArray * @param nCol size of the power array, correspond to the number of captor used */ -void writePowerData(double powerArray[], int nCol){ - FILE *f = fopen("powerData.csv","a+"); +void writeDataInFile(char* fileName , double powerArray[], int nCol){ + FILE *f = fopen(fileName,"a+"); for(int i = 0 ; i < nCol ; i++){ if( i < nCol-1){ fprintf(f, "%f , ", powerArray[i]); diff --git a/Code-C/fileGestion.h b/Code-C/fileGestion.h index afebd10..b001d93 100644 --- a/Code-C/fileGestion.h +++ b/Code-C/fileGestion.h @@ -5,4 +5,4 @@ void clearRawData(int N); -void writePowerData(double a[], int N); \ No newline at end of file +void writeDataInFile(char* fileName , double a[], int N); \ No newline at end of file diff --git a/Code-C/main b/Code-C/main index b7250cc5072f814d1b5c12a495bc4320d1294683..45755a38c8213233c34a258d84a084c5e99a0d7a 100755 GIT binary patch delta 7601 zcmaJ`30zdyxj%PsWQjTqG7f_ai?}b~f`AFisuu$hq9`gZ{303?7gWfq84a2^Z=4oA zjY+dr8*7Yde#N3jeJ&W&NZK^Pmqq$&BPQl`6b;}KCqC18|L>f0N1*LH3HLkq`~Sb? z>}Rg8)N5Nl&}yP0!Xua{8B(wCb*y^rB1<)?FXh8b??%r3-H;uTrlydeM}PWqRjM_+=GTAxl6y@Fj(D($*`3(h zF1CR&6X^!>K|v$5jJl$rmo;rPFAB16H`i!G_%`!tJ~Jp%i>fQ?K1VaJU0z;Z!QTl! zzQRQI_%9dU!cmXKpKIF=_%*X-Di^}1cfhNnm!UC1tTKR`*g}QFob3?y-Pi`DlYA4a zv~)Ey6f*VNNjC{@7_adl-q z9uN9`_zlfDnXyOvL3KIyAAY}o(Dii2mefclV`Hx6xy~-oUEk={m)Z(v=6lT14#sp( z&$=iQ>FsvL{I)%?xoL^X5vn*i)WIW>=Bu>nZu4`%_09E_q5ft|%m(s(T1nj#n%+K% z43e+#$0PdX6f0_ozj=x9XfQVj9;-?$)~nMefW>szca=SKclt!wdq*L6@1uBpWd4}{ zDPnZOZL|pq-hl8viI(ZE+%`mMmFg>`Uc~$NPSF0!vw9D99{33qq!^{Ui^1F6EKI)A zU1z*5KrMf&fwM}o`r} z!zthr-Lmon_-VmvfuF-PrMzK0G18X)FIfNCk@W?dQJs5NgZKM$&s(-Wi@r13p!1E9 z@!CPYJ93=1kvBzVMNOhcyAax)+kkl2qGjGw`B>ZFzJ&y$@7A8l^-+#36G0OlFqp5k zrG~Ch?1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Y1IxK-XR2zY z;e;y)GqG^Cm>1BMd-Zu)5NRv43i6ULY zlk~A&a1(lu@Kl9Uxs)OmKCufvLgI5-VV6L;%3*OAe6GS*DZHnQ&uGF@!Rx!=8@X+= zBW;&rYZPl!Ui%e(Na03x8~F>99okuX@|ww!&I>}hN*`hQH={p+9sL)PP%09k3-;sYnX>_F#8z{6V6h1UTxH7R% zAzMJbVWPDqapU>5DDg79Y-sypRTR2Hq?^<_XQzs}fX+W8aWKGIMB8KNnV$w1>ZQH- zQ-qQ@Twt>l-k^NNp#i)=;V1ENNU2^LHcyneR`#s*GJ)> z)7=kAZ1u2lz+>sZPc4<(3LMT1yi+X?b(s^>d3J##f1!%wvKSbp zR}{|FST2w-+sc|LQ46iim*wojTH(%pn3s~6$u|PBAtPr z>fh9*{+9$E$%b^nuS$F_D^&#IiqrvuDpcO3LXTCTi3*QZdMl0=>i8*xB_Pg9Wc%=& z(;R6|#r`xXP{3vHHSZ~B~Nqv%)R`~%>U#YXRWKV&#u$zPR)tew8i|&+!UK}pD=6{Pnwrvi&h({VO@Or zyp+&#g_iT(^TvcWtG8x;ao!mJUB88N zA7NV3mk(VqBFxw;!%VX!%IlUxtmXOInzvnK~JNcG2UW lv(-UN+eap^SezW@n=bYL9?U;nJUZ;PS@Jbl<5%ZI|1XXN7c&3= diff --git a/Code-C/main.c b/Code-C/main.c index 86ff80a..de1b7eb 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -4,9 +4,10 @@ #include "power.h" #include "initialParameters.h" #include "queue.h" +#include "average.h" bool rawDataWriteFlag; -int nRow = 100000; +int nRow = 500; int nCol = 9; double freqEch = 250; @@ -21,7 +22,7 @@ int cptFile = 1; double period = 0; double invTimeBandWidth = 0; -void *threadCalcul(void *vargp){ +void *threadCalculPower(void *vargp){ Pqueue rawDataQueue = firstRawDataQueue; char* fileName; while(rawDataWriteFlag){ @@ -29,6 +30,34 @@ void *threadCalcul(void *vargp){ rawDataQueue = queueGetNextE(rawDataQueue); fileName = queueGetTabChar(rawDataQueue); power(fileName,nRow,nCol,period,invTimeBandWidth); + remove(fileName); + } + } +} + +void *threadCalculAverage(void *vargp){ + Pqueue rawDataQueue = firstRawDataQueue; + char* fileName; + while(rawDataWriteFlag){ + while(queueGetNextE(rawDataQueue) != NULL){ + rawDataQueue = queueGetNextE(rawDataQueue); + fileName = queueGetTabChar(rawDataQueue); + average(fileName,nRow,nCol); + remove(fileName); + } + } +} + +void *threadCalculBoth(void *vargp){ + Pqueue rawDataQueue = firstRawDataQueue; + char* fileName; + while(rawDataWriteFlag){ + while(queueGetNextE(rawDataQueue) != NULL){ + rawDataQueue = queueGetNextE(rawDataQueue); + fileName = queueGetTabChar(rawDataQueue); + power(fileName,nRow,nCol,period,invTimeBandWidth); + average(fileName,nRow,nCol); + remove(fileName); } } } @@ -45,7 +74,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, threadCalculBoth, (void *)&calcul); pthread_exit(NULL); } \ No newline at end of file diff --git a/Code-C/power.c b/Code-C/power.c index 7852277..6d836e6 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -24,9 +24,8 @@ bool power(char* rawDataFileName,int N , int M, double periode , double invTimeB double pw[8]; if(p !=NULL){ powerCalculation(p,pw,N,M,periode,invTimeBandwidth); - writePowerData(pw,8); + writeDataInFile("powerData.csv",pw,8); freeArray(p,N); - remove(rawDataFileName); return true; } else{ diff --git a/Code-C/power.h b/Code-C/power.h index 2e0e3ad..51e4dae 100644 --- a/Code-C/power.h +++ b/Code-C/power.h @@ -1,5 +1,4 @@ #include #include -bool power(char* rawDataFileName,int N , int M, double periode , double invTimeBandwidth); -void *threadCalcul(void *vargp); \ No newline at end of file +bool power(char* rawDataFileName,int N , int M, double periode , double invTimeBandwidth); \ No newline at end of file diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index 28e1980..92935c9 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -105,7 +105,7 @@ bool writeOneRawData(FILE *rawDataFile){ } } cptData++; - //sleep(0.004); //simul la freq ech + sleep(0.004); //simul la freq ech return true; } else { From 2080c37eef92a974986b82bdf325135c542650d2 Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Tue, 14 Jun 2022 10:46:04 +0200 Subject: [PATCH 5/6] comment c code --- Code-C/average.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Code-C/average.c b/Code-C/average.c index 7d228fd..79dbf4a 100644 --- a/Code-C/average.c +++ b/Code-C/average.c @@ -3,8 +3,14 @@ #include "fileGestion.h" #include "initialParameters.h" #include "queue.h" -#include - +/** + * @brief realize the average calcul + * + * @param p array with all the values that will be used for the calcul + * @param averageArray array where results are stocked + * @param N number of rows in p + * @param M number of columns in p + */ void averageCalculation(long **p, double averageArray[] , int N, int M){ for(int i = 0; i < M-1; i++){ int j = 0; @@ -17,16 +23,20 @@ void averageCalculation(long **p, double averageArray[] , int N, int M){ //printf("%f\n", powerArray[i]); } } -bool average(char* rawDataFileName,int N , int M){ + +/** + * @brief function that realize all the action to write one lign in the file averageData.csv + * + * @param rawDataFileName name of the raw data file to use to realize the calcul + * @param N number of rows in the file + * @param M number of columns in the file + */ +void average(char* rawDataFileName,int N , int M){ long **p = getRawDataArray(rawDataFileName,N, M); double aver[8]; if(p !=NULL){ averageCalculation(p,aver,N,M); writeDataInFile("averageData.csv",aver,8); freeArray(p,N); - return true; - } - else{ - return false; } } \ No newline at end of file From 64a50327e74887b02d6aa5280c6c48c63f3fb948 Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Tue, 14 Jun 2022 10:46:12 +0200 Subject: [PATCH 6/6] comment c code --- Code-C/average.h | 2 +- Code-C/b2hd.c | 2 ++ Code-C/fileGestion.c | 12 ++++++------ Code-C/getArray.c | 23 +++++++++++++++++++---- Code-C/main | Bin 24840 -> 24800 bytes Code-C/main.c | 2 +- Code-C/power.c | 17 ++++++++++++++++- Code-C/queue.c | 7 +++++-- Code-C/simulateFlux.c | 31 ++++++++++++++++++++++++++----- Code-C/simulateFlux.h | 2 +- 10 files changed, 77 insertions(+), 21 deletions(-) diff --git a/Code-C/average.h b/Code-C/average.h index 7ae6f90..b4bdf81 100644 --- a/Code-C/average.h +++ b/Code-C/average.h @@ -1,4 +1,4 @@ #include #include -bool average(char* rawDataFileName,int N , int M); \ No newline at end of file +void average(char* rawDataFileName,int N , int M); \ No newline at end of file diff --git a/Code-C/b2hd.c b/Code-C/b2hd.c index c6e5147..22ce3fe 100644 --- a/Code-C/b2hd.c +++ b/Code-C/b2hd.c @@ -43,6 +43,8 @@ void b2hd() } } } + + int main(int argc , char** argv){ b2hd(); } \ No newline at end of file diff --git a/Code-C/fileGestion.c b/Code-C/fileGestion.c index 1d1d73d..57aa3e9 100644 --- a/Code-C/fileGestion.c +++ b/Code-C/fileGestion.c @@ -21,18 +21,18 @@ void clearRawData(int nRow){ fclose(f); fclose(g); } /** - * @brief use to write the file powerData.csv that contaign all power calculous results + * @brief use to write one lign in the file "fileName" * - * @param powerArray - * @param nCol size of the power array, correspond to the number of captor used + * @param array array that contaign all the values to write in the file + * @param nCol size of the array (correspond to the number of captor used) */ -void writeDataInFile(char* fileName , double powerArray[], int nCol){ +void writeDataInFile(char* fileName , double array[], int nCol){ FILE *f = fopen(fileName,"a+"); for(int i = 0 ; i < nCol ; i++){ if( i < nCol-1){ - fprintf(f, "%f , ", powerArray[i]); + fprintf(f, "%f , ", array[i]); } else { - fprintf(f, "%f\n", powerArray[i]); + fprintf(f, "%f\n", array[i]); } } fclose(f); diff --git a/Code-C/getArray.c b/Code-C/getArray.c index 9b78b07..dd3f1fe 100644 --- a/Code-C/getArray.c +++ b/Code-C/getArray.c @@ -49,10 +49,11 @@ void printArrayData(long** p, int N, int M) { /** * @brief verify if all the element of an array are not NULL, return * - * @param p - * @param N - * @param M - * @return int + * @param p array to check + * @param N number of rows in p + * @param M number of columns in p + * @return true if the array contaign no NULL element + * @return false if at least one element is null */ bool checkArrayFullyFill(long **p, int N , int M){ for(int i = 0 ; i < N ; i++){ @@ -61,6 +62,12 @@ bool checkArrayFullyFill(long **p, int N , int M){ return true; } +/** + * @brief free memory allocate to an array p + * + * @param p array to free memory + * @param N number of rows in array + */ void freeArray(long **p, int N) { int i; for(i = 0 ; i < N ; i++) @@ -68,6 +75,14 @@ void freeArray(long **p, int N) { free(p); } +/** + * @brief Get the Raw Data Array object + * + * @param rawDataFileName name of the file to use to file the array + * @param N numbers of rows to have i the array + * @param M numbers of columns to have i the array + * @return long** the array fill with raw data + */ long **getRawDataArray(char* rawDataFileName , int N , int M){ long **p; p = get(N, M); diff --git a/Code-C/main b/Code-C/main index 45755a38c8213233c34a258d84a084c5e99a0d7a..69213d78d46a50620a794cc57b661390d41c589d 100755 GIT binary patch delta 4729 zcmZ`-3sjU<9=~^R_ntHNckliG{*U|m zf8RGRf6krFygo$F1~Iivl)y?G;&=L%`O98e!*@x(Bg158q(jdS^WZz7`tcWcE%|b8 z#Z7xPP^j78BfuS7oHQQ-9k=W$fvW!$8#=aJN) zJfX5%^gfHp8BlEfSVdggm#8yef2wFJoS;{Jvbn z7I@@>zggAq$6oM^Nxp`a({&%C$?2JV>omb-%tr#-N|C-cg!rMa(G=ww6R@>FcC>(K z#}B@L);Nk2-}KrOc!O7GFt)f}iWwVqCD(fDF~xdTsXgC0b56cp>t|w2u@C$pL_qo( zBV%sE-gL%p>de{d(5OrS+5`dPx|bUin|34QN?p@(U$;|dt`W8mdk`kL%1^xuze@bi z3auMt$bQnJ;Nx~KR_*rkYg9U`N-9)p)2D#N6zhfM{)#PqD)e0=-EOz54An91cl3`z z55;&71;d{11#oTn+3i-WmQKZ<>K>vF-vziTXk<_f@1R*h!{;8k2MPiWQEY|a)j3s_ zZx!ot*A|F6PSnHLdZG1w5197U=cS=VV(7L|w!uEwiL&hyZ8Lon6ycjGnCR`G+d&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..9957208 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -71,7 +71,7 @@ int main(int argc , char** argv){ firstRawDataQueue = queueCreateEmpty(); // change this for create empty pthread_t rawData; - pthread_create(&rawData , NULL, simulateFlux, (void *)&rawData); + pthread_create(&rawData , NULL, threadSimulateFlux, (void *)&rawData); pthread_t calcul; pthread_create(&calcul , NULL, threadCalculBoth, (void *)&calcul); diff --git a/Code-C/power.c b/Code-C/power.c index 6d836e6..df99179 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -3,8 +3,15 @@ #include "fileGestion.h" #include "initialParameters.h" #include "queue.h" -#include +/** + * @brief realize the power calcul + * + * @param p array with all the values that will be used for the calcul + * @param powerArray array where results are stocked + * @param N number of rows in p + * @param M number of columns in p + */ void powerCalculation(long **p, double powerArray[] , int N, int M , double period , double invTimeBandwidth){ for(int i = 0; i < M-1; i++){ int j = 0; @@ -19,6 +26,14 @@ void powerCalculation(long **p, double powerArray[] , int N, int M , double peri //printf("%f\n", powerArray[i]); } } + +/** + * @brief function that realize all the action to write one lign in the file powerData.csv + * + * @param rawDataFileName name of the raw data file to use to realize the calcul + * @param N number of rows in the file + * @param M number of columns in the file + */ bool power(char* rawDataFileName,int N , int M, double periode , double invTimeBandwidth){ long **p = getRawDataArray(rawDataFileName,N, M); double pw[8]; diff --git a/Code-C/queue.c b/Code-C/queue.c index 432807e..6bcf99c 100644 --- a/Code-C/queue.c +++ b/Code-C/queue.c @@ -148,7 +148,6 @@ Pqueue queueRmLastE(Pqueue elem){ * @brief remove and free the first element of queue * * @param elem target to remove (the element need to be the first) - * @return Pqueue the second element after remove first */ void queueRmFrstE(Pqueue elem){ assert(elem); @@ -175,7 +174,6 @@ Pqueue queueNextDelFrst(Pqueue elem){ * @param elem Pqueue will be added at the end of queue * @param str the string will be bind at the element * @param len the lenght of char array - * @return Pqueue pointer to the last element */ void queueAddLastQ(Pqueue elem, const char* str, int len){ assert(elem); @@ -206,6 +204,11 @@ void queuePrintE(Pqueue elem){ } } +/** + * @brief Print all the element starting from @param firstE till the end of the linked list + * + * @param firstE + */ void queuePrintWholeQ(Pqueue firstE){ queuePrintE(firstE); Pqueue elem = firstE; diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index 92935c9..3066bf3 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -2,7 +2,12 @@ #include "initialParameters.h" #include "queue.h" - +/** + * @brief convert an interger N into a char* + * + * @param N + * @return char* + */ char* convertIntegerToChar(int N) { // Count digits in number N @@ -28,6 +33,11 @@ char* convertIntegerToChar(int N) return (char*)arr; } +/** + * @brief Create a New Raw Data File Name + * + * @return char* + */ char *createNewRawDataFileName(){ char *fileName = "../RawDataFiles/RawData"; char *extension = ".csv\0"; @@ -58,13 +68,25 @@ int maxInArray(int *array , int N){ } return max; } - +/** + * @brief return the unix time in millisecond + * + * @return int64_t + */ int64_t millis() { struct timespec now; timespec_get(&now, TIME_UTC); return ((int64_t) now.tv_sec) * 1000 + ((int64_t) now.tv_nsec) / 1000000; } + +/** + * @brief write one lign of rawData in the file @param rawDataFile (simulate of freq of the Vegetal Signals Captor) + * + * @param rawDataFile + * @return true if the lign is correctly write , else : + * @return false + */ bool writeOneRawData(FILE *rawDataFile){ char buff[26]; char buff2[18]; @@ -105,7 +127,7 @@ bool writeOneRawData(FILE *rawDataFile){ } } cptData++; - sleep(0.004); //simul la freq ech + //sleep(0.004); //simul freq here return true; } else { @@ -113,7 +135,7 @@ bool writeOneRawData(FILE *rawDataFile){ } } -void *simulateFlux(void *vargp){ +void *threadSimulateFlux(void *vargp){ char *fileName = createNewRawDataFileName(); FILE *rawDataFile = fopen(fileName,"w+"); @@ -130,6 +152,5 @@ void *simulateFlux(void *vargp){ FILE *rawDataFile = fopen(fileName,"w+"); } } - //queuePrintWholeQ(firstRawDataQueue); rawDataWriteFlag = false; } diff --git a/Code-C/simulateFlux.h b/Code-C/simulateFlux.h index de271bd..ea865bf 100644 --- a/Code-C/simulateFlux.h +++ b/Code-C/simulateFlux.h @@ -18,4 +18,4 @@ extern int cptFile; char *convertIntegerToChar(int N); bool writeOneRawData(FILE *f); -void *simulateFlux(void *vargp); \ No newline at end of file +void *threadSimulateFlux(void *vargp); \ No newline at end of file