From: Bdale Garbee Date: Mon, 26 May 2025 18:07:47 +0000 (-0600) Subject: add endpoint and button to arm system, more to do to make it a toggle X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=3e52f613640bf659567b49c0af3bafd01a21c66c;p=fw%2Fquantimotor add endpoint and button to arm system, more to do to make it a toggle --- diff --git a/ui/app.py b/ui/app.py index dbda572..b3588d6 100755 --- a/ui/app.py +++ b/ui/app.py @@ -25,6 +25,9 @@ thrust = 0 pyro = 0 battery = 0 +# global to keep track of whether user wants system armed +armreq = "disarm" + ctx = iio.LocalContext() ctrl = ctx.find_device('ads8688') # configuration for each channel on ADS8688 @@ -70,9 +73,13 @@ def sense_armed(): ) as request: value = request.get_value(12) if value == Value.ACTIVE: - return 'armed' + if armreq == "arm": + return 'armed' + else: + return 'remote' else: - return 'safe' + return armreq + #return 'safe' path = os.path.abspath(os.path.dirname(__file__)) config = { @@ -110,6 +117,19 @@ class App: else: return "Method not allowed", 405 + # end point for arming the system + @cherrypy.expose + @cherrypy.tools.json_in() + def armsystem(self): + global armreq + if cherrypy.request.method == 'POST': + jsondata = cherrypy.request.json + cherrypy.log(jsondata["request"].strip()) + armreq = jsondata["request"] + return "state requested: " + armreq + else: + return "Method not allowed", 405 + # end point for starting a test @cherrypy.expose def starttest(self): diff --git a/ui/index.html b/ui/index.html index 58104a5..b968e4a 100644 --- a/ui/index.html +++ b/ui/index.html @@ -31,6 +31,20 @@