use std::collections::VecDeque;
pub(crate) use super::trace_look::TraceLook;
pub(crate) struct TraceState {
pub name: String,
pub look: TraceLook,
pub offset: f64,
pub live: VecDeque<[f64; 2]>,
pub snap: Option<VecDeque<[f64; 2]>>,
#[cfg_attr(not(feature = "fft"), allow(dead_code))]
pub last_fft: Option<Vec<[f64; 2]>>,
pub is_math: bool,
pub info: String,
}
#[derive(Debug, Clone)]
pub(crate) struct MathBuilderState {
pub name: String,
pub kind_idx: usize,
pub add_inputs: Vec<(usize, f64)>,
pub mul_a_idx: usize,
pub mul_b_idx: usize,
pub single_idx: usize, pub integ_y0: f64,
pub filter_which: usize, pub filter_f1: f64,
pub filter_f2: f64,
pub filter_q: f64,
pub minmax_decay: f64,
pub look: TraceLook,
}
impl Default for MathBuilderState {
fn default() -> Self {
Self {
name: String::new(),
kind_idx: 0,
add_inputs: vec![(0, 1.0), (0, 1.0)],
mul_a_idx: 0,
mul_b_idx: 0,
single_idx: 0,
integ_y0: 0.0,
filter_which: 0,
filter_f1: 1.0,
filter_f2: 10.0,
filter_q: 0.707,
minmax_decay: 0.0,
look: TraceLook::default(),
}
}
}
#[derive(Debug, Clone)]
pub(crate) struct ThresholdBuilderState {
pub name: String,
pub target_idx: usize,
pub kind_idx: usize, pub thr1: f64,
pub thr2: f64,
pub min_duration_ms: f64,
pub max_events: usize,
pub look: TraceLook,
pub look_start_events: TraceLook,
pub look_stop_events: TraceLook,
}
impl Default for ThresholdBuilderState {
fn default() -> Self {
let mut look = TraceLook::default();
look.style = egui_plot::LineStyle::Dashed { length: 6.0 };
let mut look_start = TraceLook::default();
look_start.show_points = true;
look_start.point_size = 6.0;
look_start.marker = egui_plot::MarkerShape::Diamond;
look_start.visible = true; let mut look_stop = TraceLook::default();
look_stop.show_points = true;
look_stop.point_size = 6.0;
look_stop.marker = egui_plot::MarkerShape::Square;
Self {
name: String::new(),
target_idx: 0,
kind_idx: 0,
thr1: 0.0,
thr2: 1.0,
min_duration_ms: 2.0,
max_events: 100,
look,
look_start_events: look_start,
look_stop_events: look_stop,
}
}
}