Skip to content

Commit

Permalink
move mock data to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Jul 20, 2024
1 parent 311774f commit d464d2d
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 146 deletions.
136 changes: 136 additions & 0 deletions scylla-server-rust/src/processors/mock_data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
use super::mock_processor::{MockData, MockStringData};

pub const BASE_MOCK_DATA: [MockData; 17] = [
MockData {
name: "Status-Temp_Average",
unit: "C",
num_of_vals: 1,
min: -20.0,
max: 54.0,
},
MockData {
name: "Temps-Motor_Temperature",
unit: "C",
num_of_vals: 1,
min: -20.0,
max: 54.0,
},
MockData {
name: "Pack-SOC",
unit: "%",
num_of_vals: 1,
min: 0.0,
max: 100.0,
},
MockData {
name: "Sense-Accel",
unit: "G",
num_of_vals: 3,
min: -6.0,
max: 6.0,
},
MockData {
name: "GPS-Location",
unit: "coordinates",
num_of_vals: 2,
min: -90.0,
max: 90.0,
},
MockData {
name: "Sense-SteeringAngle",
unit: "degrees",
num_of_vals: 1,
min: 0.0,
max: 360.0,
},
MockData {
name: "Pack-Voltage",
unit: "V",
num_of_vals: 1,
min: 0.0,
max: 5.0,
},
MockData {
name: "OnBoard-CpuUsage",
unit: "%",
num_of_vals: 1,
min: 0.0,
max: 100.0,
},
MockData {
name: "OnBoard-CpuTemp",
unit: "C",
num_of_vals: 1,
min: 0.0,
max: 100.0,
},
MockData {
name: "OnBoard-MemAvailable",
unit: "mb",
num_of_vals: 1,
min: 0.0,
max: 8000.0,
},
MockData {
name: "HaLow-RSSI",
unit: "dbm",
num_of_vals: 1,
min: -150.0,
max: 80.0,
},
MockData {
name: "HaLow-StaMCS",
unit: "",
num_of_vals: 1,
min: 0.0,
max: 10.0,
},
MockData {
name: "Status/MPH",
unit: "mph",
num_of_vals: 1,
min: 0.0,
max: 88.0,
},
MockData {
name: "Pack-CCL",
unit: "A",
num_of_vals: 1,
min: -35.0,
max: 0.0,
},
MockData {
name: "Pack-DCL",
unit: "A",
num_of_vals: 1,
min: 0.0,
max: 550.0,
},
MockData {
name: "Pedals-Brake1",
unit: "",
num_of_vals: 1,
min: 0.0,
max: 3000.0,
},
MockData {
name: "Power-AC_Current",
unit: "A",
num_of_vals: 1,
min: 0.0,
max: 600.0,
},
];

pub const BASE_MOCK_STRING_DATA: [MockStringData; 2] = [
MockStringData {
name: "Driver",
unit: "String",
vals: "Fergus",
},
MockStringData {
name: "Location",
unit: "String",
vals: "Max",
},
];
160 changes: 14 additions & 146 deletions scylla-server-rust/src/processors/mock_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ use rand::Rng;
use socketioxide::SocketIo;
use tracing::warn;

use super::ClientData;
use super::{
mock_data::{BASE_MOCK_DATA, BASE_MOCK_STRING_DATA},
ClientData,
};

#[derive(Clone, Copy)]
struct MockData {
name: &'static str,
unit: &'static str,
num_of_vals: u8,
min: f64,
max: f64,
pub struct MockData {
pub name: &'static str,
pub unit: &'static str,
pub num_of_vals: u8,
pub min: f64,
pub max: f64,
}

impl MockData {
Expand All @@ -32,148 +35,13 @@ impl MockData {
}
}

const BASE_MOCK_DATA: [MockData; 17] = [
MockData {
name: "Status-Temp_Average",
unit: "C",
num_of_vals: 1,
min: -20.0,
max: 54.0,
},
MockData {
name: "Temps-Motor_Temperature",
unit: "C",
num_of_vals: 1,
min: -20.0,
max: 54.0,
},
MockData {
name: "Pack-SOC",
unit: "%",
num_of_vals: 1,
min: 0.0,
max: 100.0,
},
MockData {
name: "Sense-Accel",
unit: "G",
num_of_vals: 3,
min: -6.0,
max: 6.0,
},
MockData {
name: "GPS-Location",
unit: "coordinates",
num_of_vals: 2,
min: -90.0,
max: 90.0,
},
MockData {
name: "Sense-SteeringAngle",
unit: "degrees",
num_of_vals: 1,
min: 0.0,
max: 360.0,
},
MockData {
name: "Pack-Voltage",
unit: "V",
num_of_vals: 1,
min: 0.0,
max: 5.0,
},
MockData {
name: "OnBoard-CpuUsage",
unit: "%",
num_of_vals: 1,
min: 0.0,
max: 100.0,
},
MockData {
name: "OnBoard-CpuTemp",
unit: "C",
num_of_vals: 1,
min: 0.0,
max: 100.0,
},
MockData {
name: "OnBoard-MemAvailable",
unit: "mb",
num_of_vals: 1,
min: 0.0,
max: 8000.0,
},
MockData {
name: "HaLow-RSSI",
unit: "dbm",
num_of_vals: 1,
min: -150.0,
max: 80.0,
},
MockData {
name: "HaLow-StaMCS",
unit: "",
num_of_vals: 1,
min: 0.0,
max: 10.0,
},
MockData {
name: "Status/MPH",
unit: "mph",
num_of_vals: 1,
min: 0.0,
max: 88.0,
},
MockData {
name: "Pack-CCL",
unit: "A",
num_of_vals: 1,
min: -35.0,
max: 0.0,
},
MockData {
name: "Pack-DCL",
unit: "A",
num_of_vals: 1,
min: 0.0,
max: 550.0,
},
MockData {
name: "Pedals-Brake1",
unit: "",
num_of_vals: 1,
min: 0.0,
max: 3000.0,
},
MockData {
name: "Power-AC_Current",
unit: "A",
num_of_vals: 1,
min: 0.0,
max: 600.0,
},
];

#[derive(Clone, Copy)]
struct MockStringData {
name: &'static str,
unit: &'static str,
vals: &'static str,
pub struct MockStringData {
pub name: &'static str,
pub unit: &'static str,
pub vals: &'static str,
}

const BASE_MOCK_STRING_DATA: [MockStringData; 2] = [
MockStringData {
name: "Driver",
unit: "String",
vals: "Fergus",
},
MockStringData {
name: "Location",
unit: "String",
vals: "Max",
},
];

pub struct MockProcessor {
curr_run: i32,
io: SocketIo,
Expand Down
1 change: 1 addition & 0 deletions scylla-server-rust/src/processors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod db_handler;
mod mock_data;
pub mod mock_processor;
pub mod mqtt_processor;

Expand Down

0 comments on commit d464d2d

Please sign in to comment.