import iio
import json
import os
+import pandas
+import plotly.express as px
import shutil
import shlex
import signal
else:
return "Method not allowed", 405
+ # end point for fetching plotly output
+ @cherrypy.expose
+ def plotly(self):
+ global test_path
+ if cherrypy.request.method == 'GET':
+ plotly_path = test_path + "/plotly.html"
+ with open(plotly_path, 'r') as plot_file:
+ return plot_file.read()
+
# end point for arming the system
@cherrypy.expose
@cherrypy.tools.json_in()
@cherrypy.expose
def starttest(self):
global test_path
+ global test_time
if cherrypy.request.method == 'GET':
# create a directory name for this test
t = time.localtime()
global loggertask
global pyrotask
global test_path
+ global test_time
cherrypy.log("setting shutdown_flag for each thread")
# stop logging data by telling the thread to exit
status = "idle"
# post-process the data we just collected
+ # first, let's create a CSV file from the raw data
rawfile_path = test_path + "/rawdata"
csvfile_path = test_path + "/data.csv"
with open(rawfile_path, 'rb') as rawfile:
value7 = '%.3f'%((float(rawdata[i+15] * 256 + rawdata[i+14]) + float(OFFSET)) * float(SCALE) / 1000)
csvwriter.writerow([value0, value1, value2, value3, value4, value5, value6, value7])
+ # next, let's create a plotly html object from the csv file
+ df = pandas.read_csv(csvfile_path)
+ plot_title = "Results of test " + test_time
+ fig = px.line(df, title=plot_title)
+ html_data = fig.to_html(full_html=False)
+ plotfile_path = test_path + "/plotly.html"
+ with open(plotfile_path, 'w') as plotfile:
+ plotfile.write(html_data)
+
if __name__ == '__main__':
# initialize hardware
set_line_values(