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 45755a3..69213d7 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 de1b7eb..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