Changed SweepPoints names, included KTO frequency set.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-06-04 08:23:50 +02:00
parent fcdcf26651
commit b875e988a4
3 changed files with 31 additions and 16 deletions

View File

@@ -36,9 +36,10 @@ const DFTNUM_VARIANTS: [IcdDftNum; 13] = [
IcdDftNum::Num8192, IcdDftNum::Num16384, IcdDftNum::Num8192, IcdDftNum::Num16384,
]; ];
const SWEEP_POINTS_VARIANTS: [SweepPoints; 2] = [ const SWEEP_POINTS_VARIANTS: [SweepPoints; 3] = [
SweepPoints::Eight, SweepPoints::Partial,
SweepPoints::Eighteen, SweepPoints::Full,
SweepPoints::KTO,
]; ];
#[derive(Clone, Copy,Debug, PartialEq, Eq)] #[derive(Clone, Copy,Debug, PartialEq, Eq)]
@@ -373,7 +374,7 @@ impl CustomTabs {
ComboBox::from_id_salt("MeasurementPoints") ComboBox::from_id_salt("MeasurementPoints")
.width(75.0) .width(75.0)
.show_index(ui, &mut index, SWEEP_POINTS_VARIANTS.len(), |i| { .show_index(ui, &mut index, SWEEP_POINTS_VARIANTS.len(), |i| {
format!("{:?}", SWEEP_POINTS_VARIANTS[i].len()) format!("{:?}", SWEEP_POINTS_VARIANTS[i])
}); });
let new_value = SWEEP_POINTS_VARIANTS[index]; let new_value = SWEEP_POINTS_VARIANTS[index];
if measurement_points != new_value { if measurement_points != new_value {

View File

@@ -150,30 +150,44 @@ pub async fn communicate_with_hardware(
match val.points { match val.points {
SweepPoints::Eight => { SweepPoints::Partial => {
let magnitudes: Vec<f32> = val.magnitudes_8.into_iter().collect(); let magnitudes: Vec<f32> = val.magnitudes_8.into_iter().collect();
let phases: Vec<f32> = val.phases_8.into_iter().collect(); let phases: Vec<f32> = val.phases_8.into_iter().collect();
{ {
let mut bode_plot = data.lock().unwrap(); let mut bode_plot = data.lock().unwrap();
bode_plot.update_magnitudes(SweepPoints::Eight, magnitudes.clone()); bode_plot.update_magnitudes(SweepPoints::Partial, magnitudes.clone());
bode_plot.update_phases(SweepPoints::Eight, phases.clone()); bode_plot.update_phases(SweepPoints::Partial, phases.clone());
} }
if *logging_state_rx_clone.borrow() == LoggingState::Logging { if *logging_state_rx_clone.borrow() == LoggingState::Logging {
if let Err(e) = logging_control_tx_clone.try_send(LoggingSignal::SweepImpedance(SystemTime::now(), SweepPoints::Eight.values().to_vec(), magnitudes.clone(), phases.clone())) { if let Err(e) = logging_control_tx_clone.try_send(LoggingSignal::SweepImpedance(SystemTime::now(), SweepPoints::Partial.values().to_vec(), magnitudes.clone(), phases.clone())) {
error!("Failed to send logging signal: {:?}", e); error!("Failed to send logging signal: {:?}", e);
} }
} }
}, },
SweepPoints::Eighteen => { SweepPoints::Full => {
let magnitudes: Vec<f32> = val.magnitudes_18.into_iter().collect(); let magnitudes: Vec<f32> = val.magnitudes_18.into_iter().collect();
let phases: Vec<f32> = val.phases_18.into_iter().collect(); let phases: Vec<f32> = val.phases_18.into_iter().collect();
{ {
let mut bode_plot = data.lock().unwrap(); let mut bode_plot = data.lock().unwrap();
bode_plot.update_magnitudes(SweepPoints::Eighteen, magnitudes.clone()); bode_plot.update_magnitudes(SweepPoints::Full, magnitudes.clone());
bode_plot.update_phases(SweepPoints::Eighteen, phases.clone()); bode_plot.update_phases(SweepPoints::Full, phases.clone());
} }
if *logging_state_rx_clone.borrow() == LoggingState::Logging { if *logging_state_rx_clone.borrow() == LoggingState::Logging {
if let Err(e) = logging_control_tx_clone.try_send(LoggingSignal::SweepImpedance(SystemTime::now(), SweepPoints::Eighteen.values().to_vec(), magnitudes.clone(), phases.clone())) { if let Err(e) = logging_control_tx_clone.try_send(LoggingSignal::SweepImpedance(SystemTime::now(), SweepPoints::Full.values().to_vec(), magnitudes.clone(), phases.clone())) {
error!("Failed to send logging signal: {:?}", e);
}
}
},
SweepPoints::KTO => {
let magnitudes: Vec<f32> = val.magnitudes_18.into_iter().collect();
let phases: Vec<f32> = val.phases_18.into_iter().collect();
{
let mut bode_plot = data.lock().unwrap();
bode_plot.update_magnitudes(SweepPoints::KTO, magnitudes.clone());
bode_plot.update_phases(SweepPoints::KTO, phases.clone());
}
if *logging_state_rx_clone.borrow() == LoggingState::Logging {
if let Err(e) = logging_control_tx_clone.try_send(LoggingSignal::SweepImpedance(SystemTime::now(), SweepPoints::KTO.values().to_vec(), magnitudes.clone(), phases.clone())) {
error!("Failed to send logging signal: {:?}", e); error!("Failed to send logging signal: {:?}", e);
} }
} }
@@ -226,12 +240,12 @@ pub async fn communicate_with_hardware(
settings.lock().unwrap().mode = Some(StartStopSignal::StartSweep(lead_mode, electrode_config, num_points)); settings.lock().unwrap().mode = Some(StartStopSignal::StartSweep(lead_mode, electrode_config, num_points));
hardware_state.running = true; hardware_state.running = true;
match num_points { match num_points {
SweepPoints::Eight => { SweepPoints::Partial => {
hardware_state.periods_per_dft_sweep = (num_points.values().iter().copied().collect(), Some(periods.periods_per_dft_8.into_iter().collect())); hardware_state.periods_per_dft_sweep = (num_points.values().iter().copied().collect(), Some(periods.periods_per_dft_8.into_iter().collect()));
hardware_state_tx.send(hardware_state.clone()).unwrap(); hardware_state_tx.send(hardware_state.clone()).unwrap();
}, },
SweepPoints::Eighteen => { SweepPoints::Full | SweepPoints::KTO => {
hardware_state.periods_per_dft_sweep = (num_points.values().iter().copied().collect(), Some(periods.periods_per_dft_18.into_iter().collect())); hardware_state.periods_per_dft_sweep = (num_points.values().iter().copied().collect(), Some(periods.periods_per_dft_18.into_iter().collect()));
hardware_state_tx.send(hardware_state.clone()).unwrap(); hardware_state_tx.send(hardware_state.clone()).unwrap();
}, },

View File

@@ -119,7 +119,7 @@ impl Default for AppState {
lead_mode: BioImpedanceLeadMode::FourLead, lead_mode: BioImpedanceLeadMode::FourLead,
dft_num: IcdDftNum::Num2048, dft_num: IcdDftNum::Num2048,
electrode_settings: ElectrodeSettings::new(), electrode_settings: ElectrodeSettings::new(),
sweep_points: SweepPoints::Eighteen, sweep_points: SweepPoints::Full,
tab_active: TabActive::Single, tab_active: TabActive::Single,
tcp_connected: false, tcp_connected: false,
} }
@@ -141,7 +141,7 @@ impl Default for HardwareState {
hardware_connected: HardwareConnected::None, hardware_connected: HardwareConnected::None,
running: false, running: false,
periods_per_dft: None, periods_per_dft: None,
periods_per_dft_sweep: (SweepPoints::Eighteen.values().to_vec(), None), periods_per_dft_sweep: (SweepPoints::Full.values().to_vec(), None),
} }
} }
} }