modif on frequency in simulflux and fix average

This commit is contained in:
Aurélien Gauthier 2022-06-24 15:42:25 +02:00
parent 5e57356f85
commit ee3d1315c0
4 changed files with 29 additions and 10 deletions

View file

@ -5,6 +5,9 @@ include(CTest)
enable_testing() enable_testing()
set(CMAKE_C_FLAGS "-std=c99 -g -Wall") 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 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) # add_executable(exect main.c simulateFlux.c queue.c power.c growthRate.c average.c getArray.c fileGestion.c)

View file

@ -49,6 +49,7 @@ void *threadCalculAverage(void *vargp)
{ {
Pqueue rawDataQueue = firstRawDataQueue; Pqueue rawDataQueue = firstRawDataQueue;
char *fileName; char *fileName;
while (rawDataWriteFlag) while (rawDataWriteFlag)
{ {
while (queueGetNextE(rawDataQueue) != NULL) while (queueGetNextE(rawDataQueue) != NULL)
@ -124,7 +125,7 @@ void *threadCalculGrowthRate(void *vargp)
growthRateFunction(dataLignPw, "growthRatePw.csv"); growthRateFunction(dataLignPw, "growthRatePw.csv");
growthRateFunction(dataLignPw, "growthRateAv.csv"); growthRateFunction(dataLignPw, "growthRateAv.csv");
} }
remove(fileName); // remove(fileName);
} }
} }
return NULL; return NULL;
@ -154,11 +155,19 @@ int main(int argc, char **argv)
exit(1); exit(1);
} }
pthread_t calcul; // pthread_t calculAverage;
if (pthread_create(&calcul, NULL, threadCalculAverage, "threadCalcul")) // 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); exit(1);
} }
pthread_exit(NULL); pthread_exit(NULL);
} }

View file

@ -37,7 +37,7 @@ void powerCalculation(long **p, double powerArray[])
void powerFunction(char *rawDataFileName, double **pw) void powerFunction(char *rawDataFileName, double **pw)
{ {
long **p = getRawDataArray(rawDataFileName); long **p = getRawDataArray(rawDataFileName);
printArrayData(p, nRowRawData, nCol); // printArrayData(p, nRowRawData, nCol);
double pww[nCol - 1]; double pww[nCol - 1];
if (p != NULL) if (p != NULL)
{ {

View file

@ -1,9 +1,9 @@
#include "simulateFlux.h" #include "simulateFlux.h"
#include "initialParameters.h" #include "initialParameters.h"
#include "queue.h" #include "queue.h"
//#include <linux/time.h>
#include "time.h" #include <time.h>
#include <errno.h>
/** /**
* @brief convert an interger N into a char* * @brief convert an interger N into a char*
@ -46,7 +46,7 @@ char *convertIntegerToChar(int N)
*/ */
char *createNewRawDataFileName() char *createNewRawDataFileName()
{ {
char *fileName = "../RawDataFiles/RawData"; char *fileName = "RawDataFiles/RawData";
char *extension = ".csv\0"; char *extension = ".csv\0";
char *fileNumber = convertIntegerToChar(cptFile); char *fileNumber = convertIntegerToChar(cptFile);
// char *fileNumber; // char *fileNumber;
@ -94,7 +94,7 @@ int64_t millis()
{ {
struct timespec now; struct timespec now;
timespec_get(&now, TIME_UTC); 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() int lastIndexCaptor()
@ -133,6 +133,7 @@ bool writeOneRawData(FILE *rawDataFile)
fprintf(timeFile, "%ld\n", millis()); fprintf(timeFile, "%ld\n", millis());
fclose(timeFile); fclose(timeFile);
fprintf(rawDataFile, "%ld,", millis()); fprintf(rawDataFile, "%ld,", millis());
if (strncmp(buff, "#################\n", (size_t)18) == 0) if (strncmp(buff, "#################\n", (size_t)18) == 0)
{ {
if (!(fread(&buff2, 18, 1, stdin))) if (!(fread(&buff2, 18, 1, stdin)))
@ -174,7 +175,12 @@ bool writeOneRawData(FILE *rawDataFile)
} }
} }
cptData++; 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++; cptValue++;
return true; return true;
@ -195,6 +201,7 @@ void *threadSimulateFlux(void *vargp)
while (writeOneRawData(rawDataFile)) while (writeOneRawData(rawDataFile))
{ {
if (cptData == nRowRawData) if (cptData == nRowRawData)
{ {
fclose(rawDataFile); fclose(rawDataFile);