Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
298 changes: 153 additions & 145 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion console_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ serde_yaml = "0.9.14"
anyhow = { version = "1", features = ["backtrace"] }
clap = { version = "4.0.29", features = ["derive"] }
indexmap = { version = "1.9.2", features = ["serde"] }
chrono = { version = "0.4.23", features = ["serde"] }
chrono = { version = "0.4.23", features = [
"serde",
"clock",
"std",
], default-features = false }
serde = { version = "1.0.148", features = ["derive"] }
sbp = { version = "4.9.1", features = ["json", "link", "swiftnav"] }
mimalloc = { version = "0.1", default-features = false }
Expand Down Expand Up @@ -62,6 +66,7 @@ ndarray = "0.15.6"
criterion = "0.4.0"
sysinfo = "0.26.7"
tempfile = "3.3.0"
rstest = "0.16.0"

[build-dependencies]
capnpc = "0.15.0"
Expand Down
2 changes: 1 addition & 1 deletion console_backend/src/cli_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub struct CliOptions {
#[clap(long, hide = true)]
pub qmldebug: bool,

/// SSH tunnel to a jumphost specified ([username]:[password]@some.fqdn)
/// SSH tunnel to a jumphost specified (`[username]:[password]@some.fqdn`)
#[clap(long, hide = true)]
pub ssh_tunnel: Option<PathBuf>,

Expand Down
4 changes: 2 additions & 2 deletions console_backend/src/fileio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ impl Fileio {

/// Deletes `filename` on the remote device (if it exists) and writes the contents of `data` to the file.
/// This operation is NOT atomic. If the write fails and `filename` existed, it is gone forever.
/// For more context see: https://github.com/swift-nav/swift-toolbox/pull/72#discussion_r654751414
/// For more context see: <https://github.com/swift-nav/swift-toolbox/pull/72#discussion_r654751414>
pub fn overwrite(&mut self, filename: String, data: impl Read + Send) -> Result<()> {
self.overwrite_with_progress(filename, data, |_| ())
}

/// Deletes `filename` on the remote device (if it exists) and writes the contents of `data` to the file.
/// This operation is NOT atomic. If the write fails and `filename` existed, it is gone forever.
/// For more context see: https://github.com/swift-nav/swift-toolbox/pull/72#discussion_r654751414
/// For more context see: <https://github.com/swift-nav/swift-toolbox/pull/72#discussion_r654751414>
pub fn overwrite_with_progress<F>(
&mut self,
filename: String,
Expand Down
18 changes: 7 additions & 11 deletions console_backend/src/fusion_status_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,25 +272,21 @@ impl Drop for FusionStatusFlag {
}
}

/// FusionStatusFlags struct.
///
/// # Fields:
///
/// - `client_send`: Client Sender channel for communication from backend to frontend.
/// - `gnsspos`: Storage for the GNSS Position status.
/// - `gnssvel`: Storage for the GNSS Velocity status.
/// - `wheelticks`: Storage for the wheel ticks status.
/// - `speed`: Storage for the wheel speed status.
/// - `nhc`: Storage for the non-holonomic constraints model status.
/// - `zerovel`: Storage for the zero velocity status.
#[derive(Debug)]
pub struct FusionStatusFlags {
/// Sender channel for communication from backend to frontend.
client_sender: BoxedClientSender,
/// Storage for the GNSS Position status.
gnsspos: FusionStatusFlag,
/// Storage for the GNSS Velocity status.
gnssvel: FusionStatusFlag,
/// Storage for the wheel ticks status.
wheelticks: FusionStatusFlag,
/// Storage for the wheel speed status.
speed: FusionStatusFlag,
/// Storage for the non-holonomic constraints model status.
nhc: FusionStatusFlag,
/// Storage for the zero velocity status.
zerovel: FusionStatusFlag,
}

Expand Down
10 changes: 5 additions & 5 deletions console_backend/src/process_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ pub fn process_messages(
err
}

/// Process custom events defined by [`SharedState::EventType`]
/// Process custom events defined by `SharedState::EventType`
///
/// Allows channel to manage events dispatched from front end,
/// indirectly gives [`SharedState`] access to [`Tabs`]
/// indirectly gives `SharedState` access to `Tabs`
fn process_shared_state_events(rx: Receiver<EventType>, tabs: &Tabs) {
for event in rx.iter() {
match event {
Expand Down Expand Up @@ -534,9 +534,9 @@ mod messages {
}
}

// Wrapper type so can hook into the drop call that happens when the last Arc<Shared> is dropped.
// We could not use this and drop when the arc's strong count is 1, but the count might change
// between calling `Arc::strong_count` and `self.stop`
/// Wrapper type so can hook into the drop call that happens when the last `Arc<Shared>` is dropped.
/// We could not use this and drop when the arc's strong count is 1, but the count might change
/// between calling `Arc::strong_count` and `self.stop`
struct Shared(Sender<()>);

impl Shared {
Expand Down
5 changes: 0 additions & 5 deletions console_backend/src/shared_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,6 @@ impl SettingsTabState {
// Navbar Types.

/// Directory struct for storing informating and helpers pertaining to project directory.
///
/// Taken from swift-cli/swift/src/types.rs.
/// impl taken from swift-cli/swift/src/lib.rs.
#[derive(Debug)]
pub struct Directory {
path: PathBuf,
Expand Down Expand Up @@ -718,7 +715,6 @@ impl Default for Directory {

/// Deduce data directory path and create folder.
///
/// Taken from swift-cli/swift/src/lib.rs.
/// # Returns
/// - `Ok`: The PathBuf for the data directory path.
/// - `Err`: Issue deducing path or creating the data directory.
Expand All @@ -736,7 +732,6 @@ fn create_data_dir() -> AHResult<PathBuf> {

/// Create directory.
///
/// Taken from swift-cli/swift/src/lib.rs.
/// # Returns
/// - `Ok`: The PathBuf for the data directory path.
/// - `Err`: Issue deducing path or creating the data directory.
Expand Down
5 changes: 1 addition & 4 deletions console_backend/src/status_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,9 @@ impl Default for StatusBarUpdate {
}
}

/// StatusBar struct.
///
/// # Fields:
/// - `heartbeat_data`: The shared object for storing and accessing relevant status bar data.
#[derive(Debug)]
pub struct StatusBar {
/// The shared object for storing and accessing relevant status bar data.
heartbeat_data: Heartbeat,
}
impl StatusBar {
Expand Down
28 changes: 12 additions & 16 deletions console_backend/src/tabs/advanced_tab/advanced_imu_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,33 @@ use crate::shared_state::{SharedState, TabName};
use crate::types::RingBuffer;
use crate::utils::{euclidean_distance, serialize_capnproto_builder};

/// AdvancedImuTab struct.
///
/// # Fields:
///
/// - `client_send`: Client Sender channel for communication from backend to frontend.
/// - `imu_conf`: Storage for the Imu configuration.
/// - `imu_temp`: Storage for the raw Imu temperature converted to proper units.
/// - `rms_acc_x`: The calculated root mean squared imu acceleration for x axis.
/// - `rms_acc_y`: The calculated root mean squared imu acceleration for y axis.
/// - `rms_acc_z`: The calculated root mean squared imu acceleration for z axis.
/// - `acc_x`: The stored historic Imu acceleration values along x axis.
/// - `acc_y`: The stored historic Imu acceleration values along y axis.
/// - `acc_z`: The stored historic Imu acceleration values along z axis.
/// - `gyro_x`: The stored historic Imu angular rate values along x axis.
/// - `gyro_y`: The stored historic Imu angular rate values along y axis.
/// - `gyro_z`: The stored historic Imu angular rate values along z axis.
#[derive(Debug)]
pub struct AdvancedImuTab {
shared_state: SharedState,
/// Client Sender channel for communication from backend to frontend.
client_sender: BoxedClientSender,
pub fusion_engine_status_bar: FusionStatusFlags,
/// Storage for the Imu configuration.
imu_conf: u8,
/// Storage for the raw Imu temperature converted to proper units.
imu_temp: f64,
/// The calculated root mean squared imu acceleration for x axis.
rms_acc_x: f64,
/// The calculated root mean squared imu acceleration for y axis.
rms_acc_y: f64,
/// The calculated root mean squared imu acceleration for z axis.
rms_acc_z: f64,
/// The stored historic Imu acceleration values along x axis.
acc_x: RingBuffer<f64>,
/// The stored historic Imu acceleration values along y axis.
acc_y: RingBuffer<f64>,
/// The stored historic Imu acceleration values along z axis.
acc_z: RingBuffer<f64>,
/// The stored historic Imu angular rate values along x axis.
gyro_x: RingBuffer<f64>,
/// The stored historic Imu angular rate values along y axis.
gyro_y: RingBuffer<f64>,
/// The stored historic Imu angular rate values along z axis.
gyro_z: RingBuffer<f64>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,16 @@ use crate::types::RingBuffer;
use crate::utils::serialize_capnproto_builder;
use crate::zip;

/// AdvancedMagnetometerTab struct.
///
/// # Fields:
///
/// - `client_send`: Client Sender channel for communication from backend to frontend.
/// - `last_plot_update_time`: The last time the plot values were attempted to send to frontend.
/// - `mag_x`: The stored historic Magnetometer values along x axis.
/// - `mag_y`: The stored historic Magnetometer values along y axis.
/// - `mag_z`: The stored historic Magnetometer values along z axis.
#[derive(Debug)]
pub struct AdvancedMagnetometerTab {
shared_state: SharedState,
/// Client Sender channel for communication from backend to frontend.
client_sender: BoxedClientSender,
/// The stored historic Magnetometer values along x axis.
mag_x: RingBuffer<f64>,
/// The stored historic Magnetometer values along y axis.
mag_y: RingBuffer<f64>,
/// The stored historic Magnetometer values along z axis.
mag_z: RingBuffer<f64>,
ymax: f64,
ymin: f64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,18 @@ use crate::shared_state::{SharedState, TabName};
use crate::types::Specan;
use crate::utils::serialize_capnproto_builder;

/// AdvancedSpectrumAnalyzerTab struct.
///
/// # Fields:
///
/// - `client_send`: Client Sender channel for communication from backend to frontend.
/// - `fft_monitor`: Instance of the FftMonitor struct for handling specan messages.
/// - `channel_idx`: Stores the index received from the frontend for which CHANNEL
/// to send to frontend.
/// - `most_recent_amplitudes`: Stores the currently viewed channel's amplitude values to be
/// sent to frontend.
/// - `most_recent_frequencies`: Stores the currently viewed channel's frequency values to be
/// sent to frontend.
/// - `shared_state`: The shared state for communicating between frontend/backend/other backend tabs.
pub struct AdvancedSpectrumAnalyzerTab {
/// Client Sender channel for communication from backend to frontend.
client_sender: BoxedClientSender,
/// Instance of the FftMonitor struct for handling specan messages.
fft_monitor: FftMonitor,
/// Stores the index received from the frontend for which CHANNEL to send to frontend.
channel_idx: usize,
/// Stores the currently viewed channel's amplitude values to be sent to frontend.
most_recent_amplitudes: Vec<f32>,
/// Stores the currently viewed channel's frequency values to be sent to frontend.
most_recent_frequencies: Vec<f32>,
/// The shared state for communicating between frontend/backend/other backend tabs.
shared_state: SharedState,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,24 @@ struct ThreadStateFields {
stack_free: u32,
}

/// AdvancedSystemMonitorTab struct.
///
/// # Fields:
///
/// - `client_send`: Client Sender channel for communication from backend to frontend.
/// - `fe_temp`: RF frontend temperature reading.
/// - `obs_latency`: UART state latency measurements.
/// - `obs_period`: UART state period measurements.
/// - `threads`: Vec of, ThreadStateFields, running threads on device containing cpu and memory metric values.
/// - `threads_table_list`: Vec of ThreadStateFields, sent to frontend after heartbeat received.
/// - `zynq_temp`: Zynq SoC temperature reading.
pub struct AdvancedSystemMonitorTab {
shared_state: SharedState,
/// Client Sender channel for communication from backend to frontend.
client_sender: BoxedClientSender,
/// RF frontend temperature reading.
fe_temp: f64,
/// UART state latency measurements.
obs_latency: HashMap<String, i32>,
/// UART state period measurements.
obs_period: HashMap<String, i32>,
/// Vec of, ThreadStateFields, running threads on device containing cpu and memory metric values.
threads: Vec<ThreadStateFields>,
/// Vec of ThreadStateFields, sent to frontend after heartbeat received.
threads_table_list: Vec<ThreadStateFields>,
/// Zynq SoC temperature reading.
zynq_temp: f64,
}

impl AdvancedSystemMonitorTab {
pub fn new(
shared_state: SharedState,
Expand Down
57 changes: 22 additions & 35 deletions console_backend/src/tabs/baseline_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,60 +35,53 @@ use crate::utils::{date_conv::*, *};
use crate::zip;
use crate::{client_sender::BoxedClientSender, constants::*};

/// Baseline Tab Button Struct.
///
/// # Parameters
/// - `clear`: Indicates whether to initiate a clearing of all solution data stored.
/// - `pause`: Indicates whther or not to pause the plot updates.
/// - `reset`: Indicates whether or not to reset filters.
pub(crate) struct BaselineTabButtons {
/// Indicates whether to initiate a clearing of all solution data stored.
clear: bool,
/// Indicates whether or not to pause the plot updates.
pause: bool,
/// Indicates whether or not to reset filters.
reset: bool,
}

/// BaselineTab struct.
///
/// # Fields
/// - `age_corrections`: Stored age corrections to be displayed in the table.
/// - `client_sender`: Client Sender channel for communication from backend to frontend.
/// - `heading`: The stored heading value.
/// - `last_mode`: The most recent gnss mode stored.
/// - `n_max`: The baseline north direction maximimum value storage for plot bounds.
/// - `n_min`: The baseline north direction minimum value storage for plot bounds.
/// - `n_max`: The baseline east direction maximimum value storage for plot bounds.
/// - `n_min`: The baseline east direction minimum value storage for plot bounds.
/// - `mode_strings`: The available modes in string form to store updates for.
/// - `nsec`: The stored nanosecond value from GPS Time messages.
/// - `pending_draw_modes`: A list of draw modes waiting to be updated.
/// - `shared_state`: The shared state for communicating between frontend/backend/other backend tabs.
/// - `baseline_log_file`: The CsvSerializer corresponding to an open position log if any.
/// - `sln_cur_data`: The current most recent n/e point for each mode.
/// - `sln_data`: The preprocessed solution data to be sent to the frontend.
/// - `slns`: All solution data is stored before preparing for frontend.
/// - `table`: This stores all the key/value pairs to be displayed in the Baseline Table.
/// - `utc_source`: The string equivalent for the source of the UTC updates.
/// - `utc_time`: The stored monotonic Utc time.
/// - `week`: The stored week value from GPS Time messages.
pub struct BaselineTab {
/// Stored age corrections to be displayed in the table.
age_corrections: Option<f64>,
/// Client Sender channel for communication from backend to frontend.
client_sender: BoxedClientSender,
/// The stored heading value.
heading: Option<f64>,
/// The most recent gnss mode stored.
last_mode: u8,
/// The baseline north direction maximimum value storage for plot bounds.
n_max: f64,
/// The baseline north direction minimum value storage for plot bounds.
n_min: f64,
/// The baseline east direction maximimum value storage for plot bounds.
e_max: f64,
/// The baseline east direction minimum value storage for plot bounds.
e_min: f64,
/// The available modes in string form to store updates for.
mode_strings: Vec<String>,
/// The stored nanosecond value from GPS Time messages.
nsec: Option<i32>,
/// A list of draw modes waiting to be updated.
pending_draw_modes: Vec<String>,
/// The shared state for communicating between frontend/backend/other backend tabs.
shared_state: SharedState,
/// The current most recent n/e point for each mode.
sln_cur_data: Vec<Vec<(f64, f64)>>,
/// The preprocessed solution data to be sent to the frontend.
sln_data: Vec<Vec<(f64, f64)>>,
/// All solution data is stored before preparing for frontend.
slns: HashMap<&'static str, RingBuffer<f64>>,
/// This stores all the key/value pairs to be displayed in the Baseline Table.
table: HashMap<&'static str, String>,
/// The string equivalent for the source of the UTC updates.
utc_source: Option<String>,
/// The stored monotonic Utc time.
utc_time: Option<UtcDateTime>,
/// The stored week value from GPS Time messages.
week: Option<u16>,
writer: MsgSender,
}
Expand Down Expand Up @@ -426,12 +419,6 @@ impl BaselineTab {

/// Initiates preprocessing of solution data and handles frontend input.
///
/// TODO(johnmichael.burke@) https://swift-nav.atlassian.net/browse/CPP-245
/// Need to complete missing functionalities:
/// - Center on solution
/// - Handle zoom feature.
/// - Reset Filters button.
///
/// # Parameters
/// - `buttons`: Instance of BaselineTabButtons which trigger different behaviors.
fn solution_draw(&mut self, buttons: BaselineTabButtons) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl LatLonUnits {
/// Convert latitude in degrees to latitude and longitude to meters multipliers.
///
/// Taken from:
/// https://github.com/swift-nav/piksi_tools/blob/v3.1.0-release/piksi_tools/console/solution_view.py
/// <https://github.com/swift-nav/piksi_tools/blob/v3.1.0-release/piksi_tools/console/solution_view.py>
fn meters_per_degree(lat: f64) -> (f64, f64) {
let m1 = 111132.92; // latitude calculation term 1
let m2 = -559.82; // latitude calculation term 2
Expand Down
Loading