Skip to content

Commit 67f78b4

Browse files
Buttons are working.
1 parent f174413 commit 67f78b4

File tree

10 files changed

+459
-123
lines changed

10 files changed

+459
-123
lines changed

console_backend/src/constants.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub const LAT_MAX: f64 = 90_f64;
4141
pub const LAT_MIN: f64 = -90_f64;
4242
pub const LON_MAX: f64 = 180_f64;
4343
pub const LON_MIN: f64 = -180_f64;
44+
pub const DEGREES: &str = "degrees";
45+
pub const METERS: &str = "meters";
4446
pub const NO_FIX_LABEL: &str = "No Fix";
4547
pub const SPP_LABEL: &str = "SPP";
4648
pub const DGNSS_LABEL: &str = "DGPS";
@@ -82,10 +84,7 @@ pub const ALT_DR: &str = "alt_Dead Reckoning";
8284
pub const LAT_SBAS: &str = "lat_SBAS";
8385
pub const LNG_SBAS: &str = "lng_SBAS";
8486
pub const ALT_SBAS: &str = "alt_SBAS";
85-
pub const SOLUTIONS_KEYS: &[&str] = &[
86-
LAT_SPP, LNG_SPP, ALT_SPP, LAT_DGNSS, LNG_DGNSS, ALT_DGNSS, LAT_FLOAT, LNG_FLOAT, ALT_FLOAT,
87-
LAT_FIXED, LNG_FIXED, ALT_FIXED, LAT_DR, LNG_DR, ALT_DR, LAT_SBAS, LNG_SBAS, ALT_SBAS,
88-
];
87+
8988
pub const SOLUTION_DATA_KEYS: &[&str] = &[
9089
LAT_SPP, LNG_SPP, LAT_DGNSS, LNG_DGNSS, LAT_FLOAT, LNG_FLOAT, LAT_FIXED, LNG_FIXED, LAT_DR,
9190
LNG_DR, LAT_SBAS, LNG_SBAS,
@@ -219,7 +218,7 @@ impl GnssModes {
219218
};
220219
String::from(gnss_mode_label)
221220
}
222-
pub fn get_color(&self) -> String {
221+
pub fn get_color(&self) -> String {
223222
let gnss_mode_color = match self {
224223
GnssModes::NoFix => NO_FIX_COLOR,
225224
GnssModes::Spp => SPP_COLOR,
@@ -896,7 +895,7 @@ pub fn get_utc_time(
896895
/// # Returns:
897896
/// - Partial datetime string and seconds/microseconds string.
898897
pub fn datetime_2_str_utc(datetm: DateTime<Utc>) -> (String, f64) {
899-
let seconds = datetm.second() as f64 + datetm.nanosecond() as f64 / 1000_f64;
898+
let seconds = datetm.second() as f64 + datetm.nanosecond() as f64 / 1e9_f64;
900899
(datetm.format("%Y-%m-%d %H:%M").to_string(), seconds)
901900
}
902901

@@ -908,7 +907,7 @@ pub fn datetime_2_str_utc(datetm: DateTime<Utc>) -> (String, f64) {
908907
/// # Returns:
909908
/// - Partial datetime string and seconds/microseconds string.
910909
pub fn datetime_2_str_local(datetm: DateTime<Local>) -> (String, f64) {
911-
let seconds = datetm.second() as f64 + datetm.nanosecond() as f64 / 1000_f64;
910+
let seconds = datetm.second() as f64 + datetm.nanosecond() as f64 / 1e9_f64;
912911
(datetm.format("%Y-%m-%d %H:%M").to_string(), seconds)
913912
}
914913

@@ -1040,10 +1039,10 @@ mod tests {
10401039

10411040
#[test]
10421041
fn nano_to_micro_sec_test() {
1043-
assert_eq!(nano_to_micro_sec(1000_f64), 1_f64);
1044-
assert_eq!(nano_to_micro_sec(1000000_f64), 1000_f64);
1045-
assert_eq!(nano_to_micro_sec(0_f64), 0_f64);
1046-
assert_eq!(nano_to_micro_sec(1337_f64), 1.337_f64);
1042+
assert!(f64::abs(nano_to_micro_sec(1000_f64) - 1_f64) <= f64::EPSILON);
1043+
assert!(f64::abs(nano_to_micro_sec(1000000_f64) - 1000_f64) <= f64::EPSILON);
1044+
assert!(f64::abs(nano_to_micro_sec(0_f64) - 0_f64) <= f64::EPSILON);
1045+
assert!(f64::abs(nano_to_micro_sec(1337_f64) - 1.337_f64) <= f64::EPSILON);
10471046
}
10481047

10491048
#[test]

console_backend/src/output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use serde::Serialize;
21
use std::fs::File;
32

43
use crate::types::{PosLLHLog, Result, VelLog};
@@ -30,6 +29,7 @@ impl CsvSerializer {
3029
#[cfg(test)]
3130
mod tests {
3231
use super::*;
32+
use serde::Serialize;
3333
use std::path::Path;
3434
use tempfile::TempDir;
3535
const TEST_FILEPATH: &str = "test.csv";

console_backend/src/server.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,24 @@ impl Server {
218218
(*shared_data).solution_tab.velocity_tab.unit = unit.to_string();
219219
}
220220
}
221+
Ok(m::message::Which::SolutionPositionStatusUnitFront(Ok(cv_in))) => {
222+
let shared_state_clone = shared_state.clone();
223+
let mut shared_data = shared_state_clone.lock().unwrap();
224+
let unit = cv_in.get_solution_position_unit().unwrap();
225+
(*shared_data).solution_tab.position_tab.unit = unit.to_string();
226+
}
227+
Ok(m::message::Which::SolutionPositionStatusButtonFront(Ok(cv_in))) => {
228+
let shared_state_clone = shared_state.clone();
229+
let mut shared_data = shared_state_clone.lock().unwrap();
230+
(*shared_data).solution_tab.position_tab.zoom =
231+
cv_in.get_solution_position_zoom();
232+
(*shared_data).solution_tab.position_tab.center =
233+
cv_in.get_solution_position_center();
234+
(*shared_data).solution_tab.position_tab.clear =
235+
cv_in.get_solution_position_clear();
236+
(*shared_data).solution_tab.position_tab.pause =
237+
cv_in.get_solution_position_pause();
238+
}
221239
Ok(_) => {
222240
println!("something else");
223241
}

0 commit comments

Comments
 (0)