|
|
|
@@ -306,10 +306,26 @@ pub enum FaultComponent {
|
|
|
|
|
pub struct Fault {
|
|
|
|
|
pub component: FaultComponent,
|
|
|
|
|
pub message: String,
|
|
|
|
|
/// Firmware's numeric error code for this message, or 0 when none. Shown in
|
|
|
|
|
/// the tooltip alongside the text (round 17 R2) so an operator can look the
|
|
|
|
|
/// code up.
|
|
|
|
|
pub code: u64,
|
|
|
|
|
/// True for Error severity; false for Warning. (Info is dropped upstream.)
|
|
|
|
|
pub is_error: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Fault {
|
|
|
|
|
/// The tooltip line for this fault: the message, with the firmware error code
|
|
|
|
|
/// appended when there is one (round 17 R2).
|
|
|
|
|
pub fn display_line(&self) -> String {
|
|
|
|
|
if self.code != 0 {
|
|
|
|
|
format!("{} (code {})", self.message, self.code)
|
|
|
|
|
} else {
|
|
|
|
|
self.message.clone()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// One component's health for the Health icon column (round 13 #3). Rendered as a
|
|
|
|
|
/// coloured icon: grey = unreachable / not detected, red = detected but not
|
|
|
|
|
/// functioning, yellow = functioning sub-optimally, green = fully functioning.
|
|
|
|
@@ -394,9 +410,18 @@ pub struct MinerRow {
|
|
|
|
|
// performance
|
|
|
|
|
pub hashrate_ths: f64,
|
|
|
|
|
pub expected_ths: f64,
|
|
|
|
|
/// Per-hashboard hashrate in TH/s, index-aligned with the hashboards (index 0
|
|
|
|
|
/// = board 1). Drives the per-board Health tooltip (round 17 R2). Empty when
|
|
|
|
|
/// the firmware reports no per-board hashrate.
|
|
|
|
|
pub board_hashrates: Vec<f64>,
|
|
|
|
|
#[allow(dead_code)] // retained for the "slow" band; not shown as its own column
|
|
|
|
|
pub efficiency: f64,
|
|
|
|
|
pub power_w: f64,
|
|
|
|
|
/// PSU output voltage/current, when the firmware reports them (round 17 R2 /
|
|
|
|
|
/// roadmap G15). `None` until the PSU-info scan lands; the power tooltip then
|
|
|
|
|
/// shows "V / A" for a healthy PSU instead of a bare "PSU OK".
|
|
|
|
|
pub psu_out_voltage_v: Option<f64>,
|
|
|
|
|
pub psu_out_current_a: Option<f64>,
|
|
|
|
|
pub tuning_percent: Option<u8>,
|
|
|
|
|
// thermal / cooling
|
|
|
|
|
/// Average chip temperature (used for sorting/colour banding of the
|
|
|
|
@@ -625,7 +650,7 @@ impl MinerRow {
|
|
|
|
|
self.faults
|
|
|
|
|
.iter()
|
|
|
|
|
.filter(|f| f.component == component)
|
|
|
|
|
.map(|f| f.message.clone())
|
|
|
|
|
.map(|f| f.display_line())
|
|
|
|
|
.collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -635,7 +660,7 @@ impl MinerRow {
|
|
|
|
|
self.faults
|
|
|
|
|
.iter()
|
|
|
|
|
.filter(|f| matches!(f.component, FaultComponent::Other | FaultComponent::Control))
|
|
|
|
|
.map(|f| f.message.clone())
|
|
|
|
|
.map(|f| f.display_line())
|
|
|
|
|
.collect()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -646,84 +671,86 @@ impl MinerRow {
|
|
|
|
|
/// reports for that component.
|
|
|
|
|
pub fn health_tooltips(&self, max_fans: usize, max_boards: usize) -> Vec<String> {
|
|
|
|
|
let mut tips: Vec<String> = Vec::with_capacity(2 + max_fans + max_boards);
|
|
|
|
|
// Power -- the bolt icon carries any power-supply faults (round 16 #2).
|
|
|
|
|
// Power (bolt). A working PSU shows its output voltage + amperage when the
|
|
|
|
|
// firmware reports them (else a short OK); a faulted one shows the error
|
|
|
|
|
// and code instead (round 17 R2). asic-rs does not yet surface PSU output
|
|
|
|
|
// V/A (roadmap G15), so `psu_output` is None until that lands and the OK
|
|
|
|
|
// branch shows just the status.
|
|
|
|
|
let power_faults = self.fault_texts_for(FaultComponent::Power);
|
|
|
|
|
let mut power = format!(
|
|
|
|
|
"Power supply: {}",
|
|
|
|
|
match self.power_health() {
|
|
|
|
|
CompHealth::Ok => "OK (drawing power)",
|
|
|
|
|
CompHealth::Down if !power_faults.is_empty() => "fault reported",
|
|
|
|
|
CompHealth::Down => "detected but not delivering",
|
|
|
|
|
CompHealth::Degraded => "sub-optimal",
|
|
|
|
|
CompHealth::Unreachable => "unknown (no wattage/PSU-fan reported)",
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
for e in &power_faults {
|
|
|
|
|
power.push('\n');
|
|
|
|
|
power.push_str(e);
|
|
|
|
|
if !power_faults.is_empty() {
|
|
|
|
|
tips.push(power_faults.join("\n"));
|
|
|
|
|
} else {
|
|
|
|
|
tips.push(match (self.power_health(), self.psu_output_label()) {
|
|
|
|
|
(CompHealth::Ok, Some(va)) => va,
|
|
|
|
|
(CompHealth::Ok, None) => "PSU OK".to_string(),
|
|
|
|
|
(CompHealth::Degraded, _) => "PSU sub-optimal".to_string(),
|
|
|
|
|
(CompHealth::Down, _) => "PSU not delivering".to_string(),
|
|
|
|
|
(CompHealth::Unreachable, _) => "PSU unknown".to_string(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
tips.push(power);
|
|
|
|
|
// Control board -- also carries the miner's un-attributed / control faults.
|
|
|
|
|
let mut ctl = format!(
|
|
|
|
|
"Control board: {}",
|
|
|
|
|
match self.control_health() {
|
|
|
|
|
CompHealth::Ok => "OK (miner reachable)",
|
|
|
|
|
CompHealth::Degraded => "miner-level fault",
|
|
|
|
|
CompHealth::Down => "fault reported",
|
|
|
|
|
CompHealth::Unreachable => "unknown",
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
for e in self.general_fault_texts() {
|
|
|
|
|
ctl.push('\n');
|
|
|
|
|
ctl.push_str(&e);
|
|
|
|
|
// Control board (brain) -- its own and the miner's un-attributed faults
|
|
|
|
|
// with codes; a short OK when clean.
|
|
|
|
|
let ctl_faults = self.general_fault_texts();
|
|
|
|
|
if !ctl_faults.is_empty() {
|
|
|
|
|
tips.push(ctl_faults.join("\n"));
|
|
|
|
|
} else {
|
|
|
|
|
tips.push(match self.control_health() {
|
|
|
|
|
CompHealth::Ok => "Control board OK".to_string(),
|
|
|
|
|
_ => "Control board fault".to_string(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
tips.push(ctl);
|
|
|
|
|
// Fans.
|
|
|
|
|
// Fans -- just the RPM, unless the fan has a fault (then the error+code).
|
|
|
|
|
let fans = self.fan_healths();
|
|
|
|
|
for i in 0..max_fans {
|
|
|
|
|
let s = match fans.get(i) {
|
|
|
|
|
Some(CompHealth::Ok) => {
|
|
|
|
|
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
|
|
|
|
format!("spinning{rpm}")
|
|
|
|
|
let fault = self.fault_texts_for(FaultComponent::Fan(i));
|
|
|
|
|
let t = if !fault.is_empty() {
|
|
|
|
|
fault.join("\n")
|
|
|
|
|
} else {
|
|
|
|
|
match fans.get(i) {
|
|
|
|
|
Some(_) => format!("{:.0} rpm", self.fan_rpms.get(i).copied().unwrap_or(0.0)),
|
|
|
|
|
None => String::new(), // padding slot for fleet alignment
|
|
|
|
|
}
|
|
|
|
|
Some(CompHealth::Degraded) => {
|
|
|
|
|
let rpm = self.fan_rpms.get(i).map(|r| format!(" ({:.0} rpm)", r)).unwrap_or_default();
|
|
|
|
|
format!("slow{rpm}")
|
|
|
|
|
}
|
|
|
|
|
Some(CompHealth::Down) => "stopped (0 rpm)".to_string(),
|
|
|
|
|
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
|
|
|
|
None => "not present".to_string(),
|
|
|
|
|
};
|
|
|
|
|
let mut t = format!("Fan {}: {s}", i + 1);
|
|
|
|
|
for e in self.fault_texts_for(FaultComponent::Fan(i)) {
|
|
|
|
|
t.push('\n');
|
|
|
|
|
t.push_str(&e);
|
|
|
|
|
}
|
|
|
|
|
tips.push(t);
|
|
|
|
|
}
|
|
|
|
|
// Hashboards. When the PSU has failed the boards can't be tested, so they
|
|
|
|
|
// read "unpowered" (grey) rather than "faulted" (round 16 #2/#3).
|
|
|
|
|
// Hashboards -- an operating board shows its number (counting DOWN, n-1..0,
|
|
|
|
|
// left to right) and hashrate; a faulted board shows its error+code; a
|
|
|
|
|
// board the failed PSU left untested shows "unpowered" (round 17 R2,
|
|
|
|
|
// round 16 #2/#3). No generic "Hashboard N: faulted" prose.
|
|
|
|
|
let boards = self.board_healths();
|
|
|
|
|
let psu_down = self.power_supply_faulted();
|
|
|
|
|
let n = self.hashboards.map(|v| v as usize).unwrap_or(boards.len());
|
|
|
|
|
for i in 0..max_boards {
|
|
|
|
|
let s = match boards.get(i) {
|
|
|
|
|
Some(CompHealth::Ok) => "hashing".to_string(),
|
|
|
|
|
Some(CompHealth::Degraded) => "hashing sub-optimally".to_string(),
|
|
|
|
|
Some(CompHealth::Down) => "faulted".to_string(),
|
|
|
|
|
Some(CompHealth::Unreachable) if psu_down => "unpowered (PSU fault)".to_string(),
|
|
|
|
|
Some(CompHealth::Unreachable) => "expected but not detected".to_string(),
|
|
|
|
|
None => "not present".to_string(),
|
|
|
|
|
let fault = self.fault_texts_for(FaultComponent::Board(i));
|
|
|
|
|
let t = if !fault.is_empty() {
|
|
|
|
|
fault.join("\n")
|
|
|
|
|
} else if matches!(boards.get(i), Some(CompHealth::Unreachable)) && psu_down {
|
|
|
|
|
"unpowered (PSU fault)".to_string()
|
|
|
|
|
} else if i < n {
|
|
|
|
|
let num = n - 1 - i; // count down, left to right
|
|
|
|
|
match self.board_hashrates.get(i).copied() {
|
|
|
|
|
Some(hr) if hr > 0.0 => format!("{num} \u{00b7} {hr:.1} TH/s"),
|
|
|
|
|
_ => num.to_string(),
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
String::new() // padding slot for fleet alignment
|
|
|
|
|
};
|
|
|
|
|
let mut t = format!("Hashboard {}: {s}", i + 1);
|
|
|
|
|
for e in self.fault_texts_for(FaultComponent::Board(i)) {
|
|
|
|
|
t.push('\n');
|
|
|
|
|
t.push_str(&e);
|
|
|
|
|
}
|
|
|
|
|
tips.push(t);
|
|
|
|
|
}
|
|
|
|
|
tips
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The PSU output "V / A" tooltip label when the firmware reports it, else
|
|
|
|
|
/// None. asic-rs does not yet expose PSU output voltage/current (roadmap G15),
|
|
|
|
|
/// so this is a forward-compatible hook that stays None for now (round 17 R2).
|
|
|
|
|
fn psu_output_label(&self) -> Option<String> {
|
|
|
|
|
match (self.psu_out_voltage_v, self.psu_out_current_a) {
|
|
|
|
|
(Some(v), Some(a)) if v > 0.0 => Some(format!("{v:.1} V \u{00b7} {a:.1} A")),
|
|
|
|
|
(Some(v), None) if v > 0.0 => Some(format!("{v:.1} V")),
|
|
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Compact plain-text summary of component health (round 13 #3), used as the
|
|
|
|
|
/// Health column's filter/sort-fallback text and the base of its hover
|
|
|
|
|
/// tooltip. e.g. "power ok, fans 3/4, boards 3/3".
|
|
|
|
@@ -1654,6 +1681,7 @@ mod tests {
|
|
|
|
|
let fault = |c: FaultComponent, m: &str| Fault {
|
|
|
|
|
component: c,
|
|
|
|
|
message: m.to_string(),
|
|
|
|
|
code: 0,
|
|
|
|
|
is_error: true,
|
|
|
|
|
};
|
|
|
|
|
let r = MinerRow {
|
|
|
|
@@ -1696,6 +1724,41 @@ mod tests {
|
|
|
|
|
assert!(ptips[2 + 2].contains("unpowered")); // first board tooltip
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn health_tooltips_are_bare_data_round17_r2() {
|
|
|
|
|
// R2: operating boards show their number counting DOWN (n-1..0) left to
|
|
|
|
|
// right plus hashrate; fans show just RPM; a fault shows the message with
|
|
|
|
|
// its code; no "Hashboard N: faulted" prose.
|
|
|
|
|
let r = MinerRow {
|
|
|
|
|
is_mining: true,
|
|
|
|
|
hashboards: Some(3),
|
|
|
|
|
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Fault],
|
|
|
|
|
board_hashrates: vec![33.5, 34.6, 0.0],
|
|
|
|
|
expected_fans: Some(2),
|
|
|
|
|
fan_rpms: vec![4700.0, 4650.0],
|
|
|
|
|
power_w: 3000.0,
|
|
|
|
|
faults: vec![Fault {
|
|
|
|
|
component: FaultComponent::Board(2),
|
|
|
|
|
message: "Slot 2 chip failure.".to_string(),
|
|
|
|
|
code: 540,
|
|
|
|
|
is_error: true,
|
|
|
|
|
}],
|
|
|
|
|
..Default::default()
|
|
|
|
|
};
|
|
|
|
|
let tips = r.health_tooltips(2, 3);
|
|
|
|
|
// power OK (no V/A yet), control OK, 2 fans, 3 boards.
|
|
|
|
|
assert_eq!(tips[0], "PSU OK");
|
|
|
|
|
assert_eq!(tips[1], "Control board OK");
|
|
|
|
|
assert_eq!(tips[2], "4700 rpm");
|
|
|
|
|
assert_eq!(tips[3], "4650 rpm");
|
|
|
|
|
// Boards count DOWN left->right: leftmost = 2, then 1, then 0.
|
|
|
|
|
assert!(tips[4].starts_with("2") && tips[4].contains("33.5 TH/s"), "{}", tips[4]);
|
|
|
|
|
assert!(tips[5].starts_with("1") && tips[5].contains("34.6 TH/s"), "{}", tips[5]);
|
|
|
|
|
// The faulted board shows its error WITH the code, no "Hashboard" prose.
|
|
|
|
|
assert!(tips[6].contains("Slot 2 chip failure.") && tips[6].contains("540"), "{}", tips[6]);
|
|
|
|
|
assert!(!tips[6].to_lowercase().contains("hashboard"), "{}", tips[6]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn kpis_match_expected_hardware_output() {
|
|
|
|
|
// This does not hardcode fixture counts: it independently recomputes
|
|
|
|
|