modif on frequency in simulflux and fix average
This commit is contained in:
parent
5e57356f85
commit
ee3d1315c0
|
@ -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)
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "simulateFlux.h"
|
||||
#include "initialParameters.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*
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue