Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ i. e.
"groups": [
{
"group_name": "Frame 1",
"cycle_time_ms": 10,
"cycle_time_μs": 1000,
Comment thread
rafaeling marked this conversation as resolved.
Outdated
"signals": [
{
"path": "Vehicle.Speed"
Expand All @@ -175,7 +175,7 @@ i. e.
},
{
"group_name": "Frame 2",
"cycle_time_ms": 20,
"cycle_time_μs": 2000,
"signals": [
{
"path": "Vehicle.IsBrokenDown"
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct Config {
#[derive(Deserialize, Clone)]
pub struct Group {
pub group_name: String,
pub cycle_time_ms: u16,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcoding it to either ms or microseconds (and choosing between a u16 and u32), it would be better to store it as a Duration. That's what we want in the end anyway, and would make it equally easy to set with either milliseconds, microseconds or anything else as input.

pub cycle_time_μs: u16,
Comment thread
rafaeling marked this conversation as resolved.
Outdated
Comment thread
wba2hi marked this conversation as resolved.
Outdated
pub signals: Vec<Signal>,
}
#[derive(Deserialize, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions src/measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub async fn perform_measurement(
// Create MeasurmentContext for each group
let mut measurement_config = measurement_config.clone();

measurement_config.interval = group.cycle_time_ms;
measurement_config.interval = group.cycle_time_μs;

let hist = Histogram::<u64>::new_with_bounds(1, 60 * 60 * 1000 * 1000, 3)?;
let running_hist = Histogram::<u64>::new_with_bounds(1, 60 * 60 * 1000 * 1000, 3)?;
Expand Down Expand Up @@ -351,7 +351,7 @@ async fn measurement_loop(ctx: &mut MeasurementContext) -> Result<(u64, u64)> {
let mut interval_to_run = if ctx.measurement_config.interval == 0 {
None
} else {
Some(tokio::time::interval(Duration::from_millis(
Some(tokio::time::interval(Duration::from_micros(
ctx.measurement_config.interval.into(),
)))
};
Expand Down
6 changes: 3 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ pub fn read_config(config_file: Option<&String>) -> Result<Vec<Group>> {
Ok(vec![
Group {
group_name: String::from("Group A"),
cycle_time_ms: 0,
cycle_time_μs: 0,
signals: vec![Signal {
path: String::from("Vehicle.Speed"),
}],
},
Group {
group_name: String::from("Group B"),
cycle_time_ms: 0,
cycle_time_μs: 0,
signals: vec![Signal {
path: String::from("Vehicle.IsBrokenDown"),
}],
},
Group {
group_name: String::from("Group C"),
cycle_time_ms: 0,
cycle_time_μs: 0,
signals: vec![
Signal {
path: String::from("Vehicle.Body.Windshield.Front.Wiping.Intensity"),
Expand Down