mirror of
https://github.com/hubaldv/bioz-host-rs.git
synced 2025-12-06 05:11:17 +00:00
Added 4-lead multi calibration.
This commit is contained in:
33
src/app.rs
33
src/app.rs
@@ -222,6 +222,35 @@ impl TabViewer {
|
|||||||
.open(self.show_settings_toggle)
|
.open(self.show_settings_toggle)
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
if let Ok(on) = self.on.lock() {
|
if let Ok(on) = self.on.lock() {
|
||||||
|
ui.add_enabled_ui(!*on, |ui| {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Lead Mode:");
|
||||||
|
|
||||||
|
let mut lead_mode = self.lead_mode.lock().unwrap();
|
||||||
|
|
||||||
|
// Map current lead mode to index
|
||||||
|
let mut index = LEAD_MODES
|
||||||
|
.iter()
|
||||||
|
.position(|&m| m == *lead_mode)
|
||||||
|
.unwrap_or(0);
|
||||||
|
|
||||||
|
ComboBox::from_id_salt("LeadMode")
|
||||||
|
.width(60.0)
|
||||||
|
.show_index(ui, &mut index, LEAD_MODES.len(), |i| {
|
||||||
|
match LEAD_MODES[i] {
|
||||||
|
BioImpedanceLeadMode::TwoLead => "2-Lead",
|
||||||
|
BioImpedanceLeadMode::FourLead => "4-Lead",
|
||||||
|
}
|
||||||
|
.to_string()
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update lead mode if changed
|
||||||
|
if *lead_mode != LEAD_MODES[index] {
|
||||||
|
*lead_mode = LEAD_MODES[index];
|
||||||
|
info!("Lead Mode setting changed!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
ui.add_enabled_ui(!*on, |ui| {
|
ui.add_enabled_ui(!*on, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label("Measurement Points:");
|
ui.label("Measurement Points:");
|
||||||
@@ -463,7 +492,7 @@ impl App {
|
|||||||
let phase_series = Arc::new(Mutex::new(TimeSeriesPlot::new()));
|
let phase_series = Arc::new(Mutex::new(TimeSeriesPlot::new()));
|
||||||
let bode_plot = Arc::new(Mutex::new(BodePlot::new()));
|
let bode_plot = Arc::new(Mutex::new(BodePlot::new()));
|
||||||
let single_frequency = Arc::new(Mutex::new(50000));
|
let single_frequency = Arc::new(Mutex::new(50000));
|
||||||
let lead_mode = Arc::new(Mutex::new(BioImpedanceLeadMode::TwoLead));
|
let lead_mode = Arc::new(Mutex::new(BioImpedanceLeadMode::FourLead));
|
||||||
let dft_num = Arc::new(Mutex::new(IcdDftNum::Num2048));
|
let dft_num = Arc::new(Mutex::new(IcdDftNum::Num2048));
|
||||||
let measurement_points = Arc::new(Mutex::new(MeasurementPointSet::Eighteen));
|
let measurement_points = Arc::new(Mutex::new(MeasurementPointSet::Eighteen));
|
||||||
let periods_per_dft = Arc::new(Mutex::new(None));
|
let periods_per_dft = Arc::new(Mutex::new(None));
|
||||||
@@ -544,7 +573,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
(TabActive::Multi, true) => {
|
(TabActive::Multi, true) => {
|
||||||
if let Err(e) = self.run_impedancemeter_tx.try_send(StartStopSignal::StartMulti(*self.measurement_points.lock().unwrap())) {
|
if let Err(e) = self.run_impedancemeter_tx.try_send(StartStopSignal::StartMulti(*self.lead_mode.lock().unwrap(), *self.measurement_points.lock().unwrap())) {
|
||||||
error!("Failed to send start command: {:?}", e);
|
error!("Failed to send start command: {:?}", e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -76,10 +76,11 @@ impl WorkbookClient {
|
|||||||
|
|
||||||
pub async fn start_impedancemeter_multi(
|
pub async fn start_impedancemeter_multi(
|
||||||
&self,
|
&self,
|
||||||
|
lead_mode: BioImpedanceLeadMode,
|
||||||
points: MeasurementPointSet,
|
points: MeasurementPointSet,
|
||||||
) -> Result<MultiImpedanceInitResult, WorkbookError<Infallible>> {
|
) -> Result<MultiImpedanceInitResult, WorkbookError<Infallible>> {
|
||||||
let response = self.client
|
let response = self.client
|
||||||
.send_resp::<StartMultiImpedanceEndpoint>(&MultiImpedanceStartRequest { points })
|
.send_resp::<StartMultiImpedanceEndpoint>(&MultiImpedanceStartRequest { lead_mode, points })
|
||||||
.await?;
|
.await?;
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,10 +194,10 @@ pub async fn communicate_with_hardware(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
StartStopSignal::StartMulti(num_points) => {
|
StartStopSignal::StartMulti(lead_mode, num_points) => {
|
||||||
match workbook_client.start_impedancemeter_multi(num_points).await {
|
match workbook_client.start_impedancemeter_multi(lead_mode, num_points).await {
|
||||||
Ok(Ok(periods)) => {
|
Ok(Ok(periods)) => {
|
||||||
settings.lock().unwrap().frequency = Some(StartStopSignal::StartMulti(num_points));
|
settings.lock().unwrap().frequency = Some(StartStopSignal::StartMulti(lead_mode, num_points));
|
||||||
info!("Multi-point Impedancemeter started.");
|
info!("Multi-point Impedancemeter started.");
|
||||||
match num_points {
|
match num_points {
|
||||||
MeasurementPointSet::Eight => {
|
MeasurementPointSet::Eight => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::icd::{BioImpedanceLeadMode, IcdDftNum, MeasurementPointSet};
|
|||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum StartStopSignal {
|
pub enum StartStopSignal {
|
||||||
StartSingle(u32, BioImpedanceLeadMode, IcdDftNum), // frequency in Hz, lead mode, DFT number
|
StartSingle(u32, BioImpedanceLeadMode, IcdDftNum), // frequency in Hz, lead mode, DFT number
|
||||||
StartMulti(MeasurementPointSet), // DFT number, number of points per measurement
|
StartMulti(BioImpedanceLeadMode, MeasurementPointSet), // lead mode, number of points per measurement
|
||||||
Stop,
|
Stop,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user