Compare commits

..

No commits in common. "6b9de5f457be5917e02b610544af425eb846ce6f" and "1c7d7edaaed0245806ce2b0f5538935709632a03" have entirely different histories.

7 changed files with 35 additions and 171 deletions

View file

@ -19,7 +19,9 @@ void averageCalculation(long **p, double averageArray[])
averageArray[i] = 0;
while (j < nRowRawData)
{
//printf("pij = %ld\n", p[i][j]);
averageArray[i - 1] += (double)p[i][j];
// printf("%f , %ld\n", averageArray[i], p[i][j]);
j++;
}
averageArray[i] /= nRowRawData;

View file

@ -1,29 +1,24 @@
#include "fileGestion.h"
/**
* @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)
{
void clearRawData(int nRow){
char buffer[256];
FILE *f = fopen("newFile.csv", "w+");
FILE *g = fopen("rawData.csv", "r");
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);
FILE *f = fopen("newFile.csv","w+");
FILE *g = fopen("rawData.csv","r");
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)
{ // 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);
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"); // finally we remove the original file and rename the new one to replace rawData.csv
fclose(f);
fclose(g);
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);
}
/**
* @brief use to write one lign in the file "fileName"
@ -31,17 +26,12 @@ void clearRawData(int nRow)
* @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 appendDataInFile(char *fileName, double array[], int nCol)
{
FILE *f = fopen(fileName, "a+");
for (int i = 0; i < nCol; i++)
{
if (i < nCol - 1)
{
void appendDataInFile(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 , ", array[i]);
}
else
{
} else {
fprintf(f, "%f\n", array[i]);
}
}

View file

@ -42,10 +42,6 @@ void printArrayData(long **p)
}
void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
{
<<<<<<< HEAD
int i = 0, j;
=======
>>>>>>> 1c7d7edaaed0245806ce2b0f5538935709632a03
char *buffer;
size_t bufsize = 200;
buffer = (char *)malloc(bufsize * sizeof(char));
@ -53,131 +49,20 @@ void fillArrayWithRawData(char *rawDataFileName, long **p, int N, int M)
FILE *f = fopen(rawDataFileName, "r");
long t, c1, c2, c3, c4, c5, c6, c7, c8;
switch (M)
{
case 2:
while (fscanf(f, "%ld,%ld[^\n] ", &t, &c1) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
i++;
}
break;
case 3:
while (fscanf(f, "%ld,%ld,%ld[^\n] ", &t, &c1, &c2) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
i++;
}
break;
case 4:
while (fscanf(f, "%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
p[i][3] = c3;
i++;
}
break;
case 5:
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
p[i][3] = c3;
p[i][4] = c4;
i++;
}
break;
case 6:
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
p[i][3] = c3;
p[i][4] = c4;
p[i][5] = c5;
i++;
}
break;
case 7:
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5, &c6) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
p[i][3] = c3;
p[i][4] = c4;
p[i][5] = c5;
p[i][6] = c6;
i++;
}
break;
case 8:
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5, &c6, &c7) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
p[i][3] = c3;
p[i][4] = c4;
p[i][5] = c5;
p[i][6] = c6;
p[i][7] = c7;
i++;
}
break;
case 9:
while (fscanf(f, "%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld[^\n] ", &t, &c1, &c2, &c3, &c4, &c5, &c6, &c7, &c8) != EOF)
{
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
p[i][3] = c3;
p[i][4] = c4;
p[i][5] = c5;
p[i][6] = c6;
p[i][7] = c7;
p[i][8] = c8;
i++;
}
break;
default:
printf("bad column size -> time + nbr captor\n");
}
/************** Debug part **************/
// for (int ii = 0; ii < nRowRawData; ii++)
// {
// for (int y = 0; y < nCol; y++)
// {
// printf("%ld,", p[ii][y]);
// if (y == nCol - 1)
// printf("lol\n");
// }
// }
fclose(f);
}
/**
* @brief print all the element of a bidimensionnal array p of shape : N x M
*/
void printArrayData(long **p, int N, int M)
{
for (int i = 0; i < N; i++)
{
printf("line n°%d : ", i);
for (int j = 0; j < M; j++)
{
printf("%ld , ", p[i][j]);
if (j == (M - 1))
printf("\n");
long t, c1, c2, c3;
while (fscanf(f, "%ld,%ld,%ld,%ld\n", &t, &c1, &c2, &c3) != EOF)
{ // séparation valeur par virgule initiale : csv
//printf("%ld,%ld,%ld,%ld\n", t, c1, c2, c3);
p[i][0] = t;
p[i][1] = c1;
p[i][2] = c2;
p[i][3] = c3;
}
printf("%ld,%ld,%ld,%ld,\n",p[0][0],p[0][1],p[0][2],p[0][3]);
for(int j = 0; j < nCol; j++){
printf("p[%d][%d] : %ld\n",i,j,p[i][j]);
}
}
printArrayData(p);

View file

@ -104,7 +104,7 @@ void *threadCalculGrowthRate(void *vargp)
powerFunction(fileName, dataLignPw);
averageFunction(fileName, dataLignAv);
growthRateFunction(dataLignPw, "growthRatePw.csv");
growthRateFunction(dataLignAv, "growthRateAv.csv");
growthRateFunction(dataLignPw, "growthRateAv.csv");
}
else
@ -126,7 +126,7 @@ void *threadCalculGrowthRate(void *vargp)
growthRateFunction(dataLignPw, "growthRatePw.csv");
growthRateFunction(dataLignPw, "growthRateAv.csv");
}
remove(fileName);
// remove(fileName);
}
}
return NULL;

View file

@ -176,7 +176,7 @@ bool writeOneRawData(FILE *rawDataFile)
}
cptData++;
/************** simul freq here **************/
// simul freq here
// struct timespec ts;
// ts.tv_sec = 0;
// ts.tv_nsec = 4 * 1000000;

View file

@ -1,13 +0,0 @@
# [Robot Go West](https://projets.cohabit.fr/redmine/projects/communication-racinaire/wiki/Robot_Go-West)
### Introduction
This projet is a part of larger projet [_Communication Racinaire_](https://projets.cohabit.fr/redmine/projects/communication-racinaire/wiki/Wiki#section-8) which aims to drive plante into the direction of the sun.
When a plant received the solar radiation, a **difference of potential** will be created inside the plant. This physical reaction interest us to **measure** it and **interpret** the signal to drive the robot.
## Embedded C sources
## Graphic visualization Python script

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB