1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
const axios = require('axios');
const fs = require('fs');
const { syncBuiltinESMExports } = require('module');
var logArray = [];
var logIndex = 0;
try {
const data = fs.readFileSync('redoubt360.csv', 'UTF-8');
const lines = data.split(/\r?\n/);
lines.forEach(line => {
var logData = line.split(',');
var logEntry = {
tStamp: parseInt(logData[0]),
latitude: parseFloat(logData[1]),
longitude: parseFloat(logData[2]),
gpsBearing: parseFloat(logData[3]),
radioBearing: parseFloat(logData[5]),
conf: parseInt(logData[6]),
power: parseFloat(logData[7]),
freq: parseInt(logData[8]),
antType: logData[9],
latency: parseInt(logData[10]),
doaArray: logData.slice(12, logData.length-1).map(x => parseFloat(x))+",",
};
/*
// new Format
var logEntry = {
tStamp: parseInt(logData[0]),
latitude: parseFloat(logData[8]),
longitude: parseFloat(logData[9]),
gpsBearing: parseFloat(logData[10]),
radioBearing: parseFloat(logData[1]),
conf: parseFloat(logData[2]),
power: parseFloat(logData[3]),
freq: parseInt(logData[4]),
antType: logData[5],
latency: parseInt(logData[6]),
doaArray: logData.slice(17, logData.length).map(x => parseFloat(x))+",",
};*/
//console.log(logEntry.doaArray);
logArray.push(logEntry);
});
} catch (err) {
console.error(err);
}
setInterval(() => {
if (logIndex <= logArray.length) {
console.log("Sending Data as kraken: "+logArray[logIndex])
axios.post('http://localhost:8042/doapost', logArray[logIndex])
.then(function (response) {
//console.log(response);
})
.catch(function (error) {
console.log(error);
});
logIndex++;
}
}, 1000);
|