Change multi to sweep.

This commit is contained in:
2025-11-06 12:13:32 +01:00
parent ce23d40b38
commit b7bce96407
6 changed files with 47 additions and 46 deletions

View File

@@ -43,7 +43,7 @@ const MEASUREMENT_POINTS_VARIANTS: [MeasurementPointSet; 2] = [
#[derive(Clone, Copy,Debug, PartialEq, Eq)]
enum TabActive {
Single,
Multi,
Sweep,
Shortcuts,
}
@@ -66,7 +66,7 @@ pub struct App {
pub dft_num: Arc<Mutex<IcdDftNum>>,
pub measurement_points: Arc<Mutex<MeasurementPointSet>>,
pub periods_per_dft: Arc<Mutex<Option<f32>>>,
pub periods_per_dft_multi: Arc<Mutex<(Vec<u32>, Option<Vec<f32>>)>>,
pub periods_per_dft_sweep: Arc<Mutex<(Vec<u32>, Option<Vec<f32>>)>>,
pub gui_logging_enabled: Arc<AtomicBool>,
log_filename: String,
}
@@ -83,7 +83,7 @@ struct TabViewer {
dft_num: Arc<Mutex<IcdDftNum>>,
measurement_points: Arc<Mutex<MeasurementPointSet>>,
periods_per_dft: Arc<Mutex<Option<f32>>>,
periods_per_dft_multi: Arc<Mutex<(Vec<u32>, Option<Vec<f32>>)>>,
periods_per_dft_sweep: Arc<Mutex<(Vec<u32>, Option<Vec<f32>>)>>,
show_settings: bool,
show_settings_toggle: Option<bool>,
}
@@ -216,7 +216,8 @@ impl TabViewer {
});
}
fn multi_tab(&mut self, ui: &mut egui::Ui) {
fn sweep_tab(&mut self, ui: &mut egui::Ui) {
egui::Frame::default().inner_margin(5).show(ui, |ui| {
let settings = CollapsingHeader::new("Settings")
.open(self.show_settings_toggle)
@@ -269,7 +270,7 @@ impl TabViewer {
});
});
ui.add_enabled_ui(*on, |ui| {
let (freq, periods_per_dft_vec) = self.periods_per_dft_multi.lock().unwrap().clone();
let (freq, periods_per_dft_vec) = self.periods_per_dft_sweep.lock().unwrap().clone();
fn format_frequency(freq: u32) -> String {
if freq >= 1_000 {
@@ -474,7 +475,7 @@ impl egui_dock::TabViewer for TabViewer {
fn ui(&mut self, ui: &mut egui::Ui, tab: &mut Self::Tab) {
match tab.as_str() {
"Single" => self.single_tab(ui),
"Multi" => self.multi_tab(ui),
"Sweep" => self.sweep_tab(ui),
"Shortcuts" => self.shortcuts(ui),
_ => {
let _ = ui.label("Unknown tab");
@@ -496,7 +497,7 @@ impl App {
let dft_num = Arc::new(Mutex::new(IcdDftNum::Num2048));
let measurement_points = Arc::new(Mutex::new(MeasurementPointSet::Eighteen));
let periods_per_dft = Arc::new(Mutex::new(None));
let periods_per_dft_multi = Arc::new(Mutex::new((MeasurementPointSet::Eighteen.values().to_vec(), None)));
let periods_per_dft_sweep = Arc::new(Mutex::new((MeasurementPointSet::Eighteen.values().to_vec(), None)));
let on = Arc::new(Mutex::new(true));
let tab_active = TabActive::Single;
@@ -512,7 +513,7 @@ impl App {
dft_num: dft_num.clone(),
measurement_points: measurement_points.clone(),
periods_per_dft: periods_per_dft.clone(),
periods_per_dft_multi: periods_per_dft_multi.clone(),
periods_per_dft_sweep: periods_per_dft_sweep.clone(),
on: on.clone(),
show_settings: false,
show_settings_toggle: None,
@@ -520,7 +521,7 @@ impl App {
// Step 3: Construct App
let app = App {
tree: DockState::new(vec!["Single".to_string(), "Multi".to_string(), "Shortcuts".to_string()]),
tree: DockState::new(vec!["Single".to_string(), "Sweep".to_string(), "Shortcuts".to_string()]),
tab_viewer,
run_impedancemeter_tx,
log_tx,
@@ -538,7 +539,7 @@ impl App {
dft_num,
measurement_points,
periods_per_dft,
periods_per_dft_multi,
periods_per_dft_sweep,
gui_logging_enabled: Arc::new(AtomicBool::new(false)),
log_filename: format!("log_{}.csv", Local::now().format("%Y%m%d"))
};
@@ -572,8 +573,8 @@ impl App {
error!("Failed to send start command: {:?}", e);
}
},
(TabActive::Multi, true) => {
if let Err(e) = self.run_impedancemeter_tx.try_send(StartStopSignal::StartMulti(*self.lead_mode.lock().unwrap(), *self.measurement_points.lock().unwrap())) {
(TabActive::Sweep, true) => {
if let Err(e) = self.run_impedancemeter_tx.try_send(StartStopSignal::StartSweep(*self.lead_mode.lock().unwrap(), *self.measurement_points.lock().unwrap())) {
error!("Failed to send start command: {:?}", e);
}
},
@@ -684,12 +685,12 @@ impl eframe::App for App {
info!("Switched to Single tab");
}
}
"Multi" => {
if self.tab_active != TabActive::Multi {
self.tab_active = TabActive::Multi;
"Sweep" => {
if self.tab_active != TabActive::Sweep {
self.tab_active = TabActive::Sweep;
*self.on.lock().unwrap() = false;
self.update_start_stop();
info!("Switched to Multi tab");
info!("Switched to Sweep tab");
}
}
"Shortcuts" => {