From 92590dd3aadaeac6a8295a5b540f45b841aaa550 Mon Sep 17 00:00:00 2001 From: Cedric Godin Date: Wed, 16 Aug 2017 13:11:44 -0400 Subject: [PATCH] Corrected web ui to be compatible with the new ODAS system --- odas_interface/web_interface.ios | 14 +++++++------- ressources/js/graph.js | 16 +++++++++++++++- ressources/js/tcp_link.js | 32 +++++++++++++++++++------------- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/odas_interface/web_interface.ios b/odas_interface/web_interface.ios index 78d6cea..8749432 100644 --- a/odas_interface/web_interface.ios +++ b/odas_interface/web_interface.ios @@ -3,8 +3,8 @@ input: { - raw: { type = "file"; path = "in.raw"; format = "bin16"; } - #raw: { type = "soundcard"; card = 3; device = 0; format = "bin16"; } +# raw: { type = "file"; path = "in.raw"; format = "bin16"; } + raw: { type = "soundcard"; card = 1; device = 0; format = "bin16"; } }; @@ -38,22 +38,22 @@ output: ssl: ( - { type = "file"; path = "potential.bin"; format = "float"; } + { type = "socket"; ip = "127.0.0.1"; port = 9001; format = "json"; } ); sst: ( - { type = "file"; path = "tracked.bin"; format = "float"; } + { type = "socket"; ip = "127.0.0.1"; port = 9000; format = "json"; } ); sss: ( - { type = "file"; path = "separated_stft.bin"; format = "float"; } +# { type = "file"; path = "separated_stft.bin"; format = "float"; } ); sspf: ( - { type = "file"; path = "postfiltered_stft.bin"; format = "float"; } +# { type = "file"; path = "postfiltered_stft.bin"; format = "float"; } ); -} \ No newline at end of file +} diff --git a/ressources/js/graph.js b/ressources/js/graph.js index 20c5e4c..d7b5e46 100644 --- a/ressources/js/graph.js +++ b/ressources/js/graph.js @@ -213,6 +213,13 @@ document.addEventListener('tracking', function(e) { framCnt = 0; dataMax = currentFrame.timestamp; + + if(currentFrame.ptimestamp) { + if(currentFrame.ptimestamp > currentFrame.timestamp) { + dataMax = currentFrame.ptimestamp; + } + } + charts.forEach(function(bundle) { bundle.chart.config.options.scales.xAxes[0].ticks.max = dataMax; @@ -290,7 +297,14 @@ document.addEventListener('potential', function(e) { document.dispatchEvent(new Event('request-chart')); - dataMax = currentFrame.timestamp; + dataMax = currentFrame.ptimestamp; + + if(currentFrame.timestamp) { + if(currentFrame.timestamp > currentFrame.ptimestamp) { + dataMax = currentFrame.timestamp; + } + } + charts.forEach(function(bundle) { bundle.chart.config.options.scales.xAxes[0].ticks.max = dataMax; diff --git a/ressources/js/tcp_link.js b/ressources/js/tcp_link.js index 310e06d..1e42a1c 100644 --- a/ressources/js/tcp_link.js +++ b/ressources/js/tcp_link.js @@ -42,10 +42,12 @@ socket.onmessage = function(msg) { return; } - if(Math.abs(data.frame.timestamp - currentFrame.timestamp) > 1) - console.warn('Frame skipped ' + data.frame.timestamp.toString()); + console.log(data); + + if(Math.abs(data.timeStamp - currentFrame.timestamp) > 1) + console.warn('Frame skipped ' + data.timeStamp.toString()); - currentFrame.timestamp = data.frame.timestamp; + currentFrame.timestamp = data.timeStamp; var newMap = {}; var indexPool = []; @@ -54,9 +56,13 @@ socket.onmessage = function(msg) { }); var hasNewSource = false; - if(data.frame.src) { // If frame contains sources - - data.frame.src.forEach(function(src) { // Remove still used index from the pool + data.src = data.src.filter(function(s) { + return s.id !== 0; + }); + + if(data.src) { // If frame contains sources + + data.src.forEach(function(src) { // Remove still used index from the pool if(typeof(indexMap[src.id])!='undefined') { // If source is not new indexPool.splice(indexPool.indexOf(indexMap[src.id]),1); @@ -64,7 +70,7 @@ socket.onmessage = function(msg) { } }); - data.frame.src.forEach(function(src) { // Update sources + data.src.forEach(function(src) { // Update sources if(typeof(indexMap[src.id])!='undefined') { // Source is already registered @@ -135,19 +141,19 @@ potentialSocket.onmessage = function(msg) { return; } - if(Math.abs(data.frame.timestamp - currentFrame.ptimestamp) > 1) - console.warn('Frame skipped ' + data.frame.timestamp.toString()); + if(Math.abs(data.timeStamp - currentFrame.ptimestamp) > 1) + console.warn('Frame skipped ' + data.timeStamp.toString()); - currentFrame.ptimestamp = data.frame.timestamp; + currentFrame.ptimestamp = data.timeStamp; currentFrame.potentialSources = []; - if(data.frame.src) { // If frame contains sources + if(data.src) { // If frame contains sources - data.frame.src.forEach(function(source) { + data.src.forEach(function(source) { var newSource = new PotentialSource(); - newSource.e = source.e; + newSource.e = source.E; newSource.x = source.x; newSource.y = source.y; newSource.z = source.z; -- 2.34.1