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,
];
const SWEEP_POINTS_VARIANTS: [SweepPoints; 2] = [
SweepPoints::Eight,
SweepPoints::Eighteen,
const SWEEP_POINTS_VARIANTS: [SweepPoints; 3] = [
SweepPoints::Partial,
SweepPoints::Full,
SweepPoints::KTO,
];
#[derive(Clone, Copy,Debug, PartialEq, Eq)]
@@ -373,7 +374,7 @@ impl CustomTabs {
ComboBox::from_id_salt("MeasurementPoints")
.width(75.0)
.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];
if measurement_points != new_value {

View File

@@ -150,30 +150,44 @@ pub async fn communicate_with_hardware(
match val.points {
SweepPoints::Eight => {
SweepPoints::Partial => {
let magnitudes: Vec<f32> = val.magnitudes_8.into_iter().collect();
let phases: Vec<f32> = val.phases_8.into_iter().collect();
{
let mut bode_plot = data.lock().unwrap();
bode_plot.update_magnitudes(SweepPoints::Eight, magnitudes.clone());
bode_plot.update_phases(SweepPoints::Eight, phases.clone());
bode_plot.update_magnitudes(SweepPoints::Partial, magnitudes.clone());
bode_plot.update_phases(SweepPoints::Partial, 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::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);
}
}
},
SweepPoints::Eighteen => {
SweepPoints::Full => {
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::Eighteen, magnitudes.clone());
bode_plot.update_phases(SweepPoints::Eighteen, phases.clone());
bode_plot.update_magnitudes(SweepPoints::Full, magnitudes.clone());
bode_plot.update_phases(SweepPoints::Full, 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::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);
}
}
@@ -226,12 +240,12 @@ pub async fn communicate_with_hardware(
settings.lock().unwrap().mode = Some(StartStopSignal::StartSweep(lead_mode, electrode_config, num_points));
hardware_state.running = true;
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_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_tx.send(hardware_state.clone()).unwrap();
},

View File

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