diff options
Diffstat (limited to 'middleware/simulation_from_log.js')
m--------- | middleware | 0 | ||||
-rw-r--r-- | middleware/simulation_from_log.js | 63 |
2 files changed, 63 insertions, 0 deletions
diff --git a/middleware b/middleware deleted file mode 160000 -Subproject fd52f677a62a9a0728b4ab87d687e709f3e681d diff --git a/middleware/simulation_from_log.js b/middleware/simulation_from_log.js new file mode 100644 index 0000000..ef86304 --- /dev/null +++ b/middleware/simulation_from_log.js @@ -0,0 +1,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);
\ No newline at end of file |