From b717160a90279c21c068d39673c6aafad66dfcae Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 9 Jan 2019 15:44:06 +0100 Subject: GUI: Add status to home page --- python/gui/static/js/odr-home.js | 132 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 python/gui/static/js/odr-home.js (limited to 'python/gui/static/js/odr-home.js') diff --git a/python/gui/static/js/odr-home.js b/python/gui/static/js/odr-home.js new file mode 100644 index 0000000..11aed8e --- /dev/null +++ b/python/gui/static/js/odr-home.js @@ -0,0 +1,132 @@ +// Copyright (C) 2019 +// Matthias P. Braendli, matthias.braendli@mpb.li +// +// http://www.opendigitalradio.org +// +// This file is part of ODR-DabMod. +// +// ODR-DabMod is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// ODR-DabMod is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ODR-DabMod. If not, see . +// + +function apiRequestChain(uri, get_data, success_callback, fail_callback) { + $.ajax({ + type: "GET", + url: uri, + data: get_data, + contentType: 'application/json', + dataType: 'json', + + error: function(data) { + console.log("GET " + JSON.stringify(get_data) + " error: " + data.responseText); + fail_callback(data.responseText); + }, + success: function(data) { + console.log("GET " + JSON.stringify(get_data) + " success: " + JSON.stringify(data)); + if (data.status == 'ok') { + success_callback(data.data); + } + else { + fail_callback(data.data); + } + }, + }); +} + +function mark_pending(id) { + document.getElementById(id).className = "glyphicon glyphicon-refresh glyphicon-refresh-animate"; +} + +function mark_ok(id, comment) { + document.getElementById(id).className = "glyphicon glyphicon-ok"; + + if (comment) { + document.getElementById(id + "_comment").innerHTML = comment; + } +} + +function mark_fail(id, reason) { + var el = document.getElementById(id); + el.className = "glyphicon glyphicon-remove"; + el.style.color = "#FF3333"; + + document.getElementById(id + "_comment").innerHTML = reason; + + var overall = document.getElementById("overall_state"); + overall.style.color = "#FF8833"; + overall.className = "glyphicon glyphicon-alert"; +} + +function check_rc() { + mark_pending('is_rc_ok'); + apiRequestChain("/api/parameter", + {controllable: 'sdr', param: 'freq'}, + function(data) { + mark_ok('is_rc_ok'); + check_modulating(0); + }, + function(data) { + mark_fail('is_rc_ok', JSON.parse(data)['reason']); + }); +} + +function check_modulating(last_num_frames) { + mark_pending('is_modulating'); + apiRequestChain("/api/parameter", + {controllable: 'sdr', param: 'frames'}, + function(data) { + if (data > 0) { + if (last_num_frames == 0) { + setTimeout(function() { check_modulating(data); }, 200); + } + else { + if (data == last_num_frames) { + mark_fail('is_modulating', "Frame counter not incrementing: " + data); + } + else { + mark_ok('is_modulating', "Number of frames modulated: " + data); + check_dpdce_running(); + } + } + } + else { + mark_fail('is_modulating', 'number of frames is 0'); + } + }, + function(data) { + mark_fail('is_modulating', data); + }); +} + +function check_dpdce_running() { + mark_pending('is_dpdce_running'); + apiRequestChain("/api/dpd_results", + {controllable: 'sdr', param: 'frames'}, + function(data) { + mark_ok('is_dpdce_running', "State: " + data['state']); + mark_ok('overall_state'); + }, + function(data) { + mark_fail('is_dpdce_running', JSON.parse(data)['reason']); + }); +} + +$(function(){ + setTimeout(check_rc, 20); +}); + + +// ToolTip init +$(function(){ + $('[data-toggle="tooltip"]').tooltip(); +}); -- cgit v1.2.3 From 77cfae162dea6195e8869c95db8876bbaf98fad1 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 22 Jan 2019 10:08:21 +0100 Subject: GUI: Check modulator rate on home screen --- python/gui/static/js/odr-home.js | 22 ++++++++++++++++++++-- python/gui/templates/home.html | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'python/gui/static/js/odr-home.js') diff --git a/python/gui/static/js/odr-home.js b/python/gui/static/js/odr-home.js index 11aed8e..9498ae7 100644 --- a/python/gui/static/js/odr-home.js +++ b/python/gui/static/js/odr-home.js @@ -95,7 +95,7 @@ function check_modulating(last_num_frames) { } else { mark_ok('is_modulating', "Number of frames modulated: " + data); - check_dpdce_running(); + check_rate_4x(); } } } @@ -108,10 +108,28 @@ function check_modulating(last_num_frames) { }); } +function check_rate_4x() { + mark_pending('is_rate_4x'); + apiRequestChain("/api/parameter", + {controllable: 'modulator', param: 'rate'}, + function(data) { + if (data == 8192000) { + mark_ok('is_rate_4x', "Samplerate: " + data); + check_dpdce_running(); + } + else { + mark_fail('is_rate_4x', "Samplerate is not 8192ksps: " + data); + } + }, + function(data) { + mark_fail('is_rate_4x', JSON.parse(data)['reason']); + }); +} + function check_dpdce_running() { mark_pending('is_dpdce_running'); apiRequestChain("/api/dpd_results", - {controllable: 'sdr', param: 'frames'}, + {}, function(data) { mark_ok('is_dpdce_running', "State: " + data['state']); mark_ok('overall_state'); diff --git a/python/gui/templates/home.html b/python/gui/templates/home.html index bf802d6..0a0713a 100644 --- a/python/gui/templates/home.html +++ b/python/gui/templates/home.html @@ -27,6 +27,10 @@

Checking predistortion

    +
  • Sample rate at 4x native rate: + + +
  • DPDCE running: -- cgit v1.2.3 From d7a0913ead6724bfd508a5480c7014b2516975ce Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 22 Jan 2019 11:15:00 +0100 Subject: GUI: Check for underruns in home screen --- python/gui/static/js/odr-home.js | 51 ++++++++++++++++++++++++++++++++++++---- python/gui/templates/home.html | 4 ++++ 2 files changed, 51 insertions(+), 4 deletions(-) (limited to 'python/gui/static/js/odr-home.js') diff --git a/python/gui/static/js/odr-home.js b/python/gui/static/js/odr-home.js index 9498ae7..2fa873a 100644 --- a/python/gui/static/js/odr-home.js +++ b/python/gui/static/js/odr-home.js @@ -43,8 +43,20 @@ function apiRequestChain(uri, get_data, success_callback, fail_callback) { }); } -function mark_pending(id) { +function mark_pending(id, comment) { document.getElementById(id).className = "glyphicon glyphicon-refresh glyphicon-refresh-animate"; + + if (comment) { + document.getElementById(id + "_comment").innerHTML = comment; + } +} + +var failure_encountered = false; + +function mark_overall_ok() { + if (!failure_encountered) { + document.getElementById("overall_state").className = "glyphicon glyphicon-ok"; + } } function mark_ok(id, comment) { @@ -56,6 +68,8 @@ function mark_ok(id, comment) { } function mark_fail(id, reason) { + failure_encountered = true; + var el = document.getElementById(id); el.className = "glyphicon glyphicon-remove"; el.style.color = "#FF3333"; @@ -95,7 +109,7 @@ function check_modulating(last_num_frames) { } else { mark_ok('is_modulating', "Number of frames modulated: " + data); - check_rate_4x(); + check_underrunning(0, 0); } } } @@ -108,6 +122,35 @@ function check_modulating(last_num_frames) { }); } +function check_underrunning(iteration, first_underruns) { + var n_checks = 3; + + apiRequestChain("/api/parameter", + {controllable: 'sdr', param: 'underruns'}, + function(data) { + if (iteration == 0) { + mark_pending('is_underrunning', "Checking for underruns"); + setTimeout(function() { check_underrunning(iteration+1, data); }, 2000); + } + else if (iteration < n_checks) { + mark_pending('is_underrunning', "Check " + iteration + "/" + n_checks + "..."); + setTimeout(function() { check_underrunning(iteration+1, first_underruns); }, 2000); + } + else { + if (data == first_underruns) { + mark_ok('is_underrunning', "Number of underruns is not increasing: " + data); + } + else { + mark_fail('is_underrunning', "Underruns observed in last " + n_checks + " seconds: " + data); + } + check_rate_4x(); + } + }, + function(data) { + mark_fail('is_underrunning', data); + }); +} + function check_rate_4x() { mark_pending('is_rate_4x'); apiRequestChain("/api/parameter", @@ -115,11 +158,11 @@ function check_rate_4x() { function(data) { if (data == 8192000) { mark_ok('is_rate_4x', "Samplerate: " + data); - check_dpdce_running(); } else { mark_fail('is_rate_4x', "Samplerate is not 8192ksps: " + data); } + check_dpdce_running(); }, function(data) { mark_fail('is_rate_4x', JSON.parse(data)['reason']); @@ -132,7 +175,7 @@ function check_dpdce_running() { {}, function(data) { mark_ok('is_dpdce_running', "State: " + data['state']); - mark_ok('overall_state'); + mark_overall_ok(); }, function(data) { mark_fail('is_dpdce_running', JSON.parse(data)['reason']); diff --git a/python/gui/templates/home.html b/python/gui/templates/home.html index 0a0713a..d1c8d02 100644 --- a/python/gui/templates/home.html +++ b/python/gui/templates/home.html @@ -23,6 +23,10 @@
  • +
  • Underruns: + + +

Checking predistortion -- cgit v1.2.3 From 2b3cf8e158901ae7d20dd330c34a14947191606e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 22 Jan 2019 11:40:26 +0100 Subject: GUI: Check for late packets --- python/gui/static/js/odr-home.js | 29 +++++++++++++++++++++++++++++ python/gui/templates/home.html | 4 ++++ 2 files changed, 33 insertions(+) (limited to 'python/gui/static/js/odr-home.js') diff --git a/python/gui/static/js/odr-home.js b/python/gui/static/js/odr-home.js index 2fa873a..56c8eb4 100644 --- a/python/gui/static/js/odr-home.js +++ b/python/gui/static/js/odr-home.js @@ -110,6 +110,7 @@ function check_modulating(last_num_frames) { else { mark_ok('is_modulating', "Number of frames modulated: " + data); check_underrunning(0, 0); + check_late(0, 0); } } } @@ -151,6 +152,34 @@ function check_underrunning(iteration, first_underruns) { }); } +function check_late(iteration, first_late) { + var n_checks = 3; + + apiRequestChain("/api/parameter", + {controllable: 'sdr', param: 'latepackets'}, + function(data) { + if (iteration == 0) { + mark_pending('is_late', "Checking for late packets"); + setTimeout(function() { check_late(iteration+1, data); }, 2000); + } + else if (iteration < n_checks) { + mark_pending('is_late', "Check " + iteration + "/" + n_checks + "..."); + setTimeout(function() { check_late(iteration+1, first_late); }, 2000); + } + else { + if (data == first_late) { + mark_ok('is_late', "Number of late packets is not increasing: " + data); + } + else { + mark_fail('is_late', "Late packets observed in last " + n_checks + " seconds: " + data); + } + } + }, + function(data) { + mark_fail('is_late', data); + }); +} + function check_rate_4x() { mark_pending('is_rate_4x'); apiRequestChain("/api/parameter", diff --git a/python/gui/templates/home.html b/python/gui/templates/home.html index d1c8d02..f89e18f 100644 --- a/python/gui/templates/home.html +++ b/python/gui/templates/home.html @@ -27,6 +27,10 @@ +

  • Late packets: + + +
  • Checking predistortion -- cgit v1.2.3 From e352ec38c20d626a4359c684abea23ef92a41470 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 22 Jan 2019 11:50:01 +0100 Subject: GUI: Check GPSDO status --- python/gui/static/js/odr-home.js | 24 +++++++++++++++++++++--- python/gui/templates/home.html | 4 ++++ 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'python/gui/static/js/odr-home.js') diff --git a/python/gui/static/js/odr-home.js b/python/gui/static/js/odr-home.js index 56c8eb4..b74c4c8 100644 --- a/python/gui/static/js/odr-home.js +++ b/python/gui/static/js/odr-home.js @@ -32,7 +32,6 @@ function apiRequestChain(uri, get_data, success_callback, fail_callback) { fail_callback(data.responseText); }, success: function(data) { - console.log("GET " + JSON.stringify(get_data) + " success: " + JSON.stringify(data)); if (data.status == 'ok') { success_callback(data.data); } @@ -109,9 +108,8 @@ function check_modulating(last_num_frames) { } else { mark_ok('is_modulating', "Number of frames modulated: " + data); - check_underrunning(0, 0); - check_late(0, 0); } + check_gpsdo_ok(); } } else { @@ -123,6 +121,26 @@ function check_modulating(last_num_frames) { }); } +function check_gpsdo_ok() { + mark_pending('is_gpsdo_ok'); + apiRequestChain("/api/parameter", + {controllable: 'sdr', param: 'gpsdo_num_sv'}, + function(data) { + if (data > 3) { + mark_ok('is_gpsdo_ok', "Number of SVs used: " + data); + } + else { + mark_fail('is_gpsdo_ok', "Number of SVs (" + data + ") is too low"); + } + check_underrunning(0, 0); + check_late(0, 0); + }, + function(data) { + mark_fail('is_gpsdo_ok', json.parse(data)['reason']); + }); +} + + function check_underrunning(iteration, first_underruns) { var n_checks = 3; diff --git a/python/gui/templates/home.html b/python/gui/templates/home.html index f89e18f..398df37 100644 --- a/python/gui/templates/home.html +++ b/python/gui/templates/home.html @@ -23,6 +23,10 @@ +

  • GPSDO status: + + +
  • Underruns: -- cgit v1.2.3