Skip to content

Commit

Permalink
Update NPU links on every refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
nokyan committed Feb 22, 2025
1 parent 1287d48 commit 553a282
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ui/pages/npu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ impl ResNPU {

imp.driver_used.set_subtitle(&npu.driver());

if let Ok(link) = npu.link() {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

if let Ok(model_name) = npu.name() {
imp.set_tab_detail_string(&model_name);
}
Expand All @@ -252,6 +246,7 @@ impl ResNPU {
power_usage,
power_cap,
power_cap_max,
link,
} = npu_data;

let mut usage_percentage_string = usage_fraction.map_or_else(
Expand Down Expand Up @@ -366,6 +361,12 @@ impl ResNPU {
imp.temperature.set_subtitle(&i18n("N/A"));
}

if let Some(link) = link {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

self.set_property("tab_usage_string", &usage_percentage_string);
}
}
5 changes: 5 additions & 0 deletions src/utils/npu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct NpuData {
pub power_usage: Option<f64>,
pub power_cap: Option<f64>,
pub power_cap_max: Option<f64>,

pub link: Option<Link>,
}

impl NpuData {
Expand All @@ -65,6 +67,8 @@ impl NpuData {
let power_cap = npu.power_cap().ok();
let power_cap_max = npu.power_cap_max().ok();

let link = npu.link().ok();

let npu_data = Self {
pci_slot,
usage_fraction,
Expand All @@ -76,6 +80,7 @@ impl NpuData {
power_usage,
power_cap,
power_cap_max,
link,
};

trace!("Gathered NPU data for {}: {npu_data:?}", pci_slot);
Expand Down

0 comments on commit 553a282

Please sign in to comment.