diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-02-05 21:37:49 -0500 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-02-05 21:37:49 -0500 |
commit | 8782b327b9aae181e4fd99a8936ac9bf0a4b51a3 (patch) | |
tree | 648c4bb70393154f8098b3b67a48abd0483e1bcc /src | |
parent | a9565d21a354752ae29205ad3b18b0824874274e (diff) |
[skip travis] minor refactor of conversion fns
Diffstat (limited to 'src')
-rw-r--r-- | src/data_conversion.rs | 46 | ||||
-rw-r--r-- | src/main.rs | 12 |
2 files changed, 12 insertions, 46 deletions
diff --git a/src/data_conversion.rs b/src/data_conversion.rs index b3cc4acd..f323112e 100644 --- a/src/data_conversion.rs +++ b/src/data_conversion.rs @@ -58,41 +58,7 @@ impl From<&CpuPoint> for (f64, f64) { } } -pub fn convert_all(app: &App, current_data: &data_farmer::DataCollection) { - let current_time = current_data.current_instant; - - // Network - let network_data: ConvertedNetworkData = ConvertedNetworkData::default(); - let network_data_rx: Vec<(f64, f64)> = Vec::new(); - let network_data_tx: Vec<(f64, f64)> = Vec::new(); - let rx_display: String = String::default(); - let tx_display: String = String::default(); - let total_rx_display: String = String::default(); - let total_tx_display: String = String::default(); - - // Disk - let mut disk_table_data: Vec<Vec<String>> = Vec::new(); - - // Temp - let temp_sensor_table_data: Vec<Vec<String>> = update_temp_row(app); - - // Mem - let mut mem_vector: Vec<(f64, f64)> = Vec::new(); - let mut swap_vector: Vec<(f64, f64)> = Vec::new(); - let memory_and_swap_labels: (String, String); - - // CPU - let mut cpu_vector: Vec<ConvertedCpuData> = Vec::new(); - - // Process - let mut process_single_list: HashMap<u32, ProcessHarvest> = HashMap::new(); - let mut process_grouped_hashmap: HashMap<String, (u32, f64, f64, Vec<u32>)> = - std::collections::HashMap::new(); - - for (time, data) in ¤t_data.timed_data_vec {} -} - -pub fn update_temp_row(app: &App) -> Vec<Vec<String>> { +pub fn convert_temp_row(app: &App) -> Vec<Vec<String>> { let mut sensor_vector: Vec<Vec<String>> = Vec::new(); let current_data = &app.data_collection; @@ -117,7 +83,7 @@ pub fn update_temp_row(app: &App) -> Vec<Vec<String>> { sensor_vector } -pub fn update_disk_row(current_data: &data_farmer::DataCollection) -> Vec<Vec<String>> { +pub fn convert_disk_row(current_data: &data_farmer::DataCollection) -> Vec<Vec<String>> { let mut disk_vector: Vec<Vec<String>> = Vec::new(); for (itx, disk) in current_data.disk_harvest.iter().enumerate() { let io_activity = if current_data.io_labels.len() > itx { @@ -153,7 +119,7 @@ pub fn update_disk_row(current_data: &data_farmer::DataCollection) -> Vec<Vec<St disk_vector } -pub fn update_cpu_data_points( +pub fn convert_cpu_data_points( show_avg_cpu: bool, current_data: &data_farmer::DataCollection, ) -> Vec<ConvertedCpuData> { let mut cpu_data_vector: Vec<ConvertedCpuData> = Vec::new(); @@ -200,7 +166,7 @@ pub fn update_cpu_data_points( cpu_data_vector } -pub fn update_mem_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> { +pub fn convert_mem_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> { let mut result: Vec<(f64, f64)> = Vec::new(); let current_time = current_data.current_instant; @@ -221,7 +187,7 @@ pub fn update_mem_data_points(current_data: &data_farmer::DataCollection) -> Vec result } -pub fn update_swap_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> { +pub fn convert_swap_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> { let mut result: Vec<(f64, f64)> = Vec::new(); let current_time = current_data.current_instant; @@ -242,7 +208,7 @@ pub fn update_swap_data_points(current_data: &data_farmer::DataCollection) -> Ve result } -pub fn update_mem_labels(current_data: &data_farmer::DataCollection) -> (String, String) { +pub fn convert_mem_labels(current_data: &data_farmer::DataCollection) -> (String, String) { let mem_label = if current_data.memory_harvest.mem_total_in_mb == 0 { "".to_string() } else { diff --git a/src/main.rs b/src/main.rs index 068a72cc..41addd79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -336,20 +336,20 @@ fn main() -> error::Result<()> { app.canvas_data.total_tx_display = network_data.total_tx_display; // Disk - app.canvas_data.disk_data = update_disk_row(&app.data_collection); + app.canvas_data.disk_data = convert_disk_row(&app.data_collection); // Temperatures - app.canvas_data.temp_sensor_data = update_temp_row(&app); + app.canvas_data.temp_sensor_data = convert_temp_row(&app); // Memory - app.canvas_data.mem_data = update_mem_data_points(&app.data_collection); - app.canvas_data.swap_data = update_swap_data_points(&app.data_collection); - let memory_and_swap_labels = update_mem_labels(&app.data_collection); + app.canvas_data.mem_data = convert_mem_data_points(&app.data_collection); + app.canvas_data.swap_data = convert_swap_data_points(&app.data_collection); + let memory_and_swap_labels = convert_mem_labels(&app.data_collection); app.canvas_data.mem_label = memory_and_swap_labels.0; app.canvas_data.swap_label = memory_and_swap_labels.1; // CPU app.canvas_data.cpu_data = - update_cpu_data_points(app.show_average_cpu, &app.data_collection); + convert_cpu_data_points(app.show_average_cpu, &app.data_collection); // Processes let (single, grouped) = convert_process_data(&app.data_collection); |