summaryrefslogtreecommitdiffstats
path: root/gui/api
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-11-28 11:11:22 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-11-28 11:11:22 +0100
commitcfa9461f269e616d6d54658d583b37d215f35a7b (patch)
treebc56977f6479c297521dff9564ba6ecbffe00a52 /gui/api
parentee435c029eac59e0399dc3ae765cc74d66b9442e (diff)
downloaddabmod-cfa9461f269e616d6d54658d583b37d215f35a7b.tar.gz
dabmod-cfa9461f269e616d6d54658d583b37d215f35a7b.tar.bz2
dabmod-cfa9461f269e616d6d54658d583b37d215f35a7b.zip
GUI: Add part of calibration routine
Diffstat (limited to 'gui/api')
-rwxr-xr-xgui/api/__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/gui/api/__init__.py b/gui/api/__init__.py
index a535eb3..56062c3 100755
--- a/gui/api/__init__.py
+++ b/gui/api/__init__.py
@@ -47,15 +47,20 @@ class API(plugins.SimplePlugin):
plugins.SimplePlugin.__init__(self, bus)
self.mod_rc = mod_rc
self.dpd_state = None
+ self.calibration_result = None
def start(self):
self.bus.subscribe("dpd-state", self.dpd_state)
+ self.bus.subscribe("dpd-calibration-result", self.calibration_result)
def stop(self):
self.bus.unsubscribe("dpd-state", self.dpd_state)
+ self.bus.unsubscribe("dpd-calibration-result", self.calibration_result)
+
+ def calibration_result(self, new_result):
+ self.calibration_result = new_result
def dpd_state(self, new_state):
- print("API got new dpd-state {}".format(new_state))
self.dpd_state = new_state
@cherrypy.expose
@@ -102,3 +107,15 @@ class API(plugins.SimplePlugin):
else:
return send_error("DPD state unknown")
+ @cherrypy.expose
+ @cherrypy.tools.json_out()
+ def dpd_calibrate(self, **kwargs):
+ if cherrypy.request.method == 'POST':
+ cherrypy.engine.publish('dpd-calibrate', None)
+ return send_ok()
+ else:
+ if self.dpd_state is not None:
+ return send_ok(self.calibration_result)
+ else:
+ return send_error("DPD calibration result unknown")
+