Skip to content

Commit 7be3881

Browse files
[CPP-154]Fusion Engine Status Bar for Advanced->INS tab. (#71)
* Fusion Engine Status WIP. * Fusion Engine Status. * Switching to atomicbool. * working on it. * Switch to channels. * Switch to svg icons. * Respond to review requests.
1 parent 604d2d3 commit 7be3881

33 files changed

+1207
-90
lines changed

Cargo.lock

Lines changed: 29 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

console_backend/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ serde_yaml = "0.8.17"
3232
clap = "3.0.0-beta.2"
3333
indexmap = { version = "1.6.2", features = ["serde"] }
3434
serde_json = { version = "1" }
35+
crossbeam = "0.8.1"
3536

3637
[target.'cfg(any(target_os = "macos", target_os = "windows"))'.dependencies]
3738
serialport = "4.0.1"

console_backend/src/advanced_ins_tab.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ use log::error;
22
use sbp::messages::imu::{MsgImuAux, MsgImuRaw};
33

44
use capnp::message::Builder;
5-
use capnp::serialize;
65

76
use crate::console_backend_capnp as m;
87
use crate::constants::*;
9-
use crate::errors::{CAP_N_PROTO_SERIALIZATION_FAILURE, GET_MUT_OBJECT_FAILURE};
8+
use crate::errors::GET_MUT_OBJECT_FAILURE;
9+
use crate::fusion_status_flags::FusionStatusFlags;
1010
use crate::types::{Deque, MessageSender, SharedState};
11+
use crate::utils::serialize_capnproto_builder;
1112

1213
/// AdvancedInsTab struct.
1314
///
@@ -29,6 +30,7 @@ use crate::types::{Deque, MessageSender, SharedState};
2930
#[derive(Debug)]
3031
pub struct AdvancedInsTab<S: MessageSender> {
3132
client_sender: S,
33+
pub fusion_engine_status_bar: FusionStatusFlags<S>,
3234
imu_conf: u8,
3335
imu_temp: f64,
3436
rms_acc_x: f64,
@@ -48,6 +50,10 @@ impl<S: MessageSender> AdvancedInsTab<S> {
4850
let acc_fill_val = Some(0_f64);
4951
let gyro_fill_val = Some(0_f64);
5052
AdvancedInsTab {
53+
fusion_engine_status_bar: FusionStatusFlags::new(
54+
shared_state.clone(),
55+
client_sender.clone(),
56+
),
5157
client_sender,
5258
imu_conf: 0_u8,
5359
imu_temp: 0_f64,
@@ -169,10 +175,8 @@ impl<S: MessageSender> AdvancedInsTab<S> {
169175
fields_data_status.set(i as u32, *datur);
170176
}
171177

172-
let mut msg_bytes: Vec<u8> = vec![];
173-
serialize::write_message(&mut msg_bytes, &builder)
174-
.expect(CAP_N_PROTO_SERIALIZATION_FAILURE);
175-
self.client_sender.send_data(msg_bytes);
178+
self.client_sender
179+
.send_data(serialize_capnproto_builder(builder));
176180
}
177181
}
178182

console_backend/src/common_constants.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ pub enum Tabs {
4242
ADVANCED_SPECTRUM_ANALYZER,
4343
}
4444

45+
#[derive(Clone, Debug, Display, EnumString, EnumVariantNames, Eq, Hash, PartialEq)]
46+
pub enum FusionStatus {
47+
#[strum(serialize = "UNKNOWN")]
48+
UNKNOWN,
49+
#[strum(serialize = "WARNING")]
50+
WARNING,
51+
#[strum(serialize = "OK")]
52+
OK,
53+
}
54+
4555
#[derive(Clone, Debug, Display, EnumString, EnumVariantNames, Eq, Hash, PartialEq)]
4656
pub enum SbpLogging {
4757
#[strum(serialize = "OFF")]
@@ -154,8 +164,20 @@ pub enum Keys {
154164
LOG_LEVEL_LABELS,
155165
#[strum(serialize = "FIELDS_DATA")]
156166
FIELDS_DATA,
157-
#[strum(serialize = "XMIN")]
167+
#[strum(serialize = "XMIN_OFFSET")]
158168
XMIN_OFFSET,
169+
#[strum(serialize = "GNSSPOS")]
170+
GNSSPOS,
171+
#[strum(serialize = "GNSSVEL")]
172+
GNSSVEL,
173+
#[strum(serialize = "WHEELTICKS")]
174+
WHEELTICKS,
175+
#[strum(serialize = "SPEED")]
176+
SPEED,
177+
#[strum(serialize = "NHC")]
178+
NHC,
179+
#[strum(serialize = "ZEROVEL")]
180+
ZEROVEL,
159181
}
160182

161183
#[derive(Clone, Debug, Display, EnumString, EnumVariantNames, Eq, Hash, PartialEq)]

console_backend/src/errors.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
pub const HEARTBEAT_LOCK_MUTEX_FAILURE: &str = "unable to lock heartbeat mutex";
2-
pub const SHARED_STATE_LOCK_MUTEX_FAILURE: &str = "unable to lock shared_state mutex";
3-
pub const CAP_N_PROTO_SERIALIZATION_FAILURE: &str = "unable to serialize capnproto message";
4-
pub const CAP_N_PROTO_DESERIALIZATION_FAILURE: &str = "unable to deserialize capnproto message";
5-
pub const CONVERT_TO_STR_FAILURE: &str = "error converting to str";
6-
pub const GET_MUT_OBJECT_FAILURE: &str = "error trying to get mut object";
1+
pub(crate) const HEARTBEAT_LOCK_MUTEX_FAILURE: &str = "unable to lock heartbeat mutex";
2+
pub(crate) const SHARED_STATE_LOCK_MUTEX_FAILURE: &str = "unable to lock shared_state mutex";
3+
pub(crate) const UPDATE_STATUS_LOCK_MUTEX_FAILURE: &str = "unable to lock update status mutex";
4+
pub(crate) const CAP_N_PROTO_SERIALIZATION_FAILURE: &str = "unable to serialize capnproto message";
5+
#[allow(dead_code)]
6+
pub(crate) const CAP_N_PROTO_DESERIALIZATION_FAILURE: &str =
7+
"unable to deserialize capnproto message";
8+
pub(crate) const CONVERT_TO_STR_FAILURE: &str = "error converting to str";
9+
pub(crate) const GET_MUT_OBJECT_FAILURE: &str = "error trying to get mut object";
10+
pub(crate) const UNABLE_TO_STOP_TIMER_THREAD_FAILURE: &str = "unable to kill running timer thread";
11+
pub(crate) const UNABLE_TO_SEND_INS_UPDATE_FAILURE: &str = "unable to send an ins status update";
12+
pub(crate) const THREAD_JOIN_FAILURE: &str = "thread join failure";

0 commit comments

Comments
 (0)