Fix bug of API variable names, discovered after speedup

This commit is contained in:
30hours 2024-01-02 08:50:46 +00:00
parent a78a1a2f3c
commit 039d09dff4

View file

@ -2,10 +2,10 @@ const express = require('express');
const dgram = require('dgram'); const dgram = require('dgram');
const net = require("net"); const net = require("net");
var data_map = require('./stash/maxhold.js'); var stash_map = require('./stash/maxhold.js');
var data_detection = require('./stash/detection.js'); var stash_detection = require('./stash/detection.js');
var data_iqdata = require('./stash/iqdata.js'); var stash_iqdata = require('./stash/iqdata.js');
var data_timing = require('./stash/timing.js'); var stash_timing = require('./stash/timing.js');
// constants // constants
const PORT = 3000; const PORT = 3000;
@ -17,6 +17,12 @@ var timestamp = '';
var timing = ''; var timing = '';
var iqdata = ''; var iqdata = '';
var data = ''; var data = '';
var data_map;
var data_detection;
var data_tracker;
var data_timestamp;
var data_timing;
var data_iqdata;
var capture = false; var capture = false;
// api server // api server
@ -53,16 +59,16 @@ app.get('/api/iqdata', (req, res) => {
// stash API // stash API
app.get('/stash/map', (req, res) => { app.get('/stash/map', (req, res) => {
res.send(data_map.get_data_map()); res.send(stash_map.get_data_map());
}); });
app.get('/stash/detection', (req, res) => { app.get('/stash/detection', (req, res) => {
res.send(data_detection.get_data_detection()); res.send(stash_detection.get_data_detection());
}); });
app.get('/stash/iqdata', (req, res) => { app.get('/stash/iqdata', (req, res) => {
res.send(data_iqdata.get_data_iqdata()); res.send(stash_iqdata.get_data_iqdata());
}); });
app.get('/stash/timing', (req, res) => { app.get('/stash/timing', (req, res) => {
res.send(data_timing.get_data_timing()); res.send(stash_timing.get_data_timing());
}); });
// read state of capture // read state of capture
@ -82,11 +88,11 @@ app.listen(PORT, HOST, () => {
const server_map = net.createServer((socket)=>{ const server_map = net.createServer((socket)=>{
socket.write("Hello From Server!") socket.write("Hello From Server!")
socket.on("data",(msg)=>{ socket.on("data",(msg)=>{
data = data + msg.toString(); data_map = data_map + msg.toString();
if (data.slice(-1) === "}") if (data_map.slice(-1) === "}")
{ {
map = data; map = data_map;
data = ''; data_map = '';
} }
}); });
socket.on("close",()=>{ socket.on("close",()=>{
@ -99,11 +105,11 @@ server_map.listen(3001);
const server_detection = net.createServer((socket)=>{ const server_detection = net.createServer((socket)=>{
socket.write("Hello From Server!") socket.write("Hello From Server!")
socket.on("data",(msg)=>{ socket.on("data",(msg)=>{
data = data + msg.toString(); data_detection = data_detection + msg.toString();
if (data.slice(-1) === "}") if (data_detection.slice(-1) === "}")
{ {
detection = data; detection = data_detection;
data = ''; data_detection = '';
} }
}); });
socket.on("close",()=>{ socket.on("close",()=>{
@ -116,11 +122,11 @@ server_detection.listen(3002);
const server_tracker = net.createServer((socket)=>{ const server_tracker = net.createServer((socket)=>{
socket.write("Hello From Server!") socket.write("Hello From Server!")
socket.on("data",(msg)=>{ socket.on("data",(msg)=>{
data = data + msg.toString(); data_tracker = data_tracker + msg.toString();
if (data.slice(-1) === "}") if (data_tracker.slice(-1) === "}")
{ {
track = data; track = data_tracker;
data = ''; data_tracker = '';
} }
}); });
socket.on("close",()=>{ socket.on("close",()=>{
@ -133,9 +139,9 @@ server_tracker.listen(3003);
const server_timestamp = net.createServer((socket)=>{ const server_timestamp = net.createServer((socket)=>{
socket.write("Hello From Server!") socket.write("Hello From Server!")
socket.on("data",(msg)=>{ socket.on("data",(msg)=>{
data = data + msg.toString(); data_timestamp = data_timestamp + msg.toString();
timestamp = data; timestamp = data_timestamp;
data = ''; data_timestamp = '';
}); });
socket.on("close",()=>{ socket.on("close",()=>{
console.log("Connection closed."); console.log("Connection closed.");
@ -147,11 +153,11 @@ server_timestamp.listen(4000);
const server_timing = net.createServer((socket)=>{ const server_timing = net.createServer((socket)=>{
socket.write("Hello From Server!") socket.write("Hello From Server!")
socket.on("data",(msg)=>{ socket.on("data",(msg)=>{
data = data + msg.toString(); data_timing = data_timing + msg.toString();
if (data.slice(-1) === "}") if (data_timing.slice(-1) === "}")
{ {
timing = data; timing = data_timing;
data = ''; data_timing = '';
} }
}); });
socket.on("close",()=>{ socket.on("close",()=>{
@ -164,11 +170,11 @@ server_timing.listen(4001);
const server_iqdata = net.createServer((socket)=>{ const server_iqdata = net.createServer((socket)=>{
socket.write("Hello From Server!") socket.write("Hello From Server!")
socket.on("data",(msg)=>{ socket.on("data",(msg)=>{
data = data + msg.toString(); data_iqdata = data_iqdata + msg.toString();
if (data.slice(-1) === "}") if (data_iqdata.slice(-1) === "}")
{ {
iqdata = data; iqdata = data_iqdata;
data = ''; data_iqdata = '';
} }
}); });
socket.on("close",()=>{ socket.on("close",()=>{