aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-07 11:46:45 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-07 11:46:45 +0200
commit04c3650d5f730891c33e45d2f07c052c6393c2e8 (patch)
treed95431a387598f88b4a05df7a1dd3d3c91f6126b /python
parentf6e3913f80ec15f2a554dc2ad1fe219cefd1f5d2 (diff)
parent3a7202306c6aca5be2dad604f62063d605fd0982 (diff)
downloaddabmod-04c3650d5f730891c33e45d2f07c052c6393c2e8.tar.gz
dabmod-04c3650d5f730891c33e45d2f07c052c6393c2e8.tar.bz2
dabmod-04c3650d5f730891c33e45d2f07c052c6393c2e8.zip
Merge branch 'next' into lime
Diffstat (limited to 'python')
-rw-r--r--python/dpd/Adapt.py6
-rwxr-xr-xpython/dpdce.py32
-rw-r--r--python/gui-dpdce.ini1
-rwxr-xr-xpython/gui.py22
-rw-r--r--python/gui/templates/modulator.html2
5 files changed, 33 insertions, 30 deletions
diff --git a/python/dpd/Adapt.py b/python/dpd/Adapt.py
index a30f0c8..745a507 100644
--- a/python/dpd/Adapt.py
+++ b/python/dpd/Adapt.py
@@ -76,7 +76,7 @@ class Adapt:
try:
return float(self._mod_rc.get_param_value("sdr", "txgain"))
except ValueError as e:
- logging.warning(f"Adapt: get_txgain error: {e}")
+ logging.warning("Adapt: get_txgain error: {}".format(e))
return -1.0
def set_rxgain(self, gain: float) -> None:
@@ -90,7 +90,7 @@ class Adapt:
try:
return float(self._mod_rc.get_param_value("sdr", "rxgain"))
except ValueError as e:
- logging.warning(f"Adapt: get_rxgain error: {e}")
+ logging.warning("Adapt: get_rxgain error: {}".format(e))
return -1.0
def set_digital_gain(self, gain: float) -> None:
@@ -102,7 +102,7 @@ class Adapt:
try:
return float(self._mod_rc.get_param_value("gain", "digital"))
except ValueError as e:
- logging.warning(f"Adapt: get_digital_gain error: {e}")
+ logging.warning("Adapt: get_digital_gain error: {}".format(e))
return -1.0
def get_predistorter(self):
diff --git a/python/dpdce.py b/python/dpdce.py
index cf98aa0..94cc7c8 100755
--- a/python/dpdce.py
+++ b/python/dpdce.py
@@ -335,13 +335,13 @@ def engine_worker():
lr = Heuristics.get_learning_rate(iteration)
- summary = [f"Set predistorter:",
- f"Signal measurements after iteration {iteration} with learning rate {lr}",
- f"TX MER {tx_mer:.2}, RX MER {rx_mer:.2}",
- f"Mean-square error: {mse:.3}"]
+ summary = ["Set predistorter:",
+ "Signal measurements after iteration {} with learning rate {}".format(iteration, lr),
+ "TX MER {:.2}, RX MER {:.2}".format(tx_mer, rx_mer),
+ "Mean-square error: {:.3}".format(mse)]
if tx_shoulder_tuple is not None:
summary.append("Shoulders: TX {!r}, RX {!r}".format(tx_shoulder_tuple, rx_shoulder_tuple))
- summary.append(f"Running with digital gain {digital_gain}, TX gain {tx_gain} and RX gain {rx_gain}")
+ summary.append("Running with digital gain {}, TX gain {} and RX gain {}".format(digital_gain, tx_gain, rx_gain))
with lock:
results['state'] = 'Update Predistorter'
@@ -360,33 +360,33 @@ def engine_worker():
with lock:
results['state'] = 'Idle'
results['stateprogress'] = 100
- results['summary'] = [f"Restored DPD defaults",
- f"Running with digital gain {digital_gain}, TX gain {tx_gain} and RX gain {rx_gain}"]
+ results['summary'] = ["Restored DPD defaults",
+ "Running with digital gain {}, TX gain {} and RX gain {}".format(digital_gain, tx_gain, rx_gain)]
results['modeldata'] = dpddata_to_str(dpddata)
else:
- dump_file = os.path.join(plot_path, f"adapt_{dump_id}.pkl")
+ dump_file = os.path.join(plot_path, "adapt_{}.pkl".format(dump_id))
try:
d = adapt.restore(dump_file)
- logging.info(f"Restore: {d}")
+ logging.info("Restore: {}".format(d))
model.set_dpd_data(d['dpddata'])
with lock:
results['state'] = 'Idle'
results['stateprogress'] = 100
- results['summary'] = [f"Restored DPD settings from dumpfile {dump_id}",
- f"Running with digital gain {d['digital_gain']}, TX gain {d['txgain']} and RX gain {d['rxgain']}"]
+ results['summary'] = ["Restored DPD settings from dumpfile {}".format(dump_id),
+ "Running with digital gain {}, TX gain {} and RX gain {}".format(d['digital_gain'], d['tx_gain'], d['rx_gain'])]
results['modeldata'] = dpddata_to_str(d["dpddata"])
except:
e = traceback.format_exc()
with lock:
results['state'] = 'Idle'
results['stateprogress'] = 100
- results['summary'] = [f"Failed to restore DPD settings from dumpfile {dump_id}",
- f"Error: {e}"]
+ results['summary'] = ["Failed to restore DPD settings from dumpfile {}".format(dump_id),
+ "Error: {}".format(e)]
except:
e = traceback.format_exc()
logging.error(e)
with lock:
- results['summary'] = [f"Exception:"] + e.split("\n")
+ results['summary'] = ["Exception:"] + e.split("\n")
results['state'] = 'Autorestart pending'
results['stateprogress'] = 0
@@ -397,7 +397,7 @@ def engine_worker():
time.sleep(2)
with lock:
dt = datetime.datetime.utcnow().isoformat()
- results['summary'] = [f"DPD engine auto-restarted at {dt} UTC", f"After exception {e}"]
+ results['summary'] = ["DPD engine auto-restarted at {} UTC".format(dt), "After exception {}".format(e)]
results['state'] = 'Idle'
results['stateprogress'] = 0
@@ -427,7 +427,7 @@ try:
cmd_socket.send_success_response(addr, msg_id, None)
elif method == 'restore_dump':
logging.info('Received RPC request : restore_dump({})'.format(params['dump_id']))
- command_queue.put(f"restore_dump-{params['dump_id']}")
+ command_queue.put("restore_dump-{}".format(params['dump_id']))
cmd_socket.send_success_response(addr, msg_id, None)
elif method == 'get_results':
with lock:
diff --git a/python/gui-dpdce.ini b/python/gui-dpdce.ini
index 4385c80..496adf5 100644
--- a/python/gui-dpdce.ini
+++ b/python/gui-dpdce.ini
@@ -31,3 +31,4 @@ port=8099
logs_directory=gui/logs
static_directory=gui/static
+templates_directory=gui/templates
diff --git a/python/gui.py b/python/gui.py
index a9328ee..810ff40 100755
--- a/python/gui.py
+++ b/python/gui.py
@@ -30,15 +30,14 @@ from jinja2 import Environment, FileSystemLoader
from gui.api import API
from lib import zmqrc
-env = Environment(loader=FileSystemLoader('gui/templates'))
-
base_js = ["js/odr.js"]
base_css = ["css/odr.css"]
class Root:
- def __init__(self, dpd_port):
+ def __init__(self, dpd_port, end):
self.mod_rc = zmqrc.ModRemoteControl("localhost")
self.api = API(self.mod_rc, dpd_port)
+ self.env = env
@cherrypy.expose
def index(self):
@@ -46,30 +45,30 @@ class Root:
@cherrypy.expose
def about(self):
- tmpl = env.get_template("about.html")
+ tmpl = self.env.get_template("about.html")
return tmpl.render(tab='about', js=base_js, is_login=False)
@cherrypy.expose
def home(self):
- tmpl = env.get_template("home.html")
+ tmpl = self.env.get_template("home.html")
js = base_js + ["js/odr-home.js"]
return tmpl.render(tab='home', js=js, css=base_css, is_login=False)
@cherrypy.expose
def rcvalues(self):
- tmpl = env.get_template("rcvalues.html")
+ tmpl = self.env.get_template("rcvalues.html")
js = base_js + ["js/odr-rcvalues.js"]
return tmpl.render(tab='rcvalues', js=js, is_login=False)
@cherrypy.expose
def modulator(self):
- tmpl = env.get_template("modulator.html")
+ tmpl = self.env.get_template("modulator.html")
js = base_js + ["js/odr-modulator.js"]
return tmpl.render(tab='modulator', js=js, is_login=False)
@cherrypy.expose
def predistortion(self):
- tmpl = env.get_template("predistortion.html")
+ tmpl = self.env.get_template("predistortion.html")
js = base_js + ["js/odr-predistortion.js"]
return tmpl.render(tab='predistortion', js=js, is_login=False)
@@ -84,6 +83,7 @@ if __name__ == '__main__':
allconfig.read(cli_args.config)
config = allconfig['gui']
dpd_port = allconfig['dpdce'].getint('control_port')
+ plot_relative_dir = allconfig['dpdce']['plot_directory']
daemon = False
if daemon:
@@ -106,13 +106,15 @@ if __name__ == '__main__':
})
staticdir = os.path.realpath(config['static_directory'])
+ templatedir = os.path.realpath(config['templates_directory'])
+ env = Environment(loader=FileSystemLoader(templatedir))
cherrypy.tree.mount(
- Root(dpd_port), config={
+ Root(dpd_port, env), config={
'/': { },
'/dpd': {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': os.path.join(staticdir, u"dpd/")
+ 'tools.staticdir.dir': os.path.realpath(plot_relative_dir)
},
'/css': {
'tools.staticdir.on': True,
diff --git a/python/gui/templates/modulator.html b/python/gui/templates/modulator.html
index 016344a..c2b4a24 100644
--- a/python/gui/templates/modulator.html
+++ b/python/gui/templates/modulator.html
@@ -26,7 +26,7 @@
</div>
</div>
<div class="panel-body">
- <h3>CFR</h3>
+ <h3>Crest Factor Reduction</h3>
<div class="form-group">
<div class="checkbox">
<label><input type="checkbox" value="1" id="cfrenable">Enable</label>