add flux
This commit is contained in:
parent
879fd00f3c
commit
38366241a1
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -13,6 +13,7 @@
|
||||||
"math.h": "c",
|
"math.h": "c",
|
||||||
"limits": "c",
|
"limits": "c",
|
||||||
"*.tcc": "c",
|
"*.tcc": "c",
|
||||||
"type_traits": "c"
|
"type_traits": "c",
|
||||||
|
"simulateflux.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,9 +2,8 @@ CC = gcc
|
||||||
|
|
||||||
all:
|
all:
|
||||||
# rm powerData.csv
|
# rm powerData.csv
|
||||||
$(CC) b2hd.c -o b2hd
|
$(CC) simulateFlux.c -o simulateFlux
|
||||||
$(CC) fileGestion.c getArray.c power.c main.c -lm -o main
|
$(CC) fileGestion.c getArray.c power.c main.c -lm -o main
|
||||||
# getArray.c fileGestion.c power.c main.c -o main
|
|
||||||
|
|
||||||
./b2hd < ../02400001.TXT > rawData.csv
|
./simulateFlux < ../02400001.TXT
|
||||||
./main
|
./main
|
|
@ -13,6 +13,7 @@ void clearRawData(int N){
|
||||||
fprintf(f,"%s",buffer);
|
fprintf(f,"%s",buffer);
|
||||||
}
|
}
|
||||||
remove("rawData.csv"); rename("newFile.csv", "rawData.csv");
|
remove("rawData.csv"); rename("newFile.csv", "rawData.csv");
|
||||||
|
fclose(f); fclose(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
void writePowerData(double a[], int N){
|
void writePowerData(double a[], int N){
|
||||||
|
@ -24,4 +25,5 @@ void writePowerData(double a[], int N){
|
||||||
fprintf(f, "%f\n", a[i]);
|
fprintf(f, "%f\n", a[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fclose(f);
|
||||||
}
|
}
|
BIN
Code-C/main
BIN
Code-C/main
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
#include "b2hd.h"
|
//#include "simulateFlux.h"
|
||||||
#include "getArray.h"
|
#include "getArray.h"
|
||||||
#include "fileGestion.h"
|
#include "fileGestion.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
|
BIN
Code-C/simulateFlux
Executable file
BIN
Code-C/simulateFlux
Executable file
Binary file not shown.
60
Code-C/simulateFlux.c
Normal file
60
Code-C/simulateFlux.c
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#include "simulateFlux.h"
|
||||||
|
|
||||||
|
|
||||||
|
int writeOneRawData(){
|
||||||
|
|
||||||
|
char buff[26];
|
||||||
|
char buff2[18];
|
||||||
|
int32_t values[8];
|
||||||
|
uint32_t valbin[8];
|
||||||
|
quartet value;
|
||||||
|
|
||||||
|
FILE *f = fopen("rawData.csv" , "a");
|
||||||
|
|
||||||
|
if(fread(&buff, 26, 1, stdin)) {
|
||||||
|
fprintf(f , "%d,", millis());
|
||||||
|
if (strncmp(buff, "#################\n", (size_t)18) == 0) {
|
||||||
|
if (!(fread(&buff2, 18, 1, stdin))) {
|
||||||
|
fprintf(stderr, "Erreur lecture après ###...#");
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
strncpy(buff, &buff[18], 8);
|
||||||
|
strncpy(&buff[8], buff2, 18);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i < 9; i++){
|
||||||
|
value.octet1 = buff[3*i+1];
|
||||||
|
value.octet2 = buff[3*i+2];
|
||||||
|
value.octet3 = buff[3*i+3];
|
||||||
|
value.octet4 = 0;
|
||||||
|
|
||||||
|
valbin[i] = buff[3*i+1]*256*256*256 + buff[3*i+2]*256*256 + buff[3*i+3]*256;
|
||||||
|
memcpy(&values[i], &valbin[i], sizeof(uint32_t));
|
||||||
|
|
||||||
|
if(i<8){
|
||||||
|
fprintf(f, "%d,", values[i]/256);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
fprintf(f, "%d\n", values[i]/256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
cpt++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void simulateFlux(){
|
||||||
|
while(writeOneRawData()==0){
|
||||||
|
sleep(0.004);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc , char argv[]){
|
||||||
|
simulateFlux();
|
||||||
|
printf("%d",cpt);
|
||||||
|
}
|
22
Code-C/simulateFlux.h
Normal file
22
Code-C/simulateFlux.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
int cpt = 0;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t octet1;
|
||||||
|
uint8_t octet2;
|
||||||
|
uint8_t octet3;
|
||||||
|
uint8_t octet4;
|
||||||
|
} quartet;
|
||||||
|
|
||||||
|
int64_t millis()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
timespec_get(&now, TIME_UTC);
|
||||||
|
return ((int64_t) now.tv_sec) * 1000 + ((int64_t) now.tv_nsec) / 1000000;
|
||||||
|
}
|
Loading…
Reference in a new issue