import logging import multiprocessing as mp import numpy as np import numpy.typing as npt import typer from .. import visualise from ..config import config from ..processing.aoa import AoA from ..processing.preprocess import Preprocessor from . import file, globals app = typer.Typer(callback=globals.main) logger = logging.getLogger(__name__) @app.command() def antennas() -> None: """Utility to help determine the order in which antennas are plugged in Once the script is running, unplug and replug antennas from left to right, to get the correct order. Every time an antenna is unplugged and replugged, the script will print the antenna identifier. When you are done, press Ctrl+C to stop the script and get the final order. """ from ..utils import antenna_order if not globals.is_live: raise ValueError("This command only works with live data") antenna_order.main() @app.command() def heatmap() -> None: preprocessor = Preprocessor() aoa = AoA() manager = mp.Manager() webapp_queue: "mp.Queue[AoA]" = manager.Queue(config.sample_rate) # Start webapp in background process webapp = mp.Process(target=visualise.start, args=(webapp_queue,)) webapp.start() def callback(antenna_data: npt.NDArray[np.complex128]) -> None: logger.info(f"Got final CSI data with shape {antenna_data.shape}") processed = preprocessor.preprocess(antenna_data) # visualise.add_data(all_data, processed) aoa.update(processed) if not webapp_queue.full(): webapp_queue.put(aoa) globals.csi_producer(csi_callback=callback) logger.info("Finished processing CSI data") app.add_typer(file.app, name="file", help="Commands for working with CSI files")