diff --git a/Code-C/CMakeLists.txt b/Code-C/CMakeLists.txt index 3fdd809..5b391f7 100644 --- a/Code-C/CMakeLists.txt +++ b/Code-C/CMakeLists.txt @@ -5,6 +5,9 @@ include(CTest) enable_testing() set(CMAKE_C_FLAGS "-std=c99 -g -Wall") +file(MAKE_DIRECTORY RawDataFiles) +file(MAKE_DIRECTORY Executable) + add_executable(exect fileGestion.c getArray.c average.c growthRate.c power.c queue.c simulateFlux.c main.c) # add_executable(exect main.c simulateFlux.c queue.c power.c growthRate.c average.c getArray.c fileGestion.c) diff --git a/Code-C/main.c b/Code-C/main.c index b3b69ae..e5f6c0e 100644 --- a/Code-C/main.c +++ b/Code-C/main.c @@ -49,6 +49,7 @@ void *threadCalculAverage(void *vargp) { Pqueue rawDataQueue = firstRawDataQueue; char *fileName; + while (rawDataWriteFlag) { while (queueGetNextE(rawDataQueue) != NULL) @@ -124,7 +125,7 @@ void *threadCalculGrowthRate(void *vargp) growthRateFunction(dataLignPw, "growthRatePw.csv"); growthRateFunction(dataLignPw, "growthRateAv.csv"); } - remove(fileName); + // remove(fileName); } } return NULL; @@ -154,11 +155,19 @@ int main(int argc, char **argv) exit(1); } - pthread_t calcul; - if (pthread_create(&calcul, NULL, threadCalculAverage, "threadCalcul")) + // pthread_t calculAverage; + // if (pthread_create(&calculAverage, NULL, threadCalculAverage, "threadCalculAverage")) + // { + // perror("threadCalculAverage() error"); + // exit(1); + // } + + pthread_t calculGrowthRate; + if (pthread_create(&calculGrowthRate, NULL, threadCalculGrowthRate, "threadCalculGrowthRate")) { - perror("threadCalculAverage() error"); + perror("threadcalculGrowthRate() error"); exit(1); } + pthread_exit(NULL); } \ No newline at end of file diff --git a/Code-C/power.c b/Code-C/power.c index 4202d9f..596110f 100644 --- a/Code-C/power.c +++ b/Code-C/power.c @@ -37,7 +37,7 @@ void powerCalculation(long **p, double powerArray[]) void powerFunction(char *rawDataFileName, double **pw) { long **p = getRawDataArray(rawDataFileName); - printArrayData(p, nRowRawData, nCol); + // printArrayData(p, nRowRawData, nCol); double pww[nCol - 1]; if (p != NULL) { diff --git a/Code-C/simulateFlux.c b/Code-C/simulateFlux.c index fd31523..14b5e2e 100644 --- a/Code-C/simulateFlux.c +++ b/Code-C/simulateFlux.c @@ -1,9 +1,9 @@ #include "simulateFlux.h" #include "initialParameters.h" #include "queue.h" -//#include -#include "time.h" +#include +#include /** * @brief convert an interger N into a char* @@ -46,7 +46,7 @@ char *convertIntegerToChar(int N) */ char *createNewRawDataFileName() { - char *fileName = "../RawDataFiles/RawData"; + char *fileName = "RawDataFiles/RawData"; char *extension = ".csv\0"; char *fileNumber = convertIntegerToChar(cptFile); // char *fileNumber; @@ -94,7 +94,7 @@ int64_t millis() { struct timespec now; timespec_get(&now, TIME_UTC); - return ((int64_t)now.tv_sec) * 1000 + ((int64_t)now.tv_nsec) / 1000000; + return ((int64_t)((int64_t)now.tv_sec) * 1000 + ((int64_t)now.tv_nsec) / 1000000); } int lastIndexCaptor() @@ -133,6 +133,7 @@ bool writeOneRawData(FILE *rawDataFile) fprintf(timeFile, "%ld\n", millis()); fclose(timeFile); fprintf(rawDataFile, "%ld,", millis()); + if (strncmp(buff, "#################\n", (size_t)18) == 0) { if (!(fread(&buff2, 18, 1, stdin))) @@ -174,7 +175,12 @@ bool writeOneRawData(FILE *rawDataFile) } } cptData++; - // sleep(0.004); //simul freq here + + // simul freq here + // struct timespec ts; + // ts.tv_sec = 0; + // ts.tv_nsec = 4 * 1000000; + // nanosleep(&ts, &ts); cptValue++; return true; @@ -195,6 +201,7 @@ void *threadSimulateFlux(void *vargp) while (writeOneRawData(rawDataFile)) { + if (cptData == nRowRawData) { fclose(rawDataFile);