|
|
|
@@ -420,6 +420,10 @@ pub struct MinerRow {
|
|
|
|
|
/// = 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>,
|
|
|
|
|
/// Per-hashboard EXPECTED hashrate in TH/s, index-aligned with the hashboards.
|
|
|
|
|
/// The per-board tooltip shows actual / expected (round 18 #3). Empty when the
|
|
|
|
|
/// firmware reports no per-board expected hashrate.
|
|
|
|
|
pub board_expected_hashrates: Vec<f64>,
|
|
|
|
|
#[allow(dead_code)] // retained for the "slow" band; not shown as its own column
|
|
|
|
|
pub efficiency: f64,
|
|
|
|
|
pub power_w: f64,
|
|
|
|
@@ -516,12 +520,17 @@ impl MinerRow {
|
|
|
|
|
/// live); grey (unknown) otherwise -- asic-rs has no direct PSU-fault flag, so
|
|
|
|
|
/// a missing wattage reading is treated as unknown, never a false "down".
|
|
|
|
|
pub fn power_health(&self) -> CompHealth {
|
|
|
|
|
// A reported power-supply fault (round 16 #2) is authoritative: red, even
|
|
|
|
|
// if a residual wattage is still being read.
|
|
|
|
|
// A miner drawing power / spinning its PSU fan / actively mining has a live
|
|
|
|
|
// PSU regardless of any warning flag.
|
|
|
|
|
let delivering = self.power_w > 0.0 || self.psu_fan_rpm > 0.0 || self.is_mining;
|
|
|
|
|
// A reported PSU fault while the miner is actually mining is a warning, not
|
|
|
|
|
// a failure -- yellow, not red (round 18 #2: some WhatsMiners flag a PSU
|
|
|
|
|
// error while running fine). A fault on a miner that is not mining is a real
|
|
|
|
|
// failure (red).
|
|
|
|
|
if self.faults_for(FaultComponent::Power).next().is_some() {
|
|
|
|
|
return CompHealth::Down;
|
|
|
|
|
return if self.is_mining { CompHealth::Degraded } else { CompHealth::Down };
|
|
|
|
|
}
|
|
|
|
|
if self.power_w > 0.0 || self.psu_fan_rpm > 0.0 || self.is_mining {
|
|
|
|
|
if delivering {
|
|
|
|
|
CompHealth::Ok
|
|
|
|
|
} else {
|
|
|
|
|
CompHealth::Unreachable
|
|
|
|
@@ -557,12 +566,6 @@ impl MinerRow {
|
|
|
|
|
.filter(|f| f.is_error && matches!(f.component, FaultComponent::Other))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// True when the miner reports a power-supply fault, which means the
|
|
|
|
|
/// hashboards cannot be powered or evaluated (round 16 #2).
|
|
|
|
|
fn power_supply_faulted(&self) -> bool {
|
|
|
|
|
self.faults_for(FaultComponent::Power).next().is_some()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Per-fan health (round 13 #3), front-to-back / top-to-bottom in the order
|
|
|
|
|
/// the miner reports its fans. A spinning fan is green, unless it is running
|
|
|
|
|
/// well below its fastest sibling (< 50% of the max reported RPM), which is a
|
|
|
|
@@ -621,16 +624,22 @@ impl MinerRow {
|
|
|
|
|
if base.is_empty() {
|
|
|
|
|
return base;
|
|
|
|
|
}
|
|
|
|
|
// 3. A PSU fault means no board can be powered/tested -> all grey.
|
|
|
|
|
if self.power_supply_faulted() {
|
|
|
|
|
return vec![CompHealth::Unreachable; base.len()];
|
|
|
|
|
}
|
|
|
|
|
// 2. Board-specific faults are authoritative: red only the named boards,
|
|
|
|
|
// green the rest (overriding a stall-induced all-red).
|
|
|
|
|
// 2. Board-specific faults are authoritative: red the named boards. A board
|
|
|
|
|
// is grey ONLY when it is genuinely not detected (base Missing); a board
|
|
|
|
|
// that is running stays green and a faulted board is red, even when the
|
|
|
|
|
// PSU also reports a fault (round 18 #4b -- WhatsMiner codes 540/560 must
|
|
|
|
|
// show red, not grey, and boards still hashing during a PSU fault stay
|
|
|
|
|
// green). A whole-miner stall reds every board's base, so exonerate the
|
|
|
|
|
// boards the fault codes did NOT name back to healthy.
|
|
|
|
|
let board_faulted = |i: usize| self.faults_for(FaultComponent::Board(i)).next().is_some();
|
|
|
|
|
if (0..base.len()).any(board_faulted) {
|
|
|
|
|
for (i, h) in base.iter_mut().enumerate() {
|
|
|
|
|
*h = if board_faulted(i) { CompHealth::Down } else { ok };
|
|
|
|
|
if board_faulted(i) {
|
|
|
|
|
*h = CompHealth::Down;
|
|
|
|
|
} else if *h == CompHealth::Down {
|
|
|
|
|
*h = ok; // stall-reddened but not named by the fault codes
|
|
|
|
|
}
|
|
|
|
|
// else keep the base (green Ok / grey Missing).
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
base
|
|
|
|
@@ -736,22 +745,26 @@ impl MinerRow {
|
|
|
|
|
tips.push(t);
|
|
|
|
|
}
|
|
|
|
|
// 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.
|
|
|
|
|
// left to right) and actual/expected hashrate; a faulted board shows its
|
|
|
|
|
// error+code; a board that is genuinely not detected shows "not detected"
|
|
|
|
|
// (round 17 R2, round 18 #3 actual/expected + #4b). 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());
|
|
|
|
|
let unit = self.hashrate_unit();
|
|
|
|
|
for i in 0..max_boards {
|
|
|
|
|
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 matches!(boards.get(i), Some(CompHealth::Unreachable)) {
|
|
|
|
|
"not detected".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"),
|
|
|
|
|
let actual = self.board_hashrates.get(i).copied().unwrap_or(0.0);
|
|
|
|
|
let expected = self.board_expected_hashrates.get(i).copied().unwrap_or(0.0);
|
|
|
|
|
match (actual > 0.0, expected > 0.0) {
|
|
|
|
|
(true, true) => format!("{num} \u{00b7} {actual:.1} / {expected:.1} {unit}"),
|
|
|
|
|
(true, false) => format!("{num} \u{00b7} {actual:.1} {unit}"),
|
|
|
|
|
_ => num.to_string(),
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@@ -773,6 +786,17 @@ impl MinerRow {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// The display unit for this miner's hashrate, by mining algorithm (round 18
|
|
|
|
|
/// #7). SHA256/Scrypt miners report TH/s; Equihash miners (Antminer Z15 /
|
|
|
|
|
/// Zcash) report in Sol/s and must not be labelled TH/s.
|
|
|
|
|
pub fn hashrate_unit(&self) -> &'static str {
|
|
|
|
|
if self.algorithm.eq_ignore_ascii_case("equihash") {
|
|
|
|
|
"Sol/s"
|
|
|
|
|
} else {
|
|
|
|
|
"TH/s"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 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".
|
|
|
|
@@ -1290,20 +1314,14 @@ impl Column {
|
|
|
|
|
Column::Cpu => r.cpu.clone(),
|
|
|
|
|
Column::BoardCode => r.board_code.clone(),
|
|
|
|
|
Column::Algorithm => r.algorithm.clone(),
|
|
|
|
|
Column::Pic => {
|
|
|
|
|
// A per-board PIC MCU is an Antminer hashboard property; it has no
|
|
|
|
|
// meaning for WhatsMiner or any other make, which show nothing
|
|
|
|
|
// rather than a "?" that implies an unanswered Antminer question.
|
|
|
|
|
if !r.brand.eq_ignore_ascii_case("antminer") {
|
|
|
|
|
String::new()
|
|
|
|
|
} else {
|
|
|
|
|
match r.pic_present {
|
|
|
|
|
Some(true) => "PIC".to_string(),
|
|
|
|
|
Some(false) => "noPIC".to_string(),
|
|
|
|
|
None => "?".to_string(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Column::Pic => match r.pic_present {
|
|
|
|
|
// A per-board PIC MCU is a known Antminer-hashboard property. Show
|
|
|
|
|
// it only when known; anything unknown (non-Antminer makes, or an
|
|
|
|
|
// Antminer model we can't classify) is blank, never "?" (round 18 #11).
|
|
|
|
|
Some(true) => "PIC".to_string(),
|
|
|
|
|
Some(false) => "noPIC".to_string(),
|
|
|
|
|
None => String::new(),
|
|
|
|
|
},
|
|
|
|
|
Column::Locked => match r.write_locked {
|
|
|
|
|
Some(true) => "locked".to_string(),
|
|
|
|
|
Some(false) => "unlocked".to_string(),
|
|
|
|
@@ -1749,22 +1767,37 @@ mod tests {
|
|
|
|
|
assert!(board_tips[0].contains("Slot 0 error reading chip id."));
|
|
|
|
|
assert!(!board_tips[2].contains("Slot"), "board 3 has no fault text");
|
|
|
|
|
|
|
|
|
|
// Round 16 #2: a power-supply fault greys every board (they can't be
|
|
|
|
|
// powered/tested), turns the bolt red, and the PSU message shows on the
|
|
|
|
|
// power tooltip.
|
|
|
|
|
// Round 18 #2/#4b: a PSU fault while the miner is NOT mining is a real
|
|
|
|
|
// failure (red bolt), and boards keep their own reported state -- a PSU
|
|
|
|
|
// fault no longer greys them. Faulted boards stay red.
|
|
|
|
|
let psu = MinerRow {
|
|
|
|
|
power_w: 40.0,
|
|
|
|
|
board_status: vec![BoardHealth::Fault, BoardHealth::Fault, BoardHealth::Fault],
|
|
|
|
|
expected_fans: Some(2),
|
|
|
|
|
fan_rpms: vec![6000.0, 6000.0],
|
|
|
|
|
faults: vec![fault(FaultComponent::Power, "Power current error.")],
|
|
|
|
|
..Default::default()
|
|
|
|
|
..Default::default() // is_mining = false
|
|
|
|
|
};
|
|
|
|
|
assert_eq!(psu.power_health(), CompHealth::Down);
|
|
|
|
|
assert!(psu.board_healths().iter().all(|h| *h == CompHealth::Unreachable));
|
|
|
|
|
assert_eq!(psu.power_health(), CompHealth::Down); // fault + not mining -> red
|
|
|
|
|
assert!(psu.board_healths().iter().all(|h| *h == CompHealth::Down)); // faulted -> red, not grey
|
|
|
|
|
let ptips = psu.health_tooltips(2, 3);
|
|
|
|
|
assert!(ptips[0].contains("Power current error."));
|
|
|
|
|
assert!(ptips[2 + 2].contains("unpowered")); // first board tooltip
|
|
|
|
|
|
|
|
|
|
// Round 18 #2: the SAME PSU fault while the miner IS mining is a warning
|
|
|
|
|
// (yellow bolt), and running boards stay GREEN (not grey). Round 18 #4b:
|
|
|
|
|
// grey is reserved for genuinely-undetected boards.
|
|
|
|
|
let psu_running = MinerRow {
|
|
|
|
|
is_mining: true,
|
|
|
|
|
power_w: 3000.0,
|
|
|
|
|
board_status: vec![BoardHealth::Ok, BoardHealth::Ok, BoardHealth::Missing],
|
|
|
|
|
faults: vec![fault(FaultComponent::Power, "Power vout warning.")],
|
|
|
|
|
..Default::default()
|
|
|
|
|
};
|
|
|
|
|
assert_eq!(psu_running.power_health(), CompHealth::Degraded); // yellow, not red
|
|
|
|
|
let rb = psu_running.board_healths();
|
|
|
|
|
assert_eq!(rb[0], CompHealth::Ok); // running -> green despite PSU fault
|
|
|
|
|
assert_eq!(rb[1], CompHealth::Ok);
|
|
|
|
|
assert_eq!(rb[2], CompHealth::Unreachable); // only the undetected board is grey
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
@@ -2099,12 +2132,12 @@ mod tests {
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn pic_locked_error_columns_render() {
|
|
|
|
|
// PIC (best-effort): Antminer known -> PIC/noPIC, unknown Antminer -> "?".
|
|
|
|
|
// PIC: known -> PIC/noPIC; anything unknown -> blank, never "?" (round 18 #11).
|
|
|
|
|
let am = |pic| MinerRow { brand: "Antminer".into(), pic_present: pic, ..Default::default() };
|
|
|
|
|
assert_eq!(Column::Pic.cell(&am(Some(true))), "PIC");
|
|
|
|
|
assert_eq!(Column::Pic.cell(&am(Some(false))), "noPIC");
|
|
|
|
|
assert_eq!(Column::Pic.cell(&am(None)), "?");
|
|
|
|
|
// Non-Antminer makes: PIC has no meaning -> blank, never "?".
|
|
|
|
|
assert_eq!(Column::Pic.cell(&am(None)), ""); // unknown Antminer model -> blank
|
|
|
|
|
// Non-Antminer makes: PIC has no meaning -> blank.
|
|
|
|
|
let wm = MinerRow { brand: "WhatsMiner".into(), pic_present: None, ..Default::default() };
|
|
|
|
|
assert_eq!(Column::Pic.cell(&wm), "");
|
|
|
|
|
|
|
|
|
|