summaryrefslogtreecommitdiffstats
path: root/middleware/simulation_from_log.js
diff options
context:
space:
mode:
authorkrakenrf <>2022-10-27 12:28:39 +0200
committerkrakenrf <>2022-10-27 12:28:39 +0200
commitf59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d (patch)
treef2f98d0aa2cfcca2c722d68f197209d27b6a5312 /middleware/simulation_from_log.js
parentgraph updates, apikey fix (diff)
downloadkrakensdr_pr-f59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d.tar
krakensdr_pr-f59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d.tar.gz
krakensdr_pr-f59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d.tar.bz2
krakensdr_pr-f59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d.tar.lz
krakensdr_pr-f59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d.tar.xz
krakensdr_pr-f59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d.tar.zst
krakensdr_pr-f59ea3e3ed8bb97fe1ae347e1d7b2119aa4f4f2d.zip
Diffstat (limited to 'middleware/simulation_from_log.js')
m---------middleware0
-rw-r--r--middleware/simulation_from_log.js63
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