Skip to content

Commit

Permalink
fix some things for some platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Jan 20, 2025
1 parent fbbd100 commit 408e81c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ impl App {
pub fn update_data(&mut self) {
let data_source = self.data_store.get_data();

// FIXME: (points_rework_v1) maybe separate PR but would it make more sense to store references of data?
// Would it also make more sense to move the "data set" step to the draw step, and make it only set if force
// update is set here?
for proc in self.states.proc_state.widget_states.values_mut() {
if proc.force_update_data {
proc.set_table_data(data_source);
Expand All @@ -173,7 +176,7 @@ impl App {

for disk in self.states.disk_state.widget_states.values_mut() {
if disk.force_update_data {
disk.set_table_data(data_source); // FIXME: (points_rework_v1) do more work when eating data, not in set table data
disk.set_table_data(data_source); // FIXME: (points_rework_v1) do more work when eating data, not in set table data; maybe separate PR
disk.force_update_data = false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/data/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use crate::{
use super::{ProcessData, TimeSeriesData};

/// A collection of data. This is where we dump data into.
///
/// TODO: Maybe reduce visibility of internal data, make it only accessible through DataStore?
#[derive(Debug, Clone)]
pub struct StoredData {
pub current_instant: Instant, // FIXME: (points_rework_v1) remove this?
Expand Down
1 change: 1 addition & 0 deletions src/app/data/time_series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
vec::Vec,
};

#[cfg(feature = "gpu")]
use hashbrown::{HashMap, HashSet}; // TODO: Try fxhash again.
use timeless::data::ChunkedData;

Expand Down
3 changes: 1 addition & 2 deletions src/canvas/widgets/mem_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::borrow::Cow;

use tui::{
layout::{Constraint, Direction, Layout, Rect},
style::Style,
Frame,
};

Expand Down Expand Up @@ -137,7 +136,7 @@ impl Painter {

let style = {
if gpu_styles.is_empty() {
Style::default()
tui::style::Style::default()
} else {
let colour = gpu_styles[colour_index % gpu_styles.len()];
colour_index += 1;
Expand Down
2 changes: 2 additions & 0 deletions src/data_collection.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! This is the main file to house data collection functions.
//!
//! TODO: Rename this to intake?
#[cfg(feature = "nvidia")]
pub mod nvidia;
Expand Down
19 changes: 12 additions & 7 deletions src/data_collection/temperature/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use crate::app::filter::Filter;
pub fn get_temperature_data(
components: &sysinfo::Components, temp_type: &TemperatureType, filter: &Option<Filter>,
) -> Result<Option<Vec<TempHarvest>>> {
let mut temperature_vec: Vec<TempHarvest> = Vec::new();
let mut temperatures: Vec<TempHarvest> = Vec::new();

for component in components {
let name = component.label().to_string();

if Filter::optional_should_keep(filter, &name) {
temperature_vec.push(TempHarvest {
temperatures.push(TempHarvest {
name,
temperature: Some(temp_type.convert_temp_unit(component.temperature())),
});
Expand All @@ -25,19 +25,24 @@ pub fn get_temperature_data(
// sensors.
#[cfg(target_os = "freebsd")]
{
use super::TypedTemperature;
use sysctl::Sysctl;

const KEY: &str = "hw.temperature";
if let Ok(root) = sysctl::Ctl::new(KEY) {
for ctl in sysctl::CtlIter::below(root).flatten() {
if let (Ok(name), Ok(temp)) = (ctl.name(), ctl.value()) {
if let Some(temp) = temp.as_temperature() {
temperature_vec.push(TempHarvest {
temperatures.push(TempHarvest {
name,
temperature: Some(match temp_type {
TemperatureType::Celsius => temp.celsius(),
TemperatureType::Kelvin => temp.kelvin(),
TemperatureType::Fahrenheit => temp.fahrenheit(),
TemperatureType::Celsius => {
TypedTemperature::Celsius(temp.celsius())
}
TemperatureType::Kelvin => TypedTemperature::Kelvin(temp.kelvin()),
TemperatureType::Fahrenheit => {
TypedTemperature::Fahrenheit(temp.fahrenheit())
}
}),
});
}
Expand All @@ -47,5 +52,5 @@ pub fn get_temperature_data(
}

// TODO: Should we instead use a hashmap -> vec to skip dupes?
Ok(Some(temperature_vec))
Ok(Some(temperatures))
}
1 change: 1 addition & 0 deletions src/widgets/mem_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl MemWidgetState {
cache_points_cache: vec![],
#[cfg(feature = "zfs")]
arc_points_cache: vec![],
#[cfg(feature = "gpu")]
gpu_points_cache: vec![],
}
}
Expand Down

0 comments on commit 408e81c

Please sign in to comment.