Added logger to GUI.

This commit is contained in:
2025-10-15 18:11:10 +02:00
parent cb7bc2f025
commit 7229d4cd33
10 changed files with 269 additions and 94 deletions

View File

@@ -9,6 +9,7 @@ use bioz_host_rs::communication::communicate_with_hardware;
use tokio::sync::mpsc::{self};
use bioz_host_rs::signals::StartStopSignal;
use bioz_host_rs::logging::log_data;
#[tokio::main]
async fn main() {
@@ -26,9 +27,10 @@ async fn main() {
let run_impedancemeter_tx_clone = run_impedancemeter_tx.clone();
// Logging
let (log_tx, mut log_rx) = mpsc::channel::<LoggingSignal>(10);
let (log_tx, log_rx) = mpsc::channel::<LoggingSignal>(10);
let log_tx_clone = log_tx.clone();
let app = App::new(run_impedancemeter_tx);
let app = App::new(run_impedancemeter_tx, log_tx);
let magnitude_clone = app.magnitude.clone();
let phase_clone = app.phase.clone();
let magnitude_series_clone = app.magnitude_series.clone();
@@ -43,27 +45,8 @@ async fn main() {
let gui_logging_enabled = app.gui_logging_enabled.clone();
// Log thread
tokio::spawn(async move {
loop {
match log_rx.recv().await {
Some(signal) => {
match signal {
LoggingSignal::SingleImpedance(magnitude, phase) => {
info!("Single Impedance - Magnitude: {:.3}, Phase: {:.3}", magnitude, phase);
}
LoggingSignal::MultiImpedance(magnitudes, phases) => {
info!("Multi Impedance - Magnitudes: {:?}, Phases: {:?}", magnitudes, phases);
}
}
}
None => {
// Channel closed
break;
}
}
}
});
// Log thread
tokio::spawn(async move { log_data(log_rx).await });
// Execute the runtime in its own thread.
std::thread::spawn(move || {
@@ -80,7 +63,7 @@ async fn main() {
periods_per_dft,
periods_per_dft_multi,
gui_logging_enabled,
log_tx,
log_tx_clone,
));
});