From ed7aaf787b33cc2caaa844a2c887263007e82537 Mon Sep 17 00:00:00 2001 From: Christos Falas Date: Sun, 29 Dec 2024 12:57:29 +0000 Subject: [PATCH] customise max tof for graph --- src/visualise/__init__.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/visualise/__init__.py b/src/visualise/__init__.py index 250b229..9e97267 100644 --- a/src/visualise/__init__.py +++ b/src/visualise/__init__.py @@ -1,4 +1,4 @@ -from flask import Flask, render_template, Response +from flask import Flask, render_template, Response, request from flask_sock import Sock import numpy as np import numpy.typing as npt @@ -88,10 +88,10 @@ def add_data( del subscriber_settings[subscriber] -def make_heatmap(): +def make_heatmap(max_tof: float): fig = plt.figure() ax = fig.add_axes([0, 0, 1, 1], polar=True) - r = np.linspace(0, 1e-7, 100) # Radius values + r = np.linspace(0, max_tof, 100) # Radius values theta = np.linspace(0, np.pi, 50) # Angle values R, Theta = np.meshgrid(r, theta) # Create a 2D grid of r and theta @@ -107,18 +107,25 @@ def make_heatmap(): return buf -def gather_aoa(): +def gather_aoa(max_tof: float): while True: # time.sleep(0.05) logger.info("Got AoA heatmap") - buf = make_heatmap() + buf = make_heatmap(max_tof) yield (b"--frame\r\nContent-Type: image/jpeg\r\n\r\n" + buf.read() + b"\r\n") buf.close() @app.route("/aoa_tof") def aoa_tof(): - return Response(gather_aoa(), mimetype="multipart/x-mixed-replace; boundary=frame") + max_tof_str = request.args.get("max_tof") + try: + max_tof = float(max_tof_str) + except Exception as e: + max_tof = 5e-8 + return Response( + gather_aoa(max_tof), mimetype="multipart/x-mixed-replace; boundary=frame" + ) def start():