From 4d027c5969b22856c7ed603ec4c712a2436d732d Mon Sep 17 00:00:00 2001 From: 30hours Date: Tue, 2 Jan 2024 11:14:13 +0000 Subject: [PATCH] Make timestamp in ms and time based detection stash --- api/stash/detection.js | 15 ++++++++++++--- src/blah2.cpp | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/stash/detection.js b/api/stash/detection.js index 2d7d4a3..4d7846e 100644 --- a/api/stash/detection.js +++ b/api/stash/detection.js @@ -1,6 +1,6 @@ const http = require('http'); -var nCpi = 100; +var time = 300; var map = []; var timestamp = []; var delay = []; @@ -38,8 +38,17 @@ function update_data() { try { detection = JSON.parse(body_map); map.push(detection); - if (map.length > nCpi) { - map.shift(); + for (i = 0; i < map.length; i++) + { + console.log((ts - map[i].timestamp)/1000); + if ((ts - map[i].timestamp)/1000 > time) + { + map.shift(); + } + else + { + break; + } } delay = []; doppler = []; diff --git a/src/blah2.cpp b/src/blah2.cpp index c8361fd..ad99aa1 100644 --- a/src/blah2.cpp +++ b/src/blah2.cpp @@ -331,7 +331,7 @@ int main(int argc, char **argv) timing_name.clear(); // output CPI timestamp for updating data - std::string t0_string = std::to_string(time[0]); + std::string t0_string = std::to_string(time[0]/1000); socket_timestamp.write_some(asio::buffer(t0_string, 100), err); time.clear(); }