From 446d3b5fd7b7a66e0b1fba6edda7ea59fa82a219 Mon Sep 17 00:00:00 2001 From: "quentin.perret" Date: Thu, 9 Jun 2022 17:34:24 +0200 Subject: [PATCH] create multiple file of rawdat --- .vscode/settings.json | 3 +- Code-C/Makefile | 8 +- Code-C/b2hd | Bin 17056 -> 0 bytes Code-C/b2hd.c | 5 +- Code-C/b2hd.h | 4 + Code-C/fileGestion.c | 34 +++++--- Code-C/getArray.c | 21 ++++- Code-C/initialParameters.h | 14 ++-- Code-C/main | Bin 17872 -> 0 bytes Code-C/main.c | 20 ++++- Code-C/power | Bin 17696 -> 0 bytes Code-C/power.c | 14 ++-- Code-C/simulateFlux | Bin 17352 -> 0 bytes Code-C/simulateFlux.c | 149 +++++++++++++++++++++++++++--------- Code-C/simulateFlux.h | 20 ++--- Py-Script/Traitement-FFT.py | 10 +-- 16 files changed, 214 insertions(+), 88 deletions(-) delete mode 100755 Code-C/b2hd delete mode 100755 Code-C/main delete mode 100755 Code-C/power delete mode 100755 Code-C/simulateFlux diff --git a/.vscode/settings.json b/.vscode/settings.json index 08ba79e..5c64e94 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,6 +14,7 @@ "limits": "c", "*.tcc": "c", "type_traits": "c", - "simulateflux.h": "c" + "simulateflux.h": "c", + "pthread.h": "c" } } \ No newline at end of file diff --git a/Code-C/Makefile b/Code-C/Makefile index cdc4abd..7711ce9 100644 --- a/Code-C/Makefile +++ b/Code-C/Makefile @@ -2,8 +2,6 @@ CC = gcc all: # rm powerData.csv - $(CC) simulateFlux.c -o simulateFlux - $(CC) fileGestion.c getArray.c power.c main.c -lm -o main - - ./simulateFlux < ../02400001.TXT - ./main \ No newline at end of file +# $(CC) simulateFlux.c fileGestion.c getArray.c power.c main.c -lm -o main + $(CC) simulateFlux.c main.c -lpthread -o main + ./main < ../02400031.TXT \ No newline at end of file diff --git a/Code-C/b2hd b/Code-C/b2hd deleted file mode 100755 index bdb7e90ccfa196aa07e4e38e72b81137a69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BE8&|2yU?TtB}@Ghe6ucs`eX&S{*U!}#^i zwx8d(nah>K(9<-G^2Gi;&!YW|^y<#_^LsgSo*%+Q62-96ZU{6NV}E{sXHNSliMai2 z$NZbn(cF$@e$QuKCB0|2U&G=63Y1g!=lKA0o?mkP_Ur$S_OI6gdA`bgSmWf6x2IY8 zdlDGsgy+}vlPyVe^0AV=|5H#}{XN=`dCcmJvMs!L#^%rS73O@s9EN4)-?#Z6))g?n z!Pa1|pW{7e^XK^wbDr0;y)B%0LHl$636HkayiSYE?EXK6g7U}yK990wPT$V0WcU9S zlve*?kFsWNkkUe&H-=tA!Ht9NAtHVs=l$1qdzP8M0iRMF?9c!2OjS~}nenEi8JYdx zg@VQ&`}2H{_qUJh_Vf5;Kkmmv@Ff%W=Xv3|wE#h@70aI4pShY>%=inRHmy?J$a<;* z`!W9nu(f`EpEk5Vx0A!LAIld}AdK6;$EP&+YJbfXh_feKQiaQ4RKMMh{l9FpCtD&b z=dq_W>fEmbPU*zc?+|q #include +/** + * @brief struct used to stock binary 32 bits data from the captor + * + */ typedef struct { uint8_t octet1; uint8_t octet2; diff --git a/Code-C/fileGestion.c b/Code-C/fileGestion.c index 78d17e1..126d240 100644 --- a/Code-C/fileGestion.c +++ b/Code-C/fileGestion.c @@ -1,28 +1,38 @@ #include "fileGestion.h" -void clearRawData(int N){ + +/** + * @brief function that delete nRow lign in the beginning of the file rawData.csv . This function is necessary to not deal with the same ligns over and over + * + * @param nRow number of lign in the beginning of the file rawData.csv that has to be delete + */ +void clearRawData(int nRow){ char buffer[256]; FILE *f = fopen("newFile.csv","w+"); FILE *g = fopen("rawData.csv","r"); - for(int i = 0; i < N; i++){ - fgets(buffer , sizeof buffer , g); - //printf("Line contaigns: %s" , buffer); + for(int i = 0; i < nRow; i++){ //first the program read the first nRow ligns of the csv file but do nothing + fgets(buffer , sizeof buffer , g); } - while(1){ + while(1){ //then, till the end of the csv file it copy the lign to a new csv : newFile.csv if(!fgets(buffer,sizeof buffer , g)) break; fprintf(f,"%s",buffer); } - remove("rawData.csv"); rename("newFile.csv", "rawData.csv"); + remove("rawData.csv"); rename("newFile.csv", "rawData.csv"); //finally we remove the original file and rename the new one to replace rawData.csv fclose(f); fclose(g); } - -void writePowerData(double a[], int N){ +/** + * @brief use to write the file powerData.csv that contaign all power calculous results + * + * @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+"); - for(int i = 0 ; i < N ; i++){ - if( i < N-1){ - fprintf(f, "%f , ", a[i]); + for(int i = 0 ; i < nCol ; i++){ + if( i < nCol-1){ + fprintf(f, "%f , ", powerArray[i]); } else { - fprintf(f, "%f\n", a[i]); + fprintf(f, "%f\n", powerArray[i]); } } fclose(f); diff --git a/Code-C/getArray.c b/Code-C/getArray.c index 07ce2ed..d6543a1 100644 --- a/Code-C/getArray.c +++ b/Code-C/getArray.c @@ -13,7 +13,7 @@ long **get(int N, int M) /* Allocate the array */ return array; } -void fillRawData(long** p, int N, int M) { +void fillArrayWithRawData(long** p, int N, int M) { int i, j; char *buffer; @@ -36,14 +36,27 @@ void fillRawData(long** p, int N, int M) { //printf("\n\n"); } } - +/** + * @brief print all the element of a bidimensionnal array p of shape : N x M + */ void printArrayData(long** p, int N, int M) { int i, j; for(i = 0 ; i < N ; i++){ - printf("line n°%d : %d , %d , %d , %d , %d , %d , %d , %d , %d\n" ,i,p[i][0],p[i][1],p[i][2],p[i][3],p[i][4],p[i][5],p[i][6],p[i][7],p[i][8]); + printf("line n°%d : " , i); + for(int j = 0 ; j < M ; j++){ + printf("%d , " , p[i][j]); + if(j==(M-1)) printf("\n"); } + } } - +/** + * @brief verify if all the element of an array are not NULL, return + * + * @param p + * @param N + * @param M + * @return int + */ int checkArrayFullyFill(long **p, int N , int M){ for(int i = 0 ; i < N ; i++){ if(p[i][0] == '\0'){ return 1; } diff --git a/Code-C/initialParameters.h b/Code-C/initialParameters.h index 3007f21..5a635fa 100644 --- a/Code-C/initialParameters.h +++ b/Code-C/initialParameters.h @@ -1,6 +1,10 @@ -const int nRow = 100000; -const int nCol = 9; -const double freqEch = 250; +#include -const double period = 1.0/freqEch; -const double timeBandwidth = 1.0 /(nRow * period); +extern int nRow; +extern int nCol; +extern double freqEch; + +extern int selectionCaptors[]; +extern int sizeSelectionArray; + +extern bool flag; \ No newline at end of file diff --git a/Code-C/main b/Code-C/main deleted file mode 100755 index 9d2cfd1b3e54bec849a1e6d3da4576d3ae16a3e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17872 zcmeHPeQ;aVmA|rL5<((7kQ5ifMkTNfgeXo*viX>RWLwEIwSzG+4YMRdvE*1(mW)2~ z)da#C*a*eo?X*m~!_J1%UCeH#L%Z7!n<=bAvWc6{WDM$X?Z^pp!%SbxGU*i1q-HZcOUF1&d*yo?X9}KQhAxD z<7cY7D;9=Bo0i_WFdSGA4n>mN7HnI#bivX)UGb=EvF!Iu1VX!F&Du8c=DYLVJAX1V zd1`3<#kZflXZ&E}fww7cih=x*4i(bp^b@@fKa#6{J%O6Sh@J|b=ptIG{0M?;iwGYn zfm1uqBKoUK=s#2ff2;)lKneV%5_n4qd{+tlCg4u|3QIeHVtII>1b$Bm{LvElwi5VL zCGb0dJMk+ly#Q`51c~=Gu50!Mg0bM{P&^Tgt!u6iMj*{s;n0qth$mw4U^h@43++0JE`JD(#DYNqu#1j|rBrKIwKYwR zb@jf*uEonmzUo>+-K>x!-!3WD70)&1=y9eUkqn@pLJa-7WclA)YR4vfYyZF7b4!mwj0Be@{GJ3T0a)|4riQ5-97I{4>PU zC1AEz@_$1-T?%ELlHWl*T>@pRCI6mFh>kw+vMl( zlBq;)yKJOJjYA*aZ5$f28@8jysmqC(aNyMrrsRe@WIJrXd(|n3L~>!9(X;9=scNL& zPfRn?t9}S3vjAPnbYgR~@)hv54Q$6W`wa-&U}HQnQj5Kqdj0I>T+ZlS@*AWC!TlN} z^D;px?TyyMiR3$u-MTgK>pY8dz%b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%PK9imeE zm(NPk#=;VQ>VZ3T3}(^_d`3l$=yRJWudDUEMGFEET5bw4WEWAI{HtsjqySx0g!bSKEt^s~bw- zF5tAk3gcV>T!&(AR;-hL9O4IGP;jf3Zq&G6<1HGGk$+@jpHl(cudTpu);ebLP3`An zJ^tnMa#CoICE|%>M~ACjOsr1wCAxfAR1^uuu_`DK^=%GEH~GW9Kq4B8`~1mmqCMKx z9S$af0atBt4O(3k^7&&i|8`$6l89}`Vj`?Z@&%GzUE5(|;(X9dSXJ@LXiYGl2t^|Z z3#*nqPZ`VH7bNFzP&5q-vpY7DcZ?3Eb0r!x`iteO$1$=BT3h$WC$x+ zLjetW>KYd${F{Z8b^7C-!WGyafj>nPF(ug&jKyj2Nj1&*Ad3aVelpOt?r=i5e?Iyn+R^hmX38OMdjFa1v~Z8-5G!r=9H;A%#{V#(SpA#)Q;w(3G$5KsN*i|O5wsp z(}nrNJeB=Pb$YH~!w=KDEPVgQl%FeTvDD={(Yg51y*%6VeIC2J9kXI1YV_=a6!mRMAvl zrfJZ+#*@Gler9{8wqrV)w^Wq^_u^Xx_I!WNl;dSL%rpIm0(-t*W4eeRWN8Q7KKpyA zz@G2-nHHGKeZ{s!U(xow|AdoJ6sO#ZK}GUgj+=oWphEd$`$4CYFr{xi%!S5^x%?*> zvpqj&VA{ftwNYXFKLw7vW_b*e3g0L5{}mMKGtZR1w68MR^K*;g1>|jFyeV#iXZv44 zKx2=NVJiH5gZ~eL|M!8%C)@FU+y@)#Kil(jkfDX-4d1FLlHamD)89g3wij-#TC3l*Z%&g929k EA0U&8MF0Q* diff --git a/Code-C/main.c b/Code-C/main.c index 3e55a33..5de3cde 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -1,9 +1,25 @@ -//#include "simulateFlux.h" +#include +#include +#include "simulateFlux.h" #include "getArray.h" #include "fileGestion.h" #include "power.h" #include "initialParameters.h" +int nRow = 100000; +int nCol = 9; +double freqEch = 250; + +int selectionCaptors[] = {1,2,3,4,5,6,7,8}; +int sizeSelectionArray = 8; + int main(int argc , char** argv){ - while(power(nRow,nCol,period,timeBandwidth)==0){} + + double period = 1 / freqEch; + double invTimeBandWidth = 1 /(nRow * period); + + pthread_t rawData; + pthread_create(&rawData , NULL, simulateFlux, (void *)&rawData); + pthread_exit(NULL); + while(power(nRow,nCol,period,invTimeBandWidth)==0){} } \ No newline at end of file diff --git a/Code-C/power b/Code-C/power deleted file mode 100755 index 8d6ec53ae8a6cbdc8ef603301f744c1a49320ad8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17696 zcmeHPdvKH2mA|rZa1)ROfyPZpQ4?qliG`to8VDN+Ecl!n;y9Rw-GC61jGfAos|Sx1 zSP~PqTH(~Y!*20 zx%VFVlPqO2`^WCIqwCRk?)ja^z4zS5_q_f~Z_CCii$!po0Clxs+o?8>D^T>w+zP?}^{ zOncK5@M>iJ0%hrLagS1vAf zy8cXcbH%c7*X~t!Eei+h!(EZ&{`&omtLj(X<%&mLD`dOpp(4~3o3^xzqxWAOJ^trs z-gZ2@=CRzb54?1usuq7YxNhd%EI@P;Bew4dG}cwAH^m91=d?p6+PG7f<+O z37=1?mQ?JC?h_r+o=`+|>$nPG_OjIY^$V{r}3@m6h~pO;O}Wrnj231Qh)O;41cRQhdd>cKL^V5H+gf{ zr^wSQQi}CWuTQ)VjqCHqXc2x&rW91B7WHyxE91UjEu-6~7^H{?;AcTD&!6TZuY&o<$mCfsJidrY|9gzq=uJO)hS zO12V#N(3qqs6?O=fl37a2qR$hj@20H>R&CxrN`rgiK^VN(R;S$Oui+#m2W|mTYL#e z`$9Kz#CMWBJDNjU{7d5L(kVME`B#XiOQ!6gz0|bm^2Gko>d6(iKok+Y>(u>M?76JWp_#bDdOo;DcdUfza^e73A1j=|26S+$&_u7 z{A0w^rBc=@`3aX09sS^CTK?#`7uct$p(cg$&|4rNlwOHjH`DSerg z-Xc3Rf@^yq?Y-2Sv8?u9IkXCuGoCd1=KY-7VWhno!!m579mtJ$81~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}B_5w_$Nl&uWTe9O{5)Y~8CeNYr%3+D_DtV}#B49zTD3vZBbsHx zc1%Bnz-)iStu&8ld#7UaN48_&_s9^&^&fC6$$+*m*4N=sN;qD_k1(yC$Jzc1c|>K{ z-b{;zh*TWX4tsP3=sZLr<@)gYL-T{{E)Dgeaka|$i-cS*>(VqYQjwx>->o!e78w+= G;(q`{Y9M6* diff --git a/Code-C/power.c b/Code-C/power.c index 5f2f58c..e672b4f 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -2,26 +2,26 @@ #include "getArray.h" #include "fileGestion.h" -void powerCalculation(long **p, double a[] , int N, int M , double period , double timeBandwidth){ +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; - a[i] = 0; + powerArray[i] = 0; while(j < N-1){ double aire = ( pow(p[j][i+1],2) + pow(p[j+1][i+1],2) ) / 2 * period; //printf("aire [%d,%d] : %f\n",j,i,aire); - a[i] += aire; + powerArray[i] += aire; j++; } - a[i] *= timeBandwidth; - //printf("%f\n", a[i]); + powerArray[i] *= invTimeBandwidth; + //printf("%f\n", powerArray[i]); } } -int power(int N , int M, double periode , double timeBandwidth){ +int power(int N , int M, double periode , double invTimeBandwidth){ long **p = getRawDataArray(N, M); //printArrayData(p,N,M); double pw[8]; if(p !=NULL){ - powerCalculation(p,pw,N,M,periode,timeBandwidth); + powerCalculation(p,pw,N,M,periode,invTimeBandwidth); writePowerData(pw,8); freeArray(p,N); return 0; diff --git a/Code-C/simulateFlux b/Code-C/simulateFlux deleted file mode 100755 index 646e120b9e994830bb37cbcc5bb2d02661db82d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17352 zcmeHPeQ;dWb-$}cwg7u2jGYMF#2aHKCPiz>VAn3V?8=h-l#xGbBtj>c$4dKTE!_`w z_btejGy)--jk2K35XRFb~fYlU&E zE`Wu_4sj)p9~U1JDW@)^1qZyA(*qiTwjo!K|y&e^Jd+C=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{kEenA#PWXp z8*R^jSGbDTWMTQZdPl}t-oLlvdak3t5}tA1fD>DT{7mUT7@W^$iF0jB{KhJH7{@Jjm@MyuE#1>S^l`(U_Sr7ZkG75k?p9uQa43K@`m_Xxg*aO`IB zUe~99Q+uYuWWBVO{kutEP~rNqL2Lz1{d++7uY4B@lXhu;jrh~B+x{fPCY^%J|J$U_=kyC~`OX)*do}*o`udgcl7au0#I>`7ja9*) z1WtJy4Lgic{2K6}8A+DQ|8 zYEo7f`&eRW^Kc^FA5EAsJDtgz(cFj_NGFFAmTkpCt(7fkUrpSMW-`$urj@cYN3aDa znzYPVE}1+67l&lR(sr3<kc_may8orq{^GZOED@))>xE19uu+8m0eVziT~dp|s}&&teYEu?!XQ`B){VAuxM zpUvv<>JyUOK;`U5k&Gu2@vPd%<*Hk4(Q-kiiM>?Z-?Yi9;?60#jmzWb+|uPzsr_Is zNQAOSl6JHo+|DRI#3k$#vogaXluFxH=x{0*>d(coc`+W-P^7)P#YWzxZYY`^5~0|U z6yhmvXO!kXE0c|9$ZEZ(PVr8)u(NWjKnkLnkM^j?#?l+T;*zjS?Y+m)v}hIPX)dV+JkY)g;-mHcnL MMOm!$ICwmax) max = array[i]; + } + return max; +} + +bool writeOneRawData(FILE *rawDataFile){ char buff[26]; char buff2[18]; int32_t values[8]; uint32_t valbin[8]; quartet value; - FILE *f = fopen("rawData.csv" , "a"); - if(fread(&buff, 26, 1, stdin)) { - fprintf(f , "%d,", millis()); + if(fread(&buff, 26, 1, stdin)) { + fprintf(rawDataFile , "%d,", millis()); if (strncmp(buff, "#################\n", (size_t)18) == 0) { if (!(fread(&buff2, 18, 1, stdin))) { fprintf(stderr, "Erreur lecture après ###...#"); @@ -22,47 +103,43 @@ int writeOneRawData(){ strncpy(&buff[8], buff2, 18); } } - + int maxCapteurNb = maxInArray(selectionCaptors,sizeSelectionArray); for (int i = 1; i < 9; i++){ - value.octet1 = buff[3*i+1]; - value.octet2 = buff[3*i+2]; - value.octet3 = buff[3*i+3]; - value.octet4 = 0; - - 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(intInArray(i,selectionCaptors,sizeSelectionArray)==0){ + value.octet1 = buff[3*i+1]; + value.octet2 = buff[3*i+2]; + value.octet3 = buff[3*i+3]; + value.octet4 = 0; + + 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){ - fprintf(f, "%d,", values[i]/256); - } - else{ - fprintf(f, "%d\n", values[i]/256); + if(i==maxCapteurNb){ + fprintf(rawDataFile, "%d\n", values[i]/256); + } + else{ + fprintf(rawDataFile, "%d,", values[i]/256); + } } } - fclose(f); - cpt++; - sleep(0.004); //simul la freq ech - return 0; + cptData++; + //sleep(0.004); //simul la freq ech + return true; } else { - return 1; + return false; } } +void *simulateFlux(void *vargp){ -int simulateFlux(){ - while(writeOneRawData()==0){ - if(cpt==nRows){ - tFlag = 1; - } - while(tFlag == 1){ - /*printf("max nRows"); - cpt = 0; - tFlag = 0; - break;*/ + FILE *f = createThenOpenNewRawDataFile(); + while(writeOneRawData(f)){ + if(cptData == nRow){ + cptData = 0; + cptFile++; + fclose(f); + // initialiser et/ou modifier la structure ici + f = createThenOpenNewRawDataFile(); } } -} - -int main(int argc , char argv[]){ - simulateFlux(); } \ No newline at end of file diff --git a/Code-C/simulateFlux.h b/Code-C/simulateFlux.h index 82d8a35..77fdc3e 100644 --- a/Code-C/simulateFlux.h +++ b/Code-C/simulateFlux.h @@ -3,12 +3,9 @@ #include #include #include +#include #include -int cpt = 0; -int tFlag = 0; -int nRows = 1000; - typedef struct { uint8_t octet1; uint8_t octet2; @@ -16,9 +13,12 @@ typedef struct { uint8_t octet4; } quartet; -int64_t millis() -{ - struct timespec now; - timespec_get(&now, TIME_UTC); - return ((int64_t) now.tv_sec) * 1000 + ((int64_t) now.tv_nsec) / 1000000; -} \ No newline at end of file +extern struct nameFill; + + +extern struct rawDataFile; + +nameFill getNameFill(int N); + +bool writeOneRawData(FILE *f); +void *simulateFlux(void *vargp); \ No newline at end of file diff --git a/Py-Script/Traitement-FFT.py b/Py-Script/Traitement-FFT.py index 5347b63..6907068 100644 --- a/Py-Script/Traitement-FFT.py +++ b/Py-Script/Traitement-FFT.py @@ -1,5 +1,5 @@ import numpy as np -#import matplotlib.pyplot as plt +import matplotlib.pyplot as plt import struct @@ -9,7 +9,7 @@ import struct AllRes = [[],[],[],[],[],[],[],[]] -link = "02400007.TXT" +link = "02400031.TXT" f = open(link , "rb")#ouvertuture du fichier txt traiter @@ -47,7 +47,7 @@ while True: f.close()#fermeturedu fichier txt -"""fig, (ax1, ax2) = plt.subplots(2, 1) #Création de la figure à 2 plots +fig, (ax1, ax2) = plt.subplots(2, 1) #Création de la figure à 2 plots Fe = 250000 #Fréquence d'échantillonage tstep = 1 / Fe #Time spacing @@ -70,8 +70,8 @@ sp = np.fft.fft(y,Fe) f = np.fft.fftfreq(Fe,tstep) #axe des abscisses: fréquence #Définition des courbes des plots -ax1.plot(t,y) +ax1.plot(t,y) # print y(t) ax2.plot(f,abs(sp)) #Lancement de l'affichage du plot -plt.show()""" \ No newline at end of file +plt.show() \ No newline at end of file