2022-06-01 12:32:04 +02:00
|
|
|
#include "fileGestion.h"
|
|
|
|
|
2022-06-01 17:01:23 +02:00
|
|
|
void clearRawData(int N){
|
2022-06-01 12:32:04 +02:00
|
|
|
char buffer[256];
|
2022-06-02 14:29:21 +02:00
|
|
|
FILE *f = fopen("newFile.csv","w+");
|
|
|
|
FILE *g = fopen("rawData.csv","r");
|
2022-06-01 17:01:23 +02:00
|
|
|
for(int i = 0; i < N; i++){
|
|
|
|
fgets(buffer , sizeof buffer , g);
|
2022-06-01 12:32:04 +02:00
|
|
|
//printf("Line contaigns: %s" , buffer);
|
|
|
|
}
|
|
|
|
while(1){
|
2022-06-01 17:01:23 +02:00
|
|
|
if(!fgets(buffer,sizeof buffer , g)) break;
|
2022-06-01 12:32:04 +02:00
|
|
|
fprintf(f,"%s",buffer);
|
|
|
|
}
|
2022-06-02 14:29:21 +02:00
|
|
|
remove("rawData.csv"); rename("newFile.csv", "rawData.csv");
|
2022-06-08 11:25:19 +02:00
|
|
|
fclose(f); fclose(g);
|
2022-06-01 12:32:04 +02:00
|
|
|
}
|
2022-06-02 14:29:21 +02:00
|
|
|
|
|
|
|
void writePowerData(double a[], int N){
|
|
|
|
FILE *f = fopen("powerData.csv","a+");
|
|
|
|
for(int i = 0 ; i < N ; i++){
|
|
|
|
if( i < N-1){
|
|
|
|
fprintf(f, "%f , ", a[i]);
|
|
|
|
} else {
|
|
|
|
fprintf(f, "%f\n", a[i]);
|
|
|
|
}
|
|
|
|
}
|
2022-06-08 11:25:19 +02:00
|
|
|
fclose(f);
|
2022-06-10 10:10:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void threadCalcul(){
|
|
|
|
while(stopFlag == false){
|
|
|
|
if(rawDataWriteFlag){
|
|
|
|
pthread_mutex_lock(&mutex);
|
|
|
|
while(power(nRow,nCol,period,timeBandwidth) == false){}
|
|
|
|
pthread_mutex_unlock(&mutex);
|
|
|
|
rawDataWriteFlag = true;
|
|
|
|
delay(10);
|
|
|
|
}
|
|
|
|
}
|
2022-06-02 14:29:21 +02:00
|
|
|
}
|