aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rwxr-xr-xgui/api/__init__.py7
-rw-r--r--gui/dpd/Capture.py4
-rw-r--r--gui/dpd/__init__.py11
-rw-r--r--gui/static/js/odr-predistortion.js8
-rw-r--r--gui/static/js/odr-rcvalues.js24
-rw-r--r--gui/templates/predistortion.html6
6 files changed, 40 insertions, 20 deletions
diff --git a/gui/api/__init__.py b/gui/api/__init__.py
index 74f5feb..cef81c6 100755
--- a/gui/api/__init__.py
+++ b/gui/api/__init__.py
@@ -33,7 +33,7 @@ import datetime
def send_ok(data):
return json.dumps({'status' : 'ok', 'data': data}).encode()
-def send_error(data, reason=""):
+def send_error(reason=""):
return json.dumps({'status' : 'error', 'reason': reason}).encode()
class API:
@@ -72,7 +72,10 @@ class API:
def trigger_capture(self, **kwargs):
if cherrypy.request.method == 'POST':
cherrypy.response.headers["Content-Type"] = "application/json"
- return send_ok(self.dpd.capture_samples())
+ try:
+ return send_ok(self.dpd.capture_samples())
+ except ValueError as e:
+ return send_error(str(e))
else:
cherrypy.response.headers["Content-Type"] = "application/json"
cherrypy.response.status = 400
diff --git a/gui/dpd/Capture.py b/gui/dpd/Capture.py
index 31fa78d..de428cb 100644
--- a/gui/dpd/Capture.py
+++ b/gui/dpd/Capture.py
@@ -163,9 +163,9 @@ class Capture:
tx_median = np.median(np.abs(txframe))
if self.median_max < tx_median:
- raise ValueError("Median {} too high, decrease digital_gain!".format(tx_median))
+ raise ValueError("TX median {} too high, decrease digital_gain!".format(tx_median))
elif tx_median < self.median_min:
- raise ValueError("Median {} too low, increase digital_gain!".format(tx_median))
+ raise ValueError("TX median {} too low, increase digital_gain!".format(tx_median))
else:
rx_median = np.median(np.abs(rxframe))
rxframe = rxframe / rx_median * tx_median
diff --git a/gui/dpd/__init__.py b/gui/dpd/__init__.py
index 16017ee..8dd0807 100644
--- a/gui/dpd/__init__.py
+++ b/gui/dpd/__init__.py
@@ -24,13 +24,6 @@
from . import Capture
-class DPDError:
- def __init__(self, reason):
- self.reason = reason
-
- def __str__(self):
- return "DPD Error: {}".format(self.reason)
-
class DPD:
def __init__(self, samplerate=8192000):
self.samplerate = samplerate
@@ -56,7 +49,7 @@ class DPD:
def capture_samples(self):
"""Captures samples and store them in the accumulated samples,
- returns a string with some info"""
+ returns a dict with some info"""
try:
txframe_aligned, tx_ts, tx_median, rxframe_aligned, rx_ts, rx_median = self.capture.get_samples()
self.last_capture_info['length'] = len(txframe_aligned)
@@ -66,7 +59,7 @@ class DPD:
self.last_capture_info['rx_ts'] = rx_ts
return self.last_capture_info
except ValueError as e:
- raise DPDError("Capture failed: {}".format(e))
+ raise ValueError("Capture failed: {}".format(e))
# tx, rx, phase_diff, n_per_bin = extStat.extract(txframe_aligned, rxframe_aligned)
# off = SA.calc_offset(txframe_aligned)
diff --git a/gui/static/js/odr-predistortion.js b/gui/static/js/odr-predistortion.js
index c9b5c17..6b09202 100644
--- a/gui/static/js/odr-predistortion.js
+++ b/gui/static/js/odr-predistortion.js
@@ -21,13 +21,17 @@
$(function(){
$('#capturebutton').click(function() {
doApiRequestPOST("/api/trigger_capture", {}, function(data) {
- $('#capturelength').val(data.length);
+ console.log("trigger_capture succeeded: " + JSON.stringify(data));
+ $('#capturelength').text(data.length);
+ $('#tx_median').text(data.tx_median);
+ $('#rx_median').text(data.rx_median);
});
});
$('#dpdstatusbutton').click(function() {
doApiRequestGET("/api/dpd_status", function(data) {
- $('#dpdstatus').val(data);
+ console.log("dpd_status succeeded: " + JSON.stringify(data));
+ $('#histogram').text(data.histogram);
});
});
});
diff --git a/gui/static/js/odr-rcvalues.js b/gui/static/js/odr-rcvalues.js
index f40279d..81d895c 100644
--- a/gui/static/js/odr-rcvalues.js
+++ b/gui/static/js/odr-rcvalues.js
@@ -18,16 +18,34 @@
// You should have received a copy of the GNU General Public License
// along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
-function requestStatus(callback) {
+function buttonSetRc(key, controllable, param) {
+ var value = $("#" + key).val();
+
+ setRc(controllable, param, value, function(data) {
+ requestStatus();
+ });
+}
+
+function requestStatus() {
$('#rctable > tbody').empty();
doApiRequestGET("/api/rc_parameters", function(data) {
$.each( data, function( key1, controllable ) {
$.each( controllable, function( key2, param ) {
+ var key = key1 + "_" + key2;
+ var valueentry = '<input type="text" id="input'+key+'" ' +
+ 'value="' + param['value'] + '">' +
+ '<button type="button" class="btn btn-xs btn-warning"' +
+ 'id="button'+key+'" >upd</button>';
+
$('#rctable > tbody:last').append(
- '<tr><td>'+key1+'.'+key2+'</td>'+
- '<td>'+param['value']+'</td>'+
+ '<tr><td>'+key+'</td>'+
+ '<td>'+valueentry+'</td>'+
'<td>'+param['help']+'</td></tr>');
+
+ $('#button'+key).click(function() {
+ buttonSetRc("input"+key, key1, key2);
+ });
});
});
});
diff --git a/gui/templates/predistortion.html b/gui/templates/predistortion.html
index 0acaf81..8d5f1a5 100644
--- a/gui/templates/predistortion.html
+++ b/gui/templates/predistortion.html
@@ -32,8 +32,10 @@ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
<div class="panel-body">
<h3>Capture</h3>
<div>Number of samples captured: <span id="capturelength">None</span></div>
+ <div>TX median: <span id="tx_median">N/A</span></div>
+ <div>RX median: <span id="rx_median">N/A</span></div>
- <div><span class="glyphicons glyphicons-question-sign"></span>On pressing this button,
+ <div>On pressing this button,
the DPDCE will trigger a capture and a quick data
analysis, without updating any DPD models.</div>
<button type="button" class="btn btn-sm btn-info" id="capturebutton">Capture</button>
@@ -41,7 +43,7 @@ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
<div class="panel-body">
<h3>Status</h3>
<button type="button" class="btn btn-sm btn-info" id="dpdstatusbutton">Update</button>
- <div id="dpdstatus"></div>
+ <div>Histogram: <span id="histogram">N/A</span></div>
</div>
</div>
</div>