Skip to content

Commit

Permalink
time as f64 to allow for all kinds of input files (not just integer t…
Browse files Browse the repository at this point in the history
…ime scales)
  • Loading branch information
hacknus committed Dec 22, 2024
1 parent ce8e799 commit acd989f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ pub fn get_epoch_ms() -> u128 {

#[derive(Clone, Debug)]
pub struct Packet {
pub relative_time: u128,
pub absolute_time: u128,
pub relative_time: f64,
pub absolute_time: f64,
pub direction: SerialDirection,
pub payload: String,
}

impl Default for Packet {
fn default() -> Packet {
Packet {
relative_time: 0,
absolute_time: get_epoch_ms(),
relative_time: 0.0,
absolute_time: get_epoch_ms() as f64,
direction: SerialDirection::Send,
payload: "".to_string(),
}
Expand All @@ -44,8 +44,8 @@ impl Default for Packet {

#[derive(Clone, Debug)]
pub struct DataContainer {
pub time: Vec<u128>,
pub absolute_time: Vec<u128>,
pub time: Vec<f64>,
pub absolute_time: Vec<f64>,
pub dataset: Vec<Vec<f32>>,
pub raw_traffic: Vec<Packet>,
}
Expand Down
4 changes: 1 addition & 3 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,9 +1194,7 @@ impl MyApp {
}
}
}
FileDialogState::None => {
self.file_opened = false;
}
FileDialogState::None => {}
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ fn perform_writes(
}

let packet = Packet {
relative_time: Instant::now().duration_since(t_zero).as_millis(),
absolute_time: get_epoch_ms(),
relative_time: Instant::now().duration_since(t_zero).as_millis() as f64,
absolute_time: get_epoch_ms() as f64,
direction: SerialDirection::Send,
payload: cmd,
};
Expand All @@ -274,8 +274,8 @@ fn perform_reads(
let delimiter = if buf.contains("\r\n") { "\r\n" } else { "\0\0" };
buf.split_terminator(delimiter).for_each(|s| {
let packet = Packet {
relative_time: Instant::now().duration_since(t_zero).as_millis(),
absolute_time: get_epoch_ms(),
relative_time: Instant::now().duration_since(t_zero).as_millis() as f64,
absolute_time: get_epoch_ms() as f64,
direction: SerialDirection::Receive,
payload: s.to_owned(),
};
Expand Down

0 comments on commit acd989f

Please sign in to comment.