GUI round 14: bigger health icons, table zoom, pool config, op progress
Seven items from the round-14 list: #1 Health icons: render bigger (nearly the full row height) and packed tighter so a row of component icons stays large and readable; the icon sizes also scale with the new table zoom. #2 Scan timeout: a per-miner scan timeout (asic-rs identification timeout) is now configurable in the Scan-ranges dialog and persisted, so slow miners can be given longer or fast scans sped up. #3 Table zoom: a slider in the bottom-right of the status bar scales the whole table together -- font, component icons, row height, and column widths -- from 50% to 250% (default 100%). Implemented in the wx bridge (no Rust round-trip); the custom SegmentRenderer draws its text in the control's scaled font so the coloured columns zoom like the native ones, and the zoom is re-applied after a column rebuild so it survives show/ hide/reorder. #4 Operation progress: while an operation runs on a miner (refresh, config/light/power/tuning action, firmware flash, restore-to-stock, access check), its Health cell shows the progress text ("refreshing…", "restarting…", "setting pools…", …) instead of the component icons, and reverts to icons when the operation finishes. #5 Remove the SSH PIC probe: the "Detect PIC (SSH)..." right-click flow and its dialog, background probe, and pic_probe module are removed. PIC state stays a best-effort model-string heuristic in the PIC column. #6 WhatsMiner access: WhatsMiners now show the locked/unlocked padlock in the Access column instead of a blank cell -- since round 12 #8b gave the V1/V2/V3 backends their control commands, the same capability heuristic the other brands use applies to WhatsMiner too (the token access check still refines a read-only unit to "locked"). #7 Configure pools: a right-click "Configure pools..." flow (gated on the new pools capability) with three fields -- pool address and account (required) and an optional worker name. The worker name expands per miner from case-insensitive placeholders scanned from each unit: {ip1}..{ip4}, {serial}, {mac} (colons removed), {nameplate-hr} (rated TH), {brand}, {model}, {submodel}, {cpu}, {cb}, {firmware}, {hostname}. Applied via asic-rs set_pools_config on a background thread reusing the action plumbing. wx-rs bridge patches 0002/0003 regenerated. No vendored asic-rs changes. Unit tests (component health, worker-template expansion) + headless selftest pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
This commit is contained in:
@@ -134,6 +134,30 @@ pub fn decode_segments_plain(s: &str) -> String {
|
||||
.collect::<String>()
|
||||
}
|
||||
|
||||
/// Replace every case-insensitive occurrence of `placeholder` in `s` with
|
||||
/// `value` (round 14 #7 worker templates). Placeholders and the surrounding
|
||||
/// worker name are ASCII, so lowercasing preserves byte offsets; a non-ASCII
|
||||
/// input (offsets would shift) falls back to a case-sensitive replace.
|
||||
fn replace_placeholder_ci(s: &str, placeholder: &str, value: &str) -> String {
|
||||
if !s.is_ascii() {
|
||||
return s.replace(placeholder, value);
|
||||
}
|
||||
let hay = s.to_ascii_lowercase();
|
||||
let needle = placeholder.to_ascii_lowercase();
|
||||
let mut out = String::with_capacity(s.len());
|
||||
let mut last = 0usize;
|
||||
let mut from = 0usize;
|
||||
while let Some(rel) = hay[from..].find(&needle) {
|
||||
let at = from + rel;
|
||||
out.push_str(&s[last..at]);
|
||||
out.push_str(value);
|
||||
last = at + placeholder.len();
|
||||
from = last;
|
||||
}
|
||||
out.push_str(&s[last..]);
|
||||
out
|
||||
}
|
||||
|
||||
/// Split a full pool worker "account.worker" into (account, worker). Mining
|
||||
/// pools name a worker "<account>.<rig>"; split on the first '.'. With no '.',
|
||||
/// the whole string is the account and the worker name is empty.
|
||||
@@ -192,6 +216,9 @@ pub struct MinerCaps {
|
||||
/// Whether this miner's asic-rs driver supports `upgrade_firmware`
|
||||
/// (probed via `supports_upgrade_firmware()` at scan time).
|
||||
pub firmware_flash: bool,
|
||||
/// Whether this miner's driver supports writing pool configuration (probed
|
||||
/// via `supports_pools_config()` at scan time; round 14 #7).
|
||||
pub pools: bool,
|
||||
}
|
||||
|
||||
impl MinerCaps {
|
||||
@@ -205,6 +232,7 @@ impl MinerCaps {
|
||||
power_limit: self.power_limit && other.power_limit,
|
||||
tuning: self.tuning && other.tuning,
|
||||
firmware_flash: self.firmware_flash && other.firmware_flash,
|
||||
pools: self.pools && other.pools,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +261,7 @@ impl MinerCaps {
|
||||
|| self.power_limit
|
||||
|| self.tuning
|
||||
|| self.firmware_flash
|
||||
|| self.pools
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,6 +547,47 @@ impl MinerRow {
|
||||
parts.join(", ")
|
||||
}
|
||||
|
||||
/// Expand a worker-name template against this miner's scanned data (round 14
|
||||
/// #7). Placeholders are case-insensitive and wrapped in braces:
|
||||
/// {ip1}..{ip4} the four IP octets {serial} serial number
|
||||
/// {mac} MAC with ':' removed {brand} manufacturer
|
||||
/// {model} model {submodel} model sub-variant
|
||||
/// {cpu} control-board CPU {cb} control-board code
|
||||
/// {firmware} firmware family {hostname} hostname
|
||||
/// {nameplate-hr} rated hashrate in TH (integer, no unit)
|
||||
/// Unknown placeholders are left untouched so a typo is visible.
|
||||
pub fn expand_worker_template(&self, template: &str) -> String {
|
||||
let octets: Vec<&str> = self.ip.split('.').collect();
|
||||
let oct = |i: usize| octets.get(i).copied().unwrap_or("").to_string();
|
||||
let nameplate = if self.expected_ths > 0.0 {
|
||||
format!("{:.0}", self.expected_ths)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
let subs: [(&str, String); 15] = [
|
||||
("ip1", oct(0)),
|
||||
("ip2", oct(1)),
|
||||
("ip3", oct(2)),
|
||||
("ip4", oct(3)),
|
||||
("serial", self.serial.clone()),
|
||||
("mac", self.mac.replace(':', "")),
|
||||
("nameplate-hr", nameplate),
|
||||
("brand", self.brand.clone()),
|
||||
("model", self.model.clone()),
|
||||
("submodel", self.submodel.clone()),
|
||||
("cpu", self.cpu.clone()),
|
||||
("cb", self.board_code.clone()),
|
||||
("firmware", self.firmware.clone()),
|
||||
("hostname", self.hostname.clone()),
|
||||
("fw", self.firmware.clone()),
|
||||
];
|
||||
let mut out = template.to_string();
|
||||
for (key, val) in subs {
|
||||
out = replace_placeholder_ci(&out, &format!("{{{key}}}"), &val);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Upsert into `rows` by ip; returns true if the row is new.
|
||||
pub fn upsert_into(self, rows: &mut Vec<MinerRow>) -> bool {
|
||||
if let Some(r) = rows.iter_mut().find(|r| r.ip == self.ip) {
|
||||
@@ -1277,6 +1347,39 @@ mod tests {
|
||||
(rows, view, idx)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn worker_template_expands_scanned_fields() {
|
||||
// Round 14 #7: placeholders are case-insensitive; MAC drops its colons;
|
||||
// nameplate-hr is the rated hashrate in whole TH; unknown keys are kept.
|
||||
let r = MinerRow {
|
||||
ip: "10.2.3.44".into(),
|
||||
serial: "SNXYZ".into(),
|
||||
mac: "AA:BB:CC:11:22:33".into(),
|
||||
brand: "Antminer".into(),
|
||||
model: "S19j Pro".into(),
|
||||
submodel: "".into(),
|
||||
cpu: "AML".into(),
|
||||
board_code: "C76".into(),
|
||||
firmware: "VNish".into(),
|
||||
hostname: "rig-1".into(),
|
||||
expected_ths: 104.0,
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(r.expand_worker_template("{ip3}x{ip4}"), "3x44");
|
||||
assert_eq!(r.expand_worker_template("{MAC}"), "AABBCC112233");
|
||||
assert_eq!(r.expand_worker_template("{mac}"), "AABBCC112233");
|
||||
assert_eq!(r.expand_worker_template("{nameplate-hr}TH"), "104TH");
|
||||
assert_eq!(
|
||||
r.expand_worker_template("{brand}-{cpu}-{cb}-{fw}"),
|
||||
"Antminer-AML-C76-VNish"
|
||||
);
|
||||
assert_eq!(r.expand_worker_template("{serial}"), "SNXYZ");
|
||||
// Unknown placeholder is left untouched.
|
||||
assert_eq!(r.expand_worker_template("w-{bogus}"), "w-{bogus}");
|
||||
// A plain worker name with no placeholders is unchanged.
|
||||
assert_eq!(r.expand_worker_template("worker1"), "worker1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn component_health_maps_states_to_the_four_levels() {
|
||||
// Round 13 #3: power/control/fan/board health map to the grey/red/yellow/
|
||||
@@ -1901,6 +2004,7 @@ mod tests {
|
||||
power_limit: true,
|
||||
tuning: true,
|
||||
firmware_flash: true,
|
||||
pools: true,
|
||||
};
|
||||
let idle = MinerCaps { fault_light: true, restart: true, ..Default::default() };
|
||||
// Two full miners keep every action.
|
||||
|
||||
Reference in New Issue
Block a user