From cfa9461f269e616d6d54658d583b37d215f35a7b Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 28 Nov 2018 11:11:22 +0100 Subject: GUI: Add part of calibration routine --- gui/api/__init__.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'gui/api') 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") + -- cgit v1.2.3