Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fea3becf6 |
@@ -106,6 +106,37 @@ impl Board {
|
||||
tuning: self.mining,
|
||||
firmware_flash,
|
||||
},
|
||||
// Demo values for the round-8 columns (synthetic, so the columns
|
||||
// show variety offline).
|
||||
control_board: if self.model.contains("S17") {
|
||||
"Xilinx".to_string()
|
||||
} else if self.model.contains("S19j") || self.model.contains("S19k") {
|
||||
"AMLogic".to_string()
|
||||
} else if self.model.contains("S19") {
|
||||
"BeagleBone Black".to_string()
|
||||
} else if self.model.contains("S21") {
|
||||
"CVITek".to_string()
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
pic_present: if self.model.contains("S21") {
|
||||
Some(false) // noPIC example
|
||||
} else if self.model.starts_with("Antminer") {
|
||||
Some(true)
|
||||
} else {
|
||||
None // WhatsMiner: unknown over the network
|
||||
},
|
||||
// Access: idle/view-only units (no worker) shown locked; the rest
|
||||
// unlocked. (Live rows infer this from control capabilities.)
|
||||
write_locked: Some(self.worker.is_empty()),
|
||||
errors: if self.model.contains("S21 Pro") {
|
||||
vec![
|
||||
"[Warning] hashrate 70% below expected".to_string(),
|
||||
"[Warning] chip temperature high (HashBoard 2)".to_string(),
|
||||
]
|
||||
} else {
|
||||
Vec::new()
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +212,18 @@ impl MinerCaps {
|
||||
pub fn is_empty(self) -> bool {
|
||||
self == MinerCaps::default()
|
||||
}
|
||||
|
||||
/// Whether the miner exposes any writable control action at all. Used to
|
||||
/// infer the "Access" (locked/unlocked) column: no control -> view-only.
|
||||
pub fn any_control(self) -> bool {
|
||||
self.fault_light
|
||||
|| self.restart
|
||||
|| self.pause
|
||||
|| self.resume
|
||||
|| self.power_limit
|
||||
|| self.tuning
|
||||
|| self.firmware_flash
|
||||
}
|
||||
}
|
||||
|
||||
/// One miner's telemetry snapshot, flattened from asic-rs `MinerData` into the
|
||||
@@ -231,6 +243,19 @@ pub struct MinerRow {
|
||||
pub firmware: String,
|
||||
pub api_version: String,
|
||||
pub control_board: String,
|
||||
/// Whether the hashboards carry a PIC MCU. asic-rs does not report this over
|
||||
/// the network, so it is a best-effort inference (model-string heuristic):
|
||||
/// `None` = unknown, `Some(true)` = PIC, `Some(false)` = noPIC. True
|
||||
/// detection needs an on-board SSH/I2C probe (a separate feature).
|
||||
pub pic_present: Option<bool>,
|
||||
/// Whether this miner is locked to view-only (no command writes). Inferred
|
||||
/// from whether any control capability is available: `None` = unknown,
|
||||
/// `Some(true)` = locked, `Some(false)` = unlocked/writable.
|
||||
pub write_locked: Option<bool>,
|
||||
/// Structured error/event lines from the miner (severity + text), most
|
||||
/// severe first. Empty means none. The Error column shows a summary; the
|
||||
/// full list is the hover tooltip (added with the tooltip bridge support).
|
||||
pub errors: Vec<String>,
|
||||
// performance
|
||||
pub hashrate_ths: f64,
|
||||
pub expected_ths: f64,
|
||||
@@ -344,6 +369,9 @@ pub enum Column {
|
||||
Serial,
|
||||
ApiVersion,
|
||||
ControlBoard,
|
||||
Pic,
|
||||
Locked,
|
||||
Error,
|
||||
Uptime,
|
||||
Light,
|
||||
OperatingState,
|
||||
@@ -361,7 +389,7 @@ pub enum Column {
|
||||
|
||||
/// Every column, in registry order. Ip first, then the default-visible set
|
||||
/// (UI-SPEC order), then all remaining metrics.
|
||||
pub const ALL_COLUMNS: [Column; 35] = [
|
||||
pub const ALL_COLUMNS: [Column; 38] = [
|
||||
Column::Ip,
|
||||
Column::Hashrate,
|
||||
Column::Power,
|
||||
@@ -384,6 +412,9 @@ pub const ALL_COLUMNS: [Column; 35] = [
|
||||
Column::Serial,
|
||||
Column::ApiVersion,
|
||||
Column::ControlBoard,
|
||||
Column::Pic,
|
||||
Column::Locked,
|
||||
Column::Error,
|
||||
Column::Uptime,
|
||||
Column::Light,
|
||||
Column::OperatingState,
|
||||
@@ -436,8 +467,11 @@ impl Column {
|
||||
Column::Serial => "Serial",
|
||||
Column::ApiVersion => "API ver",
|
||||
Column::ControlBoard => "Control board",
|
||||
Column::Pic => "PIC",
|
||||
Column::Locked => "Access",
|
||||
Column::Error => "Errors",
|
||||
Column::Uptime => "Uptime",
|
||||
Column::Light => "Fault light",
|
||||
Column::Light => "Light",
|
||||
Column::OperatingState => "State",
|
||||
Column::BestShare => "Best share",
|
||||
Column::SessionBestShare => "Session best",
|
||||
@@ -469,6 +503,9 @@ impl Column {
|
||||
Column::Mac | Column::Hostname | Column::Serial => 150,
|
||||
Column::ApiVersion | Column::Light => 90,
|
||||
Column::ControlBoard => 130,
|
||||
Column::Pic => 70,
|
||||
Column::Locked => 90,
|
||||
Column::Error => 160,
|
||||
Column::Uptime => 100,
|
||||
Column::OperatingState => 100,
|
||||
Column::BestShare | Column::SessionBestShare => 110,
|
||||
@@ -607,6 +644,21 @@ impl Column {
|
||||
Column::Serial => r.serial.clone(),
|
||||
Column::ApiVersion => r.api_version.clone(),
|
||||
Column::ControlBoard => r.control_board.clone(),
|
||||
Column::Pic => match r.pic_present {
|
||||
Some(true) => "PIC".to_string(),
|
||||
Some(false) => "noPIC".to_string(),
|
||||
None => "?".to_string(),
|
||||
},
|
||||
Column::Locked => match r.write_locked {
|
||||
Some(true) => "locked".to_string(),
|
||||
Some(false) => "unlocked".to_string(),
|
||||
None => "?".to_string(),
|
||||
},
|
||||
Column::Error => match r.errors.len() {
|
||||
0 => String::new(),
|
||||
1 => r.errors[0].clone(),
|
||||
n => format!("{n} errors"),
|
||||
},
|
||||
Column::Status => r.status().to_string(),
|
||||
Column::Uptime => format_uptime(r.uptime_secs),
|
||||
Column::Light => match r.light_flashing {
|
||||
@@ -1134,6 +1186,39 @@ mod tests {
|
||||
assert_eq!(format_uptime(90_061), "1d 1h");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pic_locked_error_columns_render() {
|
||||
// PIC (best-effort): known -> PIC/noPIC, unknown -> "?".
|
||||
let pic = MinerRow { pic_present: Some(true), ..Default::default() };
|
||||
let nopic = MinerRow { pic_present: Some(false), ..Default::default() };
|
||||
let pic_unknown = MinerRow { pic_present: None, ..Default::default() };
|
||||
assert_eq!(Column::Pic.cell(&pic), "PIC");
|
||||
assert_eq!(Column::Pic.cell(&nopic), "noPIC");
|
||||
assert_eq!(Column::Pic.cell(&pic_unknown), "?");
|
||||
|
||||
// Access column.
|
||||
let locked = MinerRow { write_locked: Some(true), ..Default::default() };
|
||||
let unlocked = MinerRow { write_locked: Some(false), ..Default::default() };
|
||||
assert_eq!(Column::Locked.cell(&locked), "locked");
|
||||
assert_eq!(Column::Locked.cell(&unlocked), "unlocked");
|
||||
assert_eq!(Column::Locked.cell(&MinerRow::default()), "?");
|
||||
|
||||
// Error column: blank / single message / count.
|
||||
let none = MinerRow { errors: vec![], ..Default::default() };
|
||||
let one = MinerRow { errors: vec!["[Error] boom".into()], ..Default::default() };
|
||||
let many = MinerRow { errors: vec!["a".into(), "b".into(), "c".into()], ..Default::default() };
|
||||
assert_eq!(Column::Error.cell(&none), "");
|
||||
assert_eq!(Column::Error.cell(&one), "[Error] boom");
|
||||
assert_eq!(Column::Error.cell(&many), "3 errors");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn caps_any_control() {
|
||||
assert!(!MinerCaps::default().any_control(), "no caps -> view-only");
|
||||
assert!(MinerCaps { restart: true, ..Default::default() }.any_control());
|
||||
assert!(MinerCaps { firmware_flash: true, ..Default::default() }.any_control());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ip_column_sorts_numerically() {
|
||||
// A plain string sort puts "10.255.1.10" before "10.255.1.2"; the IP
|
||||
|
||||
@@ -397,6 +397,34 @@ pub fn start_scan(lines: Vec<String>) -> ScanHandle {
|
||||
ScanHandle { rx, cancel }
|
||||
}
|
||||
|
||||
/// Flatten a miner's structured messages into display lines, most severe first
|
||||
/// ("[Error] text (component)"), for the Errors column + hover tooltip.
|
||||
fn summarize_messages(messages: &[asic_rs::core::data::message::MinerMessage]) -> Vec<String> {
|
||||
use asic_rs::core::data::message::MessageSeverity;
|
||||
let rank = |s: &MessageSeverity| match s {
|
||||
MessageSeverity::Error => 0u8,
|
||||
MessageSeverity::Warning => 1,
|
||||
MessageSeverity::Info => 2,
|
||||
};
|
||||
let mut ranked: Vec<(u8, String)> = messages
|
||||
.iter()
|
||||
.map(|m| {
|
||||
let sev = match m.severity {
|
||||
MessageSeverity::Error => "Error",
|
||||
MessageSeverity::Warning => "Warning",
|
||||
MessageSeverity::Info => "Info",
|
||||
};
|
||||
let line = match &m.component {
|
||||
Some(c) => format!("[{sev}] {} ({c})", m.message),
|
||||
None => format!("[{sev}] {}", m.message),
|
||||
};
|
||||
(rank(&m.severity), line)
|
||||
})
|
||||
.collect();
|
||||
ranked.sort_by_key(|(r, _)| *r);
|
||||
ranked.into_iter().map(|(_, s)| s).collect()
|
||||
}
|
||||
|
||||
async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
let data = miner.get_data().await;
|
||||
let hashrate_ths = data
|
||||
@@ -484,10 +512,22 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
tuning: miner.supports_set_tuning_percent(),
|
||||
firmware_flash: miner.supports_upgrade_firmware(),
|
||||
};
|
||||
// PIC vs noPIC is not reported over the network by asic-rs; best-effort
|
||||
// heuristic from the model string, else unknown (true detection needs an
|
||||
// on-board SSH/I2C probe -- a separate feature).
|
||||
let pic_present = if model.to_lowercase().contains("nopic") { Some(false) } else { None };
|
||||
// Access: locked/view-only when the miner exposes no writable control at
|
||||
// all, otherwise unlocked. Inferred from capabilities (asic-rs has no direct
|
||||
// lock-state field).
|
||||
let write_locked = Some(!caps.any_control());
|
||||
let errors = summarize_messages(&data.messages);
|
||||
MinerRow {
|
||||
ip: data.ip.to_string(),
|
||||
selected: false,
|
||||
caps,
|
||||
pic_present,
|
||||
write_locked,
|
||||
errors,
|
||||
model,
|
||||
mac: data.mac.map(|m| m.to_string()).unwrap_or_default(),
|
||||
hostname: data.hostname.clone().unwrap_or_default(),
|
||||
|
||||
@@ -159,6 +159,12 @@ fn encode_temp_cell(pal: &Palette, plain: &str, temp_c: f64) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Segment-encoded single-colour cell (Access/Errors): `plain` in `color`, or
|
||||
/// the default text colour when `color` is None.
|
||||
fn encode_flag_cell(plain: &str, color: Option<(u8, u8, u8)>) -> String {
|
||||
encode_segments(&[(color, plain.to_string())])
|
||||
}
|
||||
|
||||
/// Build the segment-encoded cell text for the Cooling column: each fan's RPM
|
||||
/// gets its own grey-to-blue colour by speed, and the "/" separators between
|
||||
/// them stay in the default text colour.
|
||||
@@ -557,7 +563,7 @@ impl App {
|
||||
Some((sc, false)) if sc == c => title.push_str(" v"),
|
||||
_ => {}
|
||||
}
|
||||
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling) {
|
||||
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error) {
|
||||
// These columns show two-tone / multi-tone text (actual vs.
|
||||
// expected, or one colour per fan) via a custom renderer that
|
||||
// parses the segment-encoded cell value fill_rows writes.
|
||||
@@ -632,6 +638,19 @@ impl App {
|
||||
}
|
||||
Column::ChipTemp => encode_temp_cell(&self.pal, &c.cell(r), r.chip_temp_c),
|
||||
Column::Cooling => encode_cooling_cell(&self.pal, &r.fan_rpms),
|
||||
Column::Locked => {
|
||||
// green = unlocked/writable, red = locked/view-only.
|
||||
let color = match r.write_locked {
|
||||
Some(true) => Some(self.pal.red),
|
||||
Some(false) => Some(self.pal.green),
|
||||
None => None,
|
||||
};
|
||||
encode_flag_cell(&c.cell(r), color)
|
||||
}
|
||||
Column::Error => {
|
||||
let color = (!r.errors.is_empty()).then_some(self.pal.red);
|
||||
encode_flag_cell(&c.cell(r), color)
|
||||
}
|
||||
_ => continue,
|
||||
};
|
||||
t.dvlc_set_cell(disp, ci, &encoded);
|
||||
@@ -2056,7 +2075,7 @@ impl App {
|
||||
for (j, c) in cols.iter().enumerate() {
|
||||
let want = c.cell(r);
|
||||
let raw = t.dvlc_get_cell(disp_row, j).unwrap_or_default();
|
||||
let got = if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling) {
|
||||
let got = if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error) {
|
||||
decode_segments_plain(&raw)
|
||||
} else {
|
||||
raw
|
||||
|
||||
Reference in New Issue
Block a user