]> git.gag.com Git - fw/quantimotor/commitdiff
add button and endpoint for starting a test
authorBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 16:45:11 +0000 (10:45 -0600)
committerBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 16:45:11 +0000 (10:45 -0600)
ui/app.py
ui/index.html

index 6b0cccfa3cec9f5a5289b3f912de369b77a66140..78c8ff03b299d3a3c7e4e7ae776ea5829e77adcc 100755 (executable)
--- a/ui/app.py
+++ b/ui/app.py
@@ -11,6 +11,7 @@ import gpiod
 from gpiod.line import Direction, Value
 import iio
 import json
+import shutil
 import signal
 import sys
 import time
@@ -109,6 +110,24 @@ class App:
     else:
       return "Method not allowed", 405
 
+  # end point for starting a test
+  @cherrypy.expose
+  def starttest(self):
+    if cherrypy.request.method == 'GET':
+      # create a directory name for this test
+      t = time.localtime()
+      test_time = time.strftime("%Y:%m:%d_%H:%M:%S", t)
+      test_path = DATAPATH + test_time
+      # create a directory for this test
+      if not os.path.isdir(test_path):
+        os.makedirs(test_path)
+      # copy metadata into test directory
+      metadata_path = DATAPATH + "metadata.json"
+      shutil.copy(metadata_path, test_path)
+      return "Test " + test_path + " started"
+    else:
+      return "Method not allowed", 405
+
   # end point for handling AJAX requests for current status
   @cherrypy.expose
   @cherrypy.tools.json_out()
index 9efde3cf77b4d7e83857a180f8330ea8ec99c430..58104a50a1a3f612154786382fb3d88b08cfd75b 100644 (file)
       setInterval(updateContent, 1000);
 
     </script>
+    <script>
+      // start current test by just hitting an endpoint
+      function startTest() {
+        const fetchOptions = {
+          method: "GET",
+        };
+       const response = fetch("/starttest", fetchOptions);
+      }
+    </script>
   </head>
   <body>
     <!-- HEADER -->
     <section class="test">
       <div class="w3-container w3-center">
         <button onclick="document.getElementById('start-metadata').style.display='block'" 
-               class="w3-button w3-round-large w3-black w3-hover-orange w3-large w3-opacity">Prepare to Test</button>
+          class="w3-button w3-round-large w3-black w3-hover-orange w3-large w3-opacity">
+          Configure Test</button>
+      </div>
+      <div class="w3-container w3-center">
+        <button onclick="armSystem()"
+          class="w3-button w3-round-large w3-black w3-hover-red w3-large w3-opacity w3-left">
+          Arm</button>
+        <button onclick="startTest()"
+          class="w3-button w3-round-large w3-black w3-hover-red w3-large w3-opacity w3-right">
+          Start Test</button>
+        </a>
       </div>
     </section>