aboutsummaryrefslogtreecommitdiffstats
path: root/python/gui
diff options
context:
space:
mode:
Diffstat (limited to 'python/gui')
-rwxr-xr-xpython/gui/api.py18
-rw-r--r--python/gui/static/js/odr-predistortion.js98
-rw-r--r--python/gui/templates/predistortion.html23
3 files changed, 70 insertions, 69 deletions
diff --git a/python/gui/api.py b/python/gui/api.py
index 42c89c9..c0effde 100755
--- a/python/gui/api.py
+++ b/python/gui/api.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2018
+# Copyright (C) 2019
# Matthias P. Braendli, matthias.braendli@mpb.li
#
# http://www.opendigitalradio.org
@@ -125,12 +125,20 @@ class API:
@cherrypy.expose
@cherrypy.tools.json_out()
- def dpd_settings(self, setting: str, value: str, **kwargs):
+ def dpd_restore_dump(self, **kwargs):
if cherrypy.request.method == 'POST':
- data = {'setting': setting, 'value': value}
- return self._wrap_dpd("set_setting", data)
+ cl = cherrypy.request.headers['Content-Length']
+ rawbody = cherrypy.request.body.read(int(cl))
+ params = json.loads(rawbody.decode())
+ if 'dump_id' in params:
+ data = {'dump_id': params['dump_id']}
+ return self._wrap_dpd("restore_dump", data)
+ else:
+ cherrypy.response.status = 400
+ return send_error("Missing dump_id")
else:
- return self._wrap_dpd("get_settings")
+ cherrypy.response.status = 400
+ return send_error("POST only")
@cherrypy.expose
@cherrypy.tools.json_out()
diff --git a/python/gui/static/js/odr-predistortion.js b/python/gui/static/js/odr-predistortion.js
index b5f29ea..4dae068 100644
--- a/python/gui/static/js/odr-predistortion.js
+++ b/python/gui/static/js/odr-predistortion.js
@@ -1,4 +1,4 @@
-// Copyright (C) 2018
+// Copyright (C) 2019
// Matthias P. Braendli, matthias.braendli@mpb.li
//
// http://www.opendigitalradio.org
@@ -18,6 +18,8 @@
// You should have received a copy of the GNU General Public License
// along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
+var adapt_dumps = [];
+
function resultrefresh() {
var jqxhr = doApiRequestGET("/api/dpd_results", function(data) {
var summary = "";
@@ -51,6 +53,8 @@ function resultrefresh() {
else {
$('#dpdmodelplot').attr('src', "");
}
+
+ adapt_dumps = data['adapt_dumps'];
});
jqxhr.always(function() {
@@ -58,6 +62,30 @@ function resultrefresh() {
});
}
+function adaptdumpsrefresh() {
+ $('#dpdadaptdumps').html("");
+
+ $.each(adapt_dumps, function(i, item) {
+ console.log(item);
+
+ if (isNaN(+item)) {
+ $('#dpdadaptdumps').append($('<option>', {
+ value: item,
+ text : "DPD settings from " + item,
+ }));
+ }
+ else {
+ var d = new Date(0);
+ d.setUTCSeconds(item);
+
+ $('#dpdadaptdumps').append($('<option>', {
+ value: item,
+ text : "DPD settings from " + d.toISOString(),
+ }));
+ }
+ });
+}
+
$(function(){
setTimeout(resultrefresh, 20);
@@ -86,72 +114,20 @@ $(function(){
});
});
-});
+ $('#adaptdumpsrefreshbtn').click(adaptdumpsrefresh);
-/*
-function calibraterefresh() {
- doApiRequestGET("/api/calibrate", function(data) {
- var text = "Captured TX signal and feedback." +
- " TX median: " + data['tx_median'] +
- " RX median: " + data['rx_median'] +
- " with relative timestamp offset " +
- (data['tx_ts'] - data['rx_ts']) +
- " and measured offset " + data['coarse_offset'] +
- ". Correlation: " + data['correlation'];
- $('#calibrationresults').text(text);
- });
-}
-
-$(function(){
- $('#refreshframesbtn').click(function() {
- var d = new Date();
- var n = d.getTime();
- $('#txframeimg').src = "dpd/txframe.png?cachebreak=" + n;
- $('#rxframeimg').src = "dpd/rxframe.png?cachebreak=" + n;
- });
+ $('#adaptdumpsload').click(function() {
+ var elt = document.getElementById("dpdadaptdumps");
- $('#capturebutton').click(function() {
- doApiRequestPOST("/api/trigger_capture", {}, function(data) {
- console.log("trigger_capture succeeded: " + JSON.stringify(data));
- });
- });
-
- $('#dpdstatusbutton').click(function() {
- doApiRequestGET("/api/dpd_status", function(data) {
- console.log("dpd_status succeeded: " + JSON.stringify(data));
- $('#histogram').text(data.histogram);
- $('#capturestatus').text(data.capture.status);
- $('#capturelength').text(data.capture.length);
- $('#tx_median').text(data.capture.tx_median);
- $('#rx_median').text(data.capture.rx_median);
- });
-
- $.ajax({
- type: "GET",
- url: "/api/dpd_capture_pointcloud",
-
- error: function(data) {
- if (data.status == 500) {
- var errorWindow = window.open("", "_self");
- errorWindow.document.write(data.responseText);
- }
- else {
- $.gritter.add({ title: 'API',
- text: "AJAX failed: " + data.statusText,
- image: '/fonts/warning.png',
- sticky: true,
- });
- }
- },
- success: function(data) {
- $('#dpd_pointcloud').value(data)
+ if (elt.selectedIndex != -1) {
+ var selectedoption = elt.options[elt.selectedIndex].value;
+ doApiRequestPOST("/api/dpd_restore_dump", {dump_id: selectedoption}, function(data) {
+ console.log("reset succeeded: " + JSON.stringify(data));
+ });
}
- })
});
});
-*/
-
// ToolTip init
$(function(){
diff --git a/python/gui/templates/predistortion.html b/python/gui/templates/predistortion.html
index 8682054..62e8503 100644
--- a/python/gui/templates/predistortion.html
+++ b/python/gui/templates/predistortion.html
@@ -14,7 +14,7 @@
<div class="container-fluid">
<div class="row">
- <div class="col-sm-8">
+ <div class="col-sm-4">
<h2>Current DPDCE status</h2>
<div>
<div id="dpdstatus" style="font-weight:bold;">N/A</div>
@@ -27,6 +27,21 @@
<div class="well well-sm" id="dpdresults">N/A</div>
</div>
<div class="col-sm-4">
+ <h2>List of saved DPD settings</h2>
+ <!--TODO: 'erase' and 'clear' buttons. Show DPD settings in tooltip?-->
+ <p>This list contains previously used predistortion settings that you
+ can recall.</p>
+ <p>
+ <select id="dpdadaptdumps" size="8" style="width:70%" multiple></select>
+ </p>
+ <p>
+ <button type="button" class="btn btn-sm btn-info" id="adaptdumpsrefreshbtn">Refresh
+ </button>
+ <button type="button" class="btn btn-sm btn-warning" id="adaptdumpsload">Load and Apply
+ </button>
+ </p>
+ </div>
+ <div class="col-sm-4">
<h2>Summary</h2>
<p>Calibration needs to be done once before the PA model
can be trained. Every time calibration is changed, the predistortion
@@ -36,6 +51,8 @@
runs are needed before the model can be trained.</p>
<p>The capture and model analysis will calculate a new set of
DPD model data, that you can apply using the Update Predistorter button.</p>
+ <p>The reset button allows you to reset the computation engine. It does not
+ modify the currently active predistorter.</p>
</div>
</div>
</div>
@@ -47,7 +64,7 @@
<button type="button" class="btn btn-sm btn-warning" id="adaptbtn">
Update Predistorter</button>
<button type="button" class="btn btn-sm btn-info" id="resetbtn">
- Reset captured data</button>
+ Reset Capture and Model</button>
</div>
</div>
@@ -97,7 +114,7 @@
</html>
<!--
- Copyright (C) 2018
+ Copyright (C) 2019
Matthias P. Braendli, matthias.braendli@mpb.li
This file is part of ODR-DabMod.