summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-09-24 20:47:33 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-09-24 20:47:33 +0200
commit80a92a614d62141beba2c08a0393b736a1f6b0c4 (patch)
tree62e8ccd44b712bf407708aa8d10fa5f56d240ebb
parent5ad01f6415710521173e7a612b32c982847eada4 (diff)
downloaddabmod-80a92a614d62141beba2c08a0393b736a1f6b0c4.tar.gz
dabmod-80a92a614d62141beba2c08a0393b736a1f6b0c4.tar.bz2
dabmod-80a92a614d62141beba2c08a0393b736a1f6b0c4.zip
Make capture return a json
-rw-r--r--gui/dpd/__init__.py15
-rw-r--r--gui/static/js/odr-predistortion.js2
-rw-r--r--gui/templates/predistortion.html11
3 files changed, 18 insertions, 10 deletions
diff --git a/gui/dpd/__init__.py b/gui/dpd/__init__.py
index d006c1c..16017ee 100644
--- a/gui/dpd/__init__.py
+++ b/gui/dpd/__init__.py
@@ -24,6 +24,13 @@
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
@@ -53,13 +60,13 @@ class DPD:
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)
- self.last_capture_info['tx_median'] = tx_median
- self.last_capture_info['rx_median'] = rx_median
+ self.last_capture_info['tx_median'] = float(tx_median)
+ self.last_capture_info['rx_median'] = float(rx_median)
self.last_capture_info['tx_ts'] = tx_ts
self.last_capture_info['rx_ts'] = rx_ts
- return "Captured {} samples, tx median {}, rx median {}".format(len(txframe_aligned, tx_median, rx_median))
+ return self.last_capture_info
except ValueError as e:
- return "Error: {}".format(e)
+ raise DPDError("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 13dac7a..c9b5c17 100644
--- a/gui/static/js/odr-predistortion.js
+++ b/gui/static/js/odr-predistortion.js
@@ -21,7 +21,7 @@
$(function(){
$('#capturebutton').click(function() {
doApiRequestPOST("/api/trigger_capture", {}, function(data) {
- $('#capturestatus').val(data);
+ $('#capturelength').val(data.length);
});
});
diff --git a/gui/templates/predistortion.html b/gui/templates/predistortion.html
index 316c43d..0acaf81 100644
--- a/gui/templates/predistortion.html
+++ b/gui/templates/predistortion.html
@@ -31,11 +31,12 @@ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
<div class="panel panel-default">
<div class="panel-body">
<h3>Capture</h3>
- <div class="form-group">
- <label for="capturestatus">Capture status:</label>
- <input type="text" class="form-control" id="capturestatus">
- <button type="button" class="btn btn-sm btn-info" id="capturebutton">Capture</button>
- </div>
+ <div>Number of samples captured: <span id="capturelength">None</span></div>
+
+ <div><span class="glyphicons glyphicons-question-sign"></span>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>
</div>
<div class="panel-body">
<h3>Status</h3>