diff --git a/where_fi/application.py b/where_fi/application.py index b8156de..2144e3e 100644 --- a/where_fi/application.py +++ b/where_fi/application.py @@ -7,6 +7,7 @@ from typing import Any, Callable, NamedTuple import numpy.typing as npt from where_fi.collection import CSIMatrix, ingest +from where_fi.collection.csi_frame import CSI from where_fi.collection.protocols import CSIProducer, MergedCSI from where_fi.config import config from where_fi.processing.preprocess import Preprocessor @@ -125,12 +126,13 @@ class CSIApplication: return decorator def on_pre_merge( - self, - ) -> Callable[[Callable[[dict[ingest.Host, ingest.CSI]], None]], None]: - def decorator(func: Callable[[dict[ingest.Host, ingest.CSI]], None]) -> None: - self.pre_merge_callback = func - - return decorator + self, func: Callable[[dict[ingest.Host, CSI]], None] + ) -> Callable[[dict[ingest.Host, CSI]], None]: + """ + Decorator to register a callback for the samples before merging. + """ + self.pre_merge_callback = func + return func def on_process( self, func: Callable[[CSIMatrix], None] diff --git a/where_fi/utils/antenna_order.py b/where_fi/utils/antenna_order.py index 254b88a..25a4c9b 100644 --- a/where_fi/utils/antenna_order.py +++ b/where_fi/utils/antenna_order.py @@ -2,6 +2,8 @@ import logging from collections import deque from typing import Any, Collection +from where_fi.application import CSIApplication + from ..collection import ingest from ..config import config @@ -32,6 +34,10 @@ def average(data: Collection[Any]) -> float: return sum(data) / len(data) +app = CSIApplication(ingest.RealtimeCSIProducer()) + + +@app.on_pre_merge def callback(antenna_data: dict[ingest.Host, ingest.CSI]) -> None: global prev_unplugged global antenna_average @@ -73,4 +79,4 @@ def callback(antenna_data: dict[ingest.Host, ingest.CSI]) -> None: def main() -> None: - ingest.start_processing(pre_merge_callback=callback) + app.start()