forked from martino/marte-debug
227 lines
4.9 KiB
Rust
227 lines
4.9 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use std::collections::VecDeque;
|
|
use crossbeam_channel::Sender;
|
|
use eframe::egui;
|
|
use egui_plot::LineStyle;
|
|
|
|
#[allow(dead_code)]
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
pub struct Signal {
|
|
#[serde(alias = "Name")]
|
|
pub name: String,
|
|
#[serde(alias = "ID")]
|
|
pub id: u32,
|
|
#[serde(rename = "type", alias = "Type")]
|
|
pub sig_type: String,
|
|
#[serde(default, alias = "Dimensions")]
|
|
pub dimensions: u8,
|
|
#[serde(default = "default_elements", alias = "Elements")]
|
|
pub elements: u32,
|
|
#[serde(default, alias = "IsState")]
|
|
pub is_state: bool,
|
|
#[serde(default)]
|
|
pub config: Option<serde_json::Value>,
|
|
}
|
|
|
|
pub fn default_elements() -> u32 { 1 }
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct DiscoverResponse {
|
|
#[serde(rename = "Signals")]
|
|
pub signals: Vec<Signal>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
#[serde(rename_all = "PascalCase")]
|
|
pub struct TreeItem {
|
|
pub name: String,
|
|
pub class: String,
|
|
pub children: Option<Vec<TreeItem>>,
|
|
#[serde(rename = "Type")]
|
|
pub sig_type: Option<String>,
|
|
pub dimensions: Option<u8>,
|
|
pub elements: Option<u32>,
|
|
pub is_traceable: Option<bool>,
|
|
pub is_forcable: Option<bool>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct LogEntry {
|
|
pub time: String,
|
|
pub level: String,
|
|
pub message: String,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct TraceData {
|
|
pub values: VecDeque<[f64; 2]>,
|
|
pub last_value: f64,
|
|
pub recording_tx: Option<Sender<[f64; 2]>>,
|
|
pub recording_path: Option<String>,
|
|
pub is_monitored: bool,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct SignalMetadata {
|
|
pub names: Vec<String>,
|
|
pub sig_type: String,
|
|
pub dimensions: u8,
|
|
pub elements: u32,
|
|
pub is_state: bool,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct ConnectionConfig {
|
|
pub ip: String,
|
|
pub tcp_port: String,
|
|
pub udp_port: String,
|
|
pub log_port: String,
|
|
pub version: u64,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
|
pub enum PlotType {
|
|
Normal,
|
|
LogicAnalyzer,
|
|
}
|
|
|
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
|
pub enum AcquisitionMode {
|
|
FreeRun,
|
|
Triggered,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
|
pub enum TriggerEdge {
|
|
Rising,
|
|
Falling,
|
|
Both,
|
|
}
|
|
|
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
|
pub enum TriggerType {
|
|
Single,
|
|
Continuous,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
|
pub enum MarkerType {
|
|
None,
|
|
Circle,
|
|
Square,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
impl MarkerType {
|
|
pub fn to_shape(&self) -> Option<egui_plot::MarkerShape> {
|
|
match self {
|
|
MarkerType::None => None,
|
|
MarkerType::Circle => Some(egui_plot::MarkerShape::Circle),
|
|
MarkerType::Square => Some(egui_plot::MarkerShape::Square),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
#[derive(Clone)]
|
|
pub struct SignalPlotConfig {
|
|
pub source_name: String,
|
|
pub label: String,
|
|
pub unit: String,
|
|
pub color: egui::Color32,
|
|
pub line_style: LineStyle,
|
|
pub marker_type: MarkerType,
|
|
pub gain: f64,
|
|
pub offset: f64,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct PlotInstance {
|
|
pub id: String,
|
|
pub plot_type: PlotType,
|
|
pub signals: Vec<SignalPlotConfig>,
|
|
pub auto_bounds: bool,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub enum InternalEvent {
|
|
Log(LogEntry),
|
|
Discovery(Vec<Signal>),
|
|
Tree(TreeItem),
|
|
CommandResponse(String),
|
|
NodeInfo(String),
|
|
Connected,
|
|
Disconnected,
|
|
InternalLog(String),
|
|
TraceRequested(String, bool), // Name, IsMonitored
|
|
ClearTrace(String),
|
|
UdpStats(u64),
|
|
UdpDropped(u32),
|
|
RecordPathChosen(String, String), // SignalName, FilePath
|
|
RecordingError(String, String), // SignalName, ErrorMessage
|
|
TelemMatched(u32), // Signal ID
|
|
ServiceConfig { udp_port: String, log_port: String },
|
|
StateUpdate(String, String), // Path, StateName
|
|
Config(serde_json::Value),
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct ForcingDialog {
|
|
pub signal_path: String,
|
|
pub value: String,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct MonitorDialog {
|
|
pub signal_path: String,
|
|
pub period_ms: String,
|
|
}
|
|
|
|
pub struct MessageDialog {
|
|
pub destination: String,
|
|
pub function: String,
|
|
pub payload: String,
|
|
pub expect_reply: bool,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct LogFilters {
|
|
pub show_debug: bool,
|
|
pub show_info: bool,
|
|
pub show_warning: bool,
|
|
pub show_error: bool,
|
|
pub paused: bool,
|
|
pub content_regex: String,
|
|
}
|
|
|
|
#[derive(Clone, Copy, PartialEq)]
|
|
pub enum BottomTab {
|
|
Logs,
|
|
State,
|
|
}
|
|
|
|
#[derive(Clone, Copy, PartialEq)]
|
|
pub enum MainTab {
|
|
Plots,
|
|
Config,
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub struct ScopeSettings {
|
|
pub enabled: bool,
|
|
pub window_ms: f64,
|
|
pub mode: AcquisitionMode,
|
|
pub paused: bool,
|
|
pub trigger_type: TriggerType,
|
|
pub trigger_source: String,
|
|
pub trigger_edge: TriggerEdge,
|
|
pub trigger_threshold: f64,
|
|
pub pre_trigger_percent: f64,
|
|
pub trigger_active: bool,
|
|
pub last_trigger_time: f64,
|
|
pub is_armed: bool,
|
|
}
|