Compare commits

...
1 Commits
Author SHA1 Message Date
noahandClaude Opus 4.8 0d19e958f0 GUI round 15 (part 1): pool dropdowns, aligned health icons, export, more
Twelve of the round-15 items (the code items; the live-hardware flashing/
testing and the settings/localization/logs work follow separately):

#1 Configure-pools: three pool rows (address, account, worker, password),
each field with a "+" dropdown of presets (top-11 BTC pool stratums;
worker-name placeholders) plus user-addable, persisted entries. Worker
picks insert at the cursor rather than replacing. Writes up to three pools
per miner via set_pools_config, worker expanded per unit.

#2 PIC detection: replace the broken SSH i2cdump (it read 0x48, the temp
sensor, not the PIC) with a model lookup -- no firmware exposes PIC over the
network, so infer it from the model (noPIC: S19k Pro, S21 family, T21,
explicit noPIC; PIC: rest of the S19 line).

#4 Zoom: an editable percent field in the status bar (type an exact scale)
and Ctrl +/- / Ctrl+0 to zoom in/out/reset.

#5 Health icons align in fixed slots (power, control, fans, hashboards);
miners with fewer fans/boards leave a gap so hashboards still line up. The
max fan/board counts are computed parametrically from the fleet.

#6 Light: the locate-light column is on by default (last), shown as a
green-over-red beacon flashing quickly instead of a single amber dot.

#8 The bottom-left status line is now scan-only; operation progress lives in
the Health column (per miner) and failures in the bottom-right indicator.

#9 / #10 / #11: drop the Credentials-dialog blurb; move the scan-ranges
format help to a tooltip; make Restore-to-stock a plain confirmation (no
typed keyword, no warning wall).

#12 Z15 fans: the v2020 backend now reads fans from higher fan slots
(the Z15 reports fan3/fan4 with fan1/fan2 = 0). Vendored patch 0009.

#14 Export: an Export button writes every scanned data point to a CSV, one
value per cell (lists expanded to indexed columns) -- complete and
machine-readable, unlike the on-screen table.

#15 Health tooltips are per-icon: hovering a specific fan or hashboard shows
just that component's state, with errors attributed to the board that names
them in the message.

New wx-rs bridge surface: widget tooltips, save-file dialog, insert-at-cursor,
status-bar zoom entry + Ctrl+/-, the light beacon + alignment-gap sentinels,
and per-icon cell tooltips (bridge patches 0002/0003 regenerated). Unit tests
(worker templates, PIC map, CSV export, health) + headless selftest pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Djv3oncM4LxTS5tb61Ako6
2026-09-21 14:43:00 -06:00
14 changed files with 1257 additions and 245 deletions
+187
View File
@@ -0,0 +1,187 @@
//! CSV export of the full scan data (round 15 #14).
//!
//! Unlike the on-screen table (which packs several values into one cell, e.g.
//! "95T/96T" or a row of health icons), the export is one value per cell and
//! covers every scanned data point, so it is complete and machine-readable.
//! Variable-length fields (per-board temps, per-fan RPMs, per-board health, the
//! pool list) are expanded into indexed columns out to the widest miner in the
//! set, so every row has the same columns.
use crate::model::{BoardHealth, MinerRow};
/// Escape one CSV field: quote it when it contains a comma, quote, CR or LF, and
/// double any embedded quotes.
fn esc(s: &str) -> String {
if s.contains([',', '"', '\n', '\r']) {
format!("\"{}\"", s.replace('"', "\"\""))
} else {
s.to_string()
}
}
fn num(v: f64) -> String {
if v == 0.0 {
String::new()
} else if v.fract() == 0.0 {
format!("{v:.0}")
} else {
format!("{v:.3}")
}
}
fn opt_bool(v: Option<bool>, yes: &str, no: &str) -> String {
match v {
Some(true) => yes.to_string(),
Some(false) => no.to_string(),
None => String::new(),
}
}
fn board_health_str(h: &BoardHealth) -> &'static str {
match h {
BoardHealth::Ok => "ok",
BoardHealth::Fault => "fault",
BoardHealth::Missing => "missing",
}
}
/// The fixed scalar columns, in order: (header, extractor).
type Col = (&'static str, fn(&MinerRow) -> String);
fn scalar_columns() -> Vec<Col> {
vec![
("ip", |r| r.ip.clone()),
("model", |r| r.model.clone()),
("brand", |r| r.brand.clone()),
("submodel", |r| r.submodel.clone()),
("mac", |r| r.mac.clone()),
("hostname", |r| r.hostname.clone()),
("serial", |r| r.serial.clone()),
("firmware", |r| r.firmware.clone()),
("fw_version", |r| r.fw_version.clone()),
("api_version", |r| r.api_version.clone()),
("control_board", |r| r.control_board.clone()),
("cpu", |r| r.cpu.clone()),
("board_code", |r| r.board_code.clone()),
("algorithm", |r| r.algorithm.clone()),
("status", |r| r.status().to_string()),
("operating_state", |r| r.operating_state.clone()),
("is_mining", |r| r.is_mining.to_string()),
("slow", |r| r.slow.to_string()),
("paused", |r| r.paused.to_string()),
("pic", |r| opt_bool(r.pic_present, "PIC", "noPIC")),
("write_locked", |r| opt_bool(r.write_locked, "locked", "unlocked")),
("light_flashing", |r| opt_bool(r.light_flashing, "on", "off")),
("hashrate_ths", |r| num(r.hashrate_ths)),
("expected_ths", |r| num(r.expected_ths)),
("efficiency_j_th", |r| num(r.efficiency)),
("power_w", |r| num(r.power_w)),
("tuning_percent", |r| r.tuning_percent.map(|v| v.to_string()).unwrap_or_default()),
("chip_temp_c", |r| num(r.chip_temp_c)),
("fluid_temp_c", |r| num(r.fluid_temp_c)),
("env_temp_c", |r| num(r.env_temp_c)),
("outlet_temp_c", |r| num(r.outlet_temp_c)),
("psu_fan_rpm", |r| num(r.psu_fan_rpm)),
("fan_count", |r| r.fan_count.map(|v| v.to_string()).unwrap_or_default()),
("expected_fans", |r| r.expected_fans.map(|v| v.to_string()).unwrap_or_default()),
("total_chips", |r| r.total_chips.map(|v| v.to_string()).unwrap_or_default()),
("expected_chips", |r| r.expected_chips.map(|v| v.to_string()).unwrap_or_default()),
("hashboards", |r| r.hashboards.map(|v| v.to_string()).unwrap_or_default()),
("expected_hashboards", |r| r.expected_hashboards.map(|v| v.to_string()).unwrap_or_default()),
("uptime_secs", |r| if r.uptime_secs > 0 { r.uptime_secs.to_string() } else { String::new() }),
("best_share", |r| r.best_share.map(num).unwrap_or_default()),
("session_best_share", |r| r.session_best_share.map(num).unwrap_or_default()),
("pool_account", |r| r.worker.split_once('.').map(|(a, _)| a).unwrap_or(&r.worker).to_string()),
("pool_url", |r| r.pool_url.clone()),
("errors", |r| r.errors.join("; ")),
]
}
/// Build the full CSV for `rows`. Empty rows still emit a header line.
pub fn rows_to_csv(rows: &[MinerRow]) -> String {
let cols = scalar_columns();
// Widest variable-length fields across the set.
let max_board_temps = rows.iter().map(|r| r.board_temps.len()).max().unwrap_or(0);
let max_fans = rows.iter().map(|r| r.fan_rpms.len()).max().unwrap_or(0);
let max_boards = rows.iter().map(|r| r.board_status.len()).max().unwrap_or(0);
let max_pools = rows.iter().map(|r| r.pools.len()).max().unwrap_or(0);
// Header.
let mut headers: Vec<String> = cols.iter().map(|(h, _)| (*h).to_string()).collect();
for i in 1..=max_board_temps {
headers.push(format!("board_temp_{i}_c"));
}
for i in 1..=max_fans {
headers.push(format!("fan_{i}_rpm"));
}
for i in 1..=max_boards {
headers.push(format!("board_{i}_status"));
}
for i in 1..=max_pools {
headers.push(format!("pool_{i}_url"));
headers.push(format!("pool_{i}_worker"));
}
let mut out = String::new();
out.push_str(&headers.iter().map(|h| esc(h)).collect::<Vec<_>>().join(","));
out.push('\n');
for r in rows {
let mut vals: Vec<String> = cols.iter().map(|(_, f)| f(r)).collect();
for i in 0..max_board_temps {
vals.push(r.board_temps.get(i).map(|&t| num(t)).unwrap_or_default());
}
for i in 0..max_fans {
vals.push(r.fan_rpms.get(i).map(|&t| num(t)).unwrap_or_default());
}
for i in 0..max_boards {
vals.push(r.board_status.get(i).map(board_health_str).unwrap_or("").to_string());
}
for i in 0..max_pools {
let (u, w) = r.pools.get(i).cloned().unwrap_or_default();
vals.push(u);
vals.push(w);
}
out.push_str(&vals.iter().map(|v| esc(v)).collect::<Vec<_>>().join(","));
out.push('\n');
}
out
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn csv_has_header_and_one_row_per_miner() {
let rows = vec![
MinerRow {
ip: "10.0.0.1".into(),
model: "S19".into(),
hashrate_ths: 95.0,
expected_ths: 96.0,
board_temps: vec![77.0, 64.0, 74.0],
fan_rpms: vec![6000.0, 6100.0],
..Default::default()
},
MinerRow { ip: "10.0.0.2".into(), model: "M30S".into(), ..Default::default() },
];
let csv = rows_to_csv(&rows);
let lines: Vec<&str> = csv.lines().collect();
assert_eq!(lines.len(), 3, "header + 2 rows");
assert!(lines[0].starts_with("ip,model,brand,"));
// Expanded columns out to the widest miner (3 board temps, 2 fans).
assert!(lines[0].contains("board_temp_3_c"));
assert!(lines[0].contains("fan_2_rpm"));
assert!(lines[1].starts_with("10.0.0.1,S19,"));
// One value per cell: hashrate and expected are separate columns.
assert!(lines[1].contains(",95,96,") || lines[1].contains("95,96"));
}
#[test]
fn csv_escapes_commas_and_quotes() {
assert_eq!(esc("a,b"), "\"a,b\"");
assert_eq!(esc("he said \"hi\""), "\"he said \"\"hi\"\"\"");
assert_eq!(esc("plain"), "plain");
}
}
+2
View File
@@ -3,10 +3,12 @@
mod access_probe;
mod credentials;
mod export;
mod fixtures;
mod log_scan;
mod model;
mod naming;
mod pool_prefs;
mod presets;
mod restore;
mod scan;
+94 -1
View File
@@ -527,6 +527,97 @@ impl MinerRow {
val as f64
}
/// Errors mentioning hashboard/chain number `n` (1-indexed), for attributing
/// an issue to a specific board in its tooltip (round 15 #15). Matches "board
/// N", "chain N", "hashboard N" or "slot N" case-insensitively, trying both
/// 1-indexed and 0-indexed chain numbering.
pub fn errors_for_board(&self, n: usize) -> Vec<String> {
let needles = [
format!("board {n}"),
format!("chain {n}"),
format!("hashboard {n}"),
format!("slot {n}"),
format!("board {}", n - 1),
format!("chain {}", n - 1),
];
self.errors
.iter()
.filter(|e| {
let lo = e.to_lowercase();
needles.iter().any(|nd| lo.contains(nd.as_str()))
})
.cloned()
.collect()
}
/// Errors that don't name a specific board (attributed to the miner / control
/// board), for the control-board icon tooltip (round 15 #15).
pub fn general_errors(&self, boards: usize) -> Vec<String> {
let attributed: std::collections::HashSet<String> =
(1..=boards).flat_map(|n| self.errors_for_board(n)).collect();
self.errors.iter().filter(|e| !attributed.contains(*e)).cloned().collect()
}
/// Per-icon hover tooltips for the Health column, in the same draw order (and
/// length) as `encode_component_health`'s segments: power, control, each fan
/// padded to `max_fans`, each hashboard padded to `max_boards` (round 15 #15).
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.
tips.push(format!(
"Power supply: {}",
match self.power_health() {
CompHealth::Ok => "OK (drawing power)",
CompHealth::Down => "detected but not delivering",
CompHealth::Degraded => "sub-optimal",
CompHealth::Unreachable => "unknown (no wattage/PSU-fan reported)",
}
));
// Control board -- also carries the miner's un-attributed errors.
let mut ctl = "Control board: OK (miner reachable)".to_string();
for e in self.general_errors(max_boards) {
ctl.push('\n');
ctl.push_str(&e);
}
tips.push(ctl);
// Fans.
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}")
}
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(),
};
tips.push(format!("Fan {}: {s}", i + 1));
}
// Hashboards.
let boards = self.board_healths();
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) => "expected but not detected".to_string(),
None => "not present".to_string(),
};
let mut t = format!("Hashboard {}: {s}", i + 1);
for e in self.errors_for_board(i + 1) {
t.push('\n');
t.push_str(&e);
}
tips.push(t);
}
tips
}
/// 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".
@@ -738,7 +829,7 @@ pub const ALL_COLUMNS: [Column; 43] = [
/// order: model, health (component icons), hashrate, power, chip temp, firmware,
/// CPU, access. The Health column (round 13 #3) folds the old Errors, Boards and
/// Status columns into one row of per-component icons.
pub const DEFAULT_VISIBLE: [Column; 8] = [
pub const DEFAULT_VISIBLE: [Column; 9] = [
Column::Model,
Column::Health,
Column::Hashrate,
@@ -747,6 +838,8 @@ pub const DEFAULT_VISIBLE: [Column; 8] = [
Column::Firmware,
Column::Cpu,
Column::Locked,
// Locate-light beacon, last (round 15 #6).
Column::Light,
];
impl Column {
+116
View File
@@ -0,0 +1,116 @@
//! Dropdown presets + user-saved values for the Configure-pools dialog (round 15
//! #1). Each pool field (address / account / worker / password) has a "+" menu
//! offering built-in presets (pool stratums, worker placeholders) plus values the
//! user has saved, and the user can add the current box value to the saved list.
//! Saved lists persist one-per-line under the config dir.
use std::path::PathBuf;
const CONFIG_DIR: &str = ".config/alkane-toolkit";
/// Which pool field a "+" menu belongs to.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PoolField {
Address,
Account,
Worker,
Password,
}
impl PoolField {
fn saved_file(self) -> &'static str {
match self {
PoolField::Address => "pool-addresses.txt",
PoolField::Account => "pool-accounts.txt",
PoolField::Worker => "pool-workers.txt",
PoolField::Password => "pool-passwords.txt",
}
}
/// Built-in presets offered before the user's saved values.
pub fn presets(self) -> Vec<&'static str> {
match self {
// Top Bitcoin pools by hashrate with their primary stratum endpoints
// (researched round 15; verify in-app before relying on any one).
PoolField::Address => POOL_STRATUMS.iter().map(|(_, u)| *u).collect(),
PoolField::Account => Vec::new(),
// Per-miner worker-name placeholders (see MinerRow::expand_worker_template).
PoolField::Worker => vec![
"{ip1}", "{ip2}", "{ip3}", "{ip4}", "{serial}", "{mac}", "{nameplate-hr}",
"{brand}", "{model}", "{submodel}", "{cpu}", "{cb}", "{firmware}", "{hostname}",
],
PoolField::Password => vec!["x"],
}
}
}
/// (pool name, primary stratum URL). Used for the address dropdown labels.
pub const POOL_STRATUMS: &[(&str, &str)] = &[
("Foundry USA", "stratum+tcp://btc.foundryusapool.com:3333"),
("AntPool", "stratum+tcp://ss.antpool.com:3333"),
("F2Pool", "stratum+tcp://btc.f2pool.com:1314"),
("ViaBTC", "stratum+tcp://btc.viabtc.io:3333"),
("SpiderPool", "stratum+tcp://btc-us.spiderpool.com:2309"),
("Binance Pool", "stratum+tcp://bs.poolbinance.com:3333"),
("Luxor", "stratum+tcp://btc.global.luxor.tech:700"),
("SBI Crypto", "stratum+tcp://us1.sbicrypto.com:3333"),
("Braiins Pool", "stratum+tcp://stratum.braiins.com:3333"),
("ULTIMUSPOOL", "stratum+tcp://bs.ultimuspool.com:8888"),
("SECPOOL", "stratum+tcp://btc.secpool.com:3333"),
];
fn config_path(file: &str) -> PathBuf {
let home = std::env::var("HOME").unwrap_or_else(|_| ".".into());
PathBuf::from(home).join(CONFIG_DIR).join(file)
}
/// The user's saved values for `field`, in save order (most recent last).
pub fn load_saved(field: PoolField) -> Vec<String> {
std::fs::read_to_string(config_path(field.saved_file()))
.ok()
.map(|s| s.lines().map(str::trim).filter(|l| !l.is_empty()).map(String::from).collect())
.unwrap_or_default()
}
/// Add `value` to `field`'s saved list (deduplicated, no-op if empty/already
/// present or already a preset). Returns true if it was newly added.
pub fn add_saved(field: PoolField, value: &str) -> bool {
let value = value.trim();
if value.is_empty() {
return false;
}
if field.presets().iter().any(|p| *p == value) {
return false;
}
let mut saved = load_saved(field);
if saved.iter().any(|s| s == value) {
return false;
}
saved.push(value.to_string());
let p = config_path(field.saved_file());
if let Some(dir) = p.parent() {
let _ = std::fs::create_dir_all(dir);
}
let _ = std::fs::write(p, saved.join("\n"));
true
}
/// The full dropdown list for a field: presets first, then the user's saved
/// values. For the address field each entry is labelled with the pool name.
pub fn dropdown_entries(field: PoolField) -> Vec<(String, String)> {
// (label, value)
let mut out: Vec<(String, String)> = Vec::new();
if field == PoolField::Address {
for (name, url) in POOL_STRATUMS {
out.push((format!("{name} -- {url}"), url.to_string()));
}
} else {
for p in field.presets() {
out.push((p.to_string(), p.to_string()));
}
}
for s in load_saved(field) {
out.push((s.clone(), s));
}
out
}
+2 -1
View File
@@ -15,7 +15,7 @@ pub const PRESETS_FILE: &str = "presets.json";
/// IP, model, health (component icons), hashrate, power, chip temp, firmware,
/// CPU, access. The Health column (round 13 #3) replaced the old errors, boards
/// (hashboard dots) and status columns.
const DEFAULT_PROFILE: [Column; 9] = [
const DEFAULT_PROFILE: [Column; 10] = [
Column::Ip,
Column::Model,
Column::Health,
@@ -25,6 +25,7 @@ const DEFAULT_PROFILE: [Column; 9] = [
Column::Firmware,
Column::Cpu,
Column::Locked,
Column::Light,
];
/// A serializable snapshot of a `ViewState` (Vec-based so JSON has no map keys
+51 -15
View File
@@ -455,6 +455,33 @@ fn summarize_messages(messages: &[asic_rs::core::data::message::MinerMessage]) -
ranked.into_iter().map(|(_, s)| s).collect()
}
/// Infer whether an Antminer's hashboards carry a per-board PIC MCU from the
/// model string (round 14 #2). No firmware (stock cgminer, Vnish, LuxOS, Braiins)
/// exposes a PIC flag over the network; PIC-vs-noPIC is fixed by the hashboard
/// type, so a model map is the only network-only method:
/// - noPIC: an explicit "noPIC" model, the S19k Pro board, and the BM1368+
/// generation (S21 family, T21), where Bitmain dropped the per-board PIC.
/// - PIC: the rest of the S19 line (BM1362/BM1366, PIC16F1704/1542).
/// - unknown: everything else (older Antminers, non-Antminer makes).
/// The one genuinely ambiguous model is the plain "S19j Pro" (both PIC and noPIC
/// revisions exist); it is assumed PIC unless the model string says noPIC.
fn infer_pic(model: &str) -> Option<bool> {
let m = model.to_lowercase();
if m.contains("nopic") {
return Some(false);
}
if m.contains("s21") || m.contains("t21") {
return Some(false);
}
if m.contains("s19k") {
return Some(false);
}
if m.contains("s19") {
return Some(true);
}
None
}
async fn to_row(miner: &dyn Miner) -> MinerRow {
let data = miner.get_data().await;
let hashrate_ths = data
@@ -588,10 +615,10 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
firmware_flash: miner.supports_upgrade_firmware(),
pools: miner.supports_pools_config(),
};
// 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 };
// PIC vs noPIC (round 14 #2 rework). No firmware exposes a PIC flag over the
// network -- it's a fixed hardware property of the hashboard type -- so infer
// it from the model, which every API reports. See `infer_pic`.
let pic_present = infer_pic(&model);
// Access: locked/view-only when the miner exposes no writable control at
// all, otherwise unlocked. Inferred from asic-rs capabilities (there is no
// direct lock-state field). This now covers WhatsMiner too: since round 12
@@ -842,16 +869,20 @@ pub fn start_config_action(ips: Vec<String>, action: ConfigAction) -> ActionHand
ActionHandle { rx, cancel }
}
/// One miner's pool config to write (round 14 #7). The worker `username` has
/// already been expanded from the per-firmware worker template in the UI (which
/// holds the scanned MinerRow), so this carries a fully-resolved endpoint.
pub struct PoolTarget {
pub ip: String,
/// One resolved pool endpoint (worker already expanded from the template).
pub struct PoolEntry {
pub url: String,
pub username: String,
pub password: String,
}
/// One miner's pool config to write (round 14 #7, round 15 #1): up to three
/// pools (primary + backups), each already worker-expanded in the UI.
pub struct PoolTarget {
pub ip: String,
pub pools: Vec<PoolEntry>,
}
/// Apply a single "default" pool group to each target miner on a background
/// thread (round 14 #7). Reuses the ActionMsg/ActionHandle plumbing so the
/// existing drain_action + status handling covers it. Miners whose backend does
@@ -869,10 +900,11 @@ pub fn start_pools_action(targets: Vec<PoolTarget>) -> ActionHandle {
let err_tx = tx.clone();
let res = std::thread::Builder::new().name("fake-pools".into()).spawn(move || {
for t in targets {
let first = t.pools.first().map(|p| p.username.clone()).unwrap_or_default();
let _ = tx.send(ActionMsg::Result {
ip: t.ip,
ok: true,
detail: format!("simulated ({})", t.username),
detail: format!("simulated ({} pool(s), {first})", t.pools.len()),
});
}
let _ = tx.send(ActionMsg::Done { ok: total, total });
@@ -910,11 +942,15 @@ pub fn start_pools_action(targets: Vec<PoolTarget>) -> ActionHandle {
let group = PoolGroupConfig {
name: "default".to_string(),
quota: 1,
pools: vec![PoolConfig {
url: PoolURL::from(t.url.clone()),
username: t.username.clone(),
password: t.password.clone(),
}],
pools: t
.pools
.iter()
.map(|p| PoolConfig {
url: PoolURL::from(p.url.clone()),
username: p.username.clone(),
password: p.password.clone(),
})
.collect(),
};
match miner.set_pools_config(vec![group]).await {
Ok(true) => (true, "ok".to_string()),
+279 -183
View File
@@ -18,6 +18,8 @@ pub const ID_PAUSE: i32 = 105;
pub const ID_STOP: i32 = 106;
pub const ID_SCAN_CREDS: i32 = 107;
pub const ID_PRESETS: i32 = 108;
// Export all scan data to CSV (round 15 #14).
pub const ID_EXPORT: i32 = 109;
// Presets dialog.
const ID_PRESET_LOAD: i32 = 770;
const ID_PRESET_SAVE: i32 = 771;
@@ -70,6 +72,11 @@ const ID_RESTORE_CANCEL: i32 = 787;
const ID_CTX_POOLS: i32 = 736;
const ID_POOLS_OK: i32 = 788;
const ID_POOLS_CANCEL: i32 = 789;
// Pool-field "+" dropdown buttons (round 15 #1): 12 buttons (3 rows x 4 fields),
// id = base + row*4 + field. The dropdown menu items use their own id range.
const ID_POOL_PLUS_BASE: i32 = 800;
const ID_POOL_MENU_ADD: i32 = 819; // "add current box value to the dropdown"
const ID_POOL_MENU_BASE: i32 = 820; // one id per dropdown entry (820 + index)
// Value-prompt dialog for power-limit / tuning-percent actions.
const ID_ACTION_OK: i32 = 740;
const ID_ACTION_CANCEL: i32 = 741;
@@ -96,7 +103,6 @@ const ID_HDR_SORT_REL_ASC: i32 = 765;
const ID_HDR_SORT_REL_DESC: i32 = 766;
// Ticks (~seconds) to keep an action's result on the status bar before the
// idle/countdown status takes over again.
const ACTION_RESULT_TICKS: u8 = 8;
// Filter dialog: the column-selector dropdown + the comparator dropdown.
const ID_FILTER_COL: i32 = 730;
const ID_FILTER_OP: i32 = 731;
@@ -284,6 +290,12 @@ const SHAPE_BOLT: &str = "\u{000C}"; // power supply
const SHAPE_BRAIN: &str = "\u{000E}"; // control board
const SHAPE_FAN: &str = "\u{000F}"; // cooling fan
const SHAPE_CHIP: &str = "\u{0010}"; // hashboard
/// Locate-light beacon (round 15 #6): a green dot above a red dot, both flashing
/// quickly. Replaces the single fading amber dot for the Light column.
const SHAPE_LIGHT_BEACON: &str = "\u{0011}";
/// Health-column alignment gap (round 15 #5): one health-icon-width slot that
/// draws nothing, so component icons line up across rows.
const SHAPE_GAP: &str = "\u{0012}";
/// Register every SVG-backed table-cell icon with the bridge (round 12 #9/#11):
/// the access padlocks and the four status KPI icons. Called once at startup;
@@ -357,12 +369,12 @@ fn encode_access_icon(pal: &Palette, write_locked: Option<bool>) -> String {
}
}
/// Light column: a yellow dot while the miner's locate light is flashing, else
/// blank (round 11 #10). The dot fades in and out (round 12 #6) via the pulsing
/// sentinel, so a flashing light reads as a live pulse rather than a static dot.
fn encode_light_dot(pal: &Palette, flashing: Option<bool>) -> String {
/// Light column: a green-over-red beacon flashing quickly while the miner's
/// locate light is on, else blank (round 15 #6; was a single fading amber dot).
/// The beacon draws its own colours, so the segment colour is unused.
fn encode_light_dot(_pal: &Palette, flashing: Option<bool>) -> String {
match flashing {
Some(true) => encode_segments(&[(Some(pal.amber), SHAPE_PULSE_DOT.to_string())]),
Some(true) => encode_segments(&[(None, SHAPE_LIGHT_BEACON.to_string())]),
_ => encode_segments(&[(None, String::new())]),
}
}
@@ -396,15 +408,34 @@ fn health_color(pal: &Palette, h: crate::model::CompHealth) -> (u8, u8, u8) {
/// Health column: one coloured icon per component (round 13 #3), in the order
/// power supply, control board, each fan (front-to-back / top-to-bottom), then
/// each hashboard. Replaces the old Errors/Boards/Status columns.
fn encode_component_health(pal: &Palette, r: &crate::model::MinerRow) -> String {
///
/// Icons line up in fixed slots across rows (round 15 #5): the fan and hashboard
/// groups are padded with blank gaps out to `max_fans` / `max_boards` (the widest
/// counts in the current fleet), so a miner with fewer fans/boards leaves a gap
/// where the missing ones would be and its hashboards still align. This is
/// parametric -- the maxima are recomputed from the fleet each refresh.
fn encode_component_health(
pal: &Palette,
r: &crate::model::MinerRow,
max_fans: usize,
max_boards: usize,
) -> String {
let mut segs: Vec<(Option<(u8, u8, u8)>, String)> = Vec::new();
segs.push((Some(health_color(pal, r.power_health())), SHAPE_BOLT.to_string()));
segs.push((Some(health_color(pal, r.control_health())), SHAPE_BRAIN.to_string()));
for h in r.fan_healths() {
segs.push((Some(health_color(pal, h)), SHAPE_FAN.to_string()));
let fans = r.fan_healths();
for h in &fans {
segs.push((Some(health_color(pal, *h)), SHAPE_FAN.to_string()));
}
for h in r.board_healths() {
segs.push((Some(health_color(pal, h)), SHAPE_CHIP.to_string()));
for _ in fans.len()..max_fans {
segs.push((None, SHAPE_GAP.to_string()));
}
let boards = r.board_healths();
for h in &boards {
segs.push((Some(health_color(pal, *h)), SHAPE_CHIP.to_string()));
}
for _ in boards.len()..max_boards {
segs.push((None, SHAPE_GAP.to_string()));
}
encode_segments(&segs)
}
@@ -660,21 +691,21 @@ pub struct App {
// Restore-to-stock (round 12 #8a): background job + its typed-confirm dialog.
restore: Option<restore::RestoreHandle>,
restore_dialog: Widget,
restore_input: Widget,
pending_restore: Vec<restore::RestoreTarget>,
// Configure-pools dialog (round 14 #7).
// Configure-pools dialog (round 14 #7, expanded round 15 #1): 3 pool rows x 4
// fields (address, account, worker, password) = 12 text controls, indexed
// row*4 + field. Plus the "+" dropdown menu state.
pools_dialog: Widget,
pools_url_input: Widget,
pools_account_input: Widget,
pools_worker_input: Widget,
pool_fields: Vec<Widget>,
pool_menu_target: usize, // which field the open "+" menu edits
pool_menu_field: crate::pool_prefs::PoolField,
pool_menu_values: Vec<String>, // values behind the open menu, by item index
// Saved view presets + the Presets dialog widgets.
presets: Vec<crate::presets::Preset>,
presets_dialog: Widget,
presets_choice: Widget,
presets_name_input: Widget,
// The last action's result, kept on the status bar for a few ticks.
action_result: Option<String>,
action_result_ticks: u8,
ranges_dialog: Widget,
ranges_edit: Widget,
ranges_auto: Widget,
@@ -847,6 +878,8 @@ pub fn build(frame: Widget) -> App {
ctl.add(filter_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
let columns_btn = Widget::button(panel, "Columns", ID_COLUMNS);
ctl.add(columns_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
let export_btn = Widget::button(panel, "Export", ID_EXPORT);
ctl.add(export_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
let creds_btn = Widget::button(panel, "Credentials", ID_SCAN_CREDS);
ctl.add(creds_btn, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 4);
root.add_sizer(ctl, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 4);
@@ -940,18 +973,16 @@ pub fn build(frame: Widget) -> App {
logview_dialog: frame,
restore: None,
restore_dialog: frame,
restore_input: frame,
pending_restore: Vec::new(),
pools_dialog: frame,
pools_url_input: frame,
pools_account_input: frame,
pools_worker_input: frame,
pool_fields: Vec::new(),
pool_menu_target: 0,
pool_menu_field: crate::pool_prefs::PoolField::Address,
pool_menu_values: Vec::new(),
presets: crate::presets::load_presets(),
presets_dialog: frame,
presets_choice: frame,
presets_name_input: frame,
action_result: None,
action_result_ticks: 0,
ranges_dialog: frame,
ranges_edit: frame,
ranges_auto: frame,
@@ -1105,6 +1136,13 @@ impl App {
// (set at table build) separate rows instead.
// Overwrite the conditionally-coloured cells with segment-encoded text
// (the custom renderer these columns use parses it back out).
// Widest fan / hashboard counts across the visible fleet, so the Health
// column can pad shorter miners with gaps and keep every component icon
// in a fixed slot (round 15 #5).
let (max_fans, max_boards) = self.view_idx.iter().fold((0usize, 0usize), |(f, b), &ri| {
let r = &self.rows[ri];
(f.max(r.fan_healths().len()), b.max(r.board_healths().len()))
});
for (disp, &ri) in self.view_idx.iter().enumerate() {
let r = &self.rows[ri];
for (ci, c) in cols.iter().enumerate() {
@@ -1125,7 +1163,7 @@ impl App {
// the progress text instead of the component icons (round 14 #4).
Column::Health => match self.op_status.get(&r.ip) {
Some(op) => encode_segments(&[(Some(self.pal.amber), op.clone())]),
None => encode_component_health(&self.pal, r),
None => encode_component_health(&self.pal, r, max_fans, max_boards),
},
// Boards column: per-hashboard health dots (round 11 #10).
Column::Hashboards => encode_board_dots(&self.pal, &r.board_status),
@@ -1164,16 +1202,19 @@ impl App {
if matches!(c, Column::Error) {
t.dvlc_set_cell_tooltip(disp, ci, &r.errors.join("\n"));
}
// The Health icons carry a hover tooltip: the component summary,
// plus the full error list (which the Health column replaced) so
// no error detail is lost (round 13 #3).
// The Health icons carry a per-ICON hover tooltip (round 15 #15):
// hovering a specific fan/board shows just that component's state
// (and any error attributed to it). While an operation runs, the
// cell is text, so use a plain cell tooltip instead.
if matches!(c, Column::Health) {
let mut tip = r.health_summary();
if !r.errors.is_empty() {
tip.push('\n');
tip.push_str(&r.errors.join("\n"));
if self.op_status.contains_key(&r.ip) {
t.dvlc_set_icon_tooltips(disp, ci, &[]);
t.dvlc_set_cell_tooltip(disp, ci, &r.health_summary());
} else {
t.dvlc_set_cell_tooltip(disp, ci, "");
let tips = r.health_tooltips(max_fans, max_boards);
t.dvlc_set_icon_tooltips(disp, ci, &tips);
}
t.dvlc_set_cell_tooltip(disp, ci, &tip);
}
}
}
@@ -1443,10 +1484,11 @@ impl App {
self.op_status.remove(ip);
}
/// Build (but do not show) the Configure-pools dialog (round 14 #7): pool
/// address + account (both required) + an optional worker-name template that
/// is expanded per miner. Returns None when nothing is selected or a flash
/// holds the exclusive lock.
/// Build (but do not show) the Configure-pools dialog (round 15 #1): three
/// pool rows, each with address + account + worker + password boxes and a "+"
/// dropdown next to each. Address/account are required per used row; the
/// worker expands per miner from placeholders. Returns None when nothing is
/// selected or a flash holds the exclusive lock.
fn build_pools_dialog(&mut self) -> Option<Widget> {
if self.flashing {
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
@@ -1462,88 +1504,161 @@ impl App {
root.add(
Widget::static_text(
dlg,
&format!("Set the primary pool on {n} selected miner(s). Address and account are required."),
&format!("Set up to 3 pools on {n} selected miner(s). Leave a row blank to skip it; address + account are required for a used row. Use \"+\" for presets; worker placeholders (e.g. {{ip4}}, {{serial}}) expand per miner and insert at the cursor."),
),
0,
sf::BORDER_ALL,
8,
);
let mut field = |label: &str, hint: &str| -> Widget {
let row = Widget::box_sizer(false);
let l = Widget::static_text(dlg, label);
l.set_min_size(90, -1);
row.add(l, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
let input = Widget::text_ctrl(dlg, false);
input.set_min_size(320, -1);
row.add(input, 1, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_ALL, 6);
root.add_sizer(row, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 4);
let _ = hint;
input
// Column headers.
let head = Widget::box_sizer(false);
let hl = |t: &str, w: i32| {
let l = Widget::static_text(dlg, t);
l.set_min_size(w, -1);
l
};
let url_input = field("Address:", "");
url_input.set_value("stratum+tcp://");
let account_input = field("Account:", "");
let worker_input = field("Worker:", "");
root.add(
Widget::static_text(
dlg,
"Worker name may use per-miner placeholders (case-insensitive):\n {ip1}..{ip4} IP octets {serial} {mac} (no ':') {nameplate-hr} rated TH\n {brand} {model} {submodel} {cpu} {cb} control board {firmware} {hostname}\nThe pool user sent is \"account.worker\" (or just the account when Worker is empty).",
),
0,
sf::BORDER_ALL,
8,
);
head.add(hl("", 46), 0, sf::BORDER_LEFT, 6);
head.add(hl("Address", 210), 0, sf::BORDER_LEFT, 6);
head.add(hl("Account", 150), 0, sf::BORDER_LEFT, 6);
head.add(hl("Worker", 150), 0, sf::BORDER_LEFT, 6);
head.add(hl("Password", 110), 0, sf::BORDER_LEFT, 6);
root.add_sizer(head, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 6);
let mut fields: Vec<Widget> = Vec::with_capacity(12);
// widths per field type (address, account, worker, password).
let widths = [180, 120, 120, 80];
for row in 0..3usize {
let rsizer = Widget::box_sizer(false);
let lbl = Widget::static_text(dlg, &format!("Pool {}", row + 1));
lbl.set_min_size(46, -1);
rsizer.add(lbl, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6);
for field in 0..4usize {
let input = Widget::text_ctrl(dlg, false);
input.set_min_size(widths[field], -1);
rsizer.add(input, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT, 6);
let plus = Widget::button(dlg, "+", ID_POOL_PLUS_BASE + (row * 4 + field) as i32);
plus.set_min_size(26, -1);
rsizer.add(plus, 0, sf::ALIGN_CENTRE_VERTICAL, 0);
fields.push(input);
}
root.add_sizer(rsizer, 0, sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP, 4);
}
let btns = Widget::box_sizer(false);
btns.add_stretch(1);
btns.add(Widget::button(dlg, "Apply", ID_POOLS_OK), 0, sf::BORDER_ALL, 6);
btns.add(Widget::button(dlg, "Cancel", ID_POOLS_CANCEL), 0, sf::BORDER_ALL, 6);
root.add_sizer(btns, 0, sf::EXPAND | sf::BORDER_ALL, 6);
root.set_sizer_on(dlg);
dlg.set_min_size(520, 300);
dlg.set_min_size(760, 260);
dlg.fit(dlg);
self.pools_dialog = dlg;
self.pools_url_input = url_input;
self.pools_account_input = account_input;
self.pools_worker_input = worker_input;
self.pool_fields = fields;
Some(dlg)
}
/// Validate the pool inputs, expand the worker template per selected miner,
/// and start the background pool-config action (round 14 #7).
/// The `PoolField` kind of a 0..4 field index within a pool row.
fn pool_field_kind(field: usize) -> crate::pool_prefs::PoolField {
use crate::pool_prefs::PoolField;
match field {
0 => PoolField::Address,
1 => PoolField::Account,
2 => PoolField::Worker,
_ => PoolField::Password,
}
}
/// A pool "+" button was clicked: build its dropdown (presets + saved + "add
/// current") and queue it to pop up (round 15 #1).
fn open_pool_dropdown(&mut self, target: usize) {
if target >= self.pool_fields.len() {
return;
}
let field = Self::pool_field_kind(target % 4);
let entries = crate::pool_prefs::dropdown_entries(field);
let menu = Widget::menu_new();
self.pool_menu_values.clear();
for (i, (label, value)) in entries.into_iter().enumerate() {
menu.menu_append(ID_POOL_MENU_BASE + i as i32, &label);
self.pool_menu_values.push(value);
}
menu.menu_append_separator();
menu.menu_append(ID_POOL_MENU_ADD, "Add this box's value to the list");
self.pool_menu_target = target;
self.pool_menu_field = field;
self.pending_popup = Some((self.pools_dialog, menu));
}
/// A pool dropdown item was chosen (round 15 #1). Worker values insert at the
/// cursor (so several placeholders can be combined); other fields replace.
fn choose_pool_dropdown(&mut self, id: i32) {
use crate::pool_prefs::PoolField;
let Some(input) = self.pool_fields.get(self.pool_menu_target).copied() else {
return;
};
if id == ID_POOL_MENU_ADD {
let val = input.get_value();
if crate::pool_prefs::add_saved(self.pool_menu_field, &val) {
wx_rs::set_status_text("added to the dropdown list");
}
return;
}
let idx = (id - ID_POOL_MENU_BASE) as usize;
let Some(value) = self.pool_menu_values.get(idx).cloned() else {
return;
};
if self.pool_menu_field == PoolField::Worker {
input.write_text(&value); // insert at cursor
} else {
input.set_value(&value);
}
}
/// Read the 3 pool rows, expand each row's worker per selected miner, and
/// start the background pool-config action (round 15 #1). Rows missing an
/// address or account are skipped; a miner with no usable rows is skipped.
fn apply_pools(&mut self) {
let url = self.pools_url_input.get_value().trim().to_string();
let account = self.pools_account_input.get_value().trim().to_string();
let worker_tpl = self.pools_worker_input.get_value();
if url.is_empty() || url == "stratum+tcp://" {
wx_rs::set_status_text("enter a pool address");
return;
}
if account.is_empty() {
wx_rs::set_status_text("enter a pool account");
return;
}
if self.flashing {
wx_rs::set_status_text("firmware flash in progress -- wait for it to finish");
return;
}
// Collect the raw rows: (address, account, worker_template, password).
let mut rows: Vec<(String, String, String, String)> = Vec::new();
for row in 0..3usize {
let get = |f: usize| self.pool_fields.get(row * 4 + f).map(|w| w.get_value()).unwrap_or_default();
let addr = get(0).trim().to_string();
let account = get(1).trim().to_string();
let worker_tpl = get(2);
let password = {
let p = get(3).trim().to_string();
if p.is_empty() { "x".to_string() } else { p }
};
// A row is used only when it has both an address and an account.
if !addr.is_empty() && addr != "stratum+tcp://" && !account.is_empty() {
rows.push((addr, account, worker_tpl, password));
}
}
if rows.is_empty() {
wx_rs::set_status_text("enter at least one pool (address + account)");
return;
}
let targets: Vec<scan::PoolTarget> = self
.selected_rows()
.iter()
.map(|r| {
let worker = r.expand_worker_template(&worker_tpl);
let worker = worker.trim();
let username = if worker.is_empty() {
account.clone()
} else {
format!("{account}.{worker}")
};
scan::PoolTarget {
ip: r.ip.clone(),
url: url.clone(),
username,
// Most pools ignore the worker password; "x" is the convention.
password: "x".to_string(),
}
let pools = rows
.iter()
.map(|(addr, account, worker_tpl, password)| {
let worker = r.expand_worker_template(worker_tpl);
let worker = worker.trim();
let username = if worker.is_empty() {
account.clone()
} else {
format!("{account}.{worker}")
};
scan::PoolEntry { url: addr.clone(), username, password: password.clone() }
})
.collect();
scan::PoolTarget { ip: r.ip.clone(), pools }
})
.collect();
if targets.is_empty() {
@@ -1551,7 +1666,6 @@ impl App {
return;
}
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
let n = ips.len();
if let Some(old) = self.action.take() {
old.stop();
}
@@ -1559,7 +1673,6 @@ impl App {
self.action_targets = ips.clone();
self.set_op_status(&ips, "setting pools…");
self.action = Some(scan::start_pools_action(targets));
wx_rs::set_status_text(&format!("configuring pools on {n} miner(s)..."));
}
/// Start a config action against `ips` on a background thread, cancelling any
@@ -1575,14 +1688,14 @@ impl App {
if let Some(old) = self.action.take() {
old.stop();
}
let msg = format!("applying {} to {} miner(s)...", action.label(), ips.len());
// Progress shows in each miner's Health cell (round 15 #8), not the scan
// line; the bottom-right indicator still surfaces failures at the end.
self.action_targets = ips.clone();
self.set_op_status(&ips, &action.progress_label());
self.action = Some(scan::start_config_action(ips, action));
// Clear any stale error/warning from a previous operation; the new
// outcome repopulates the indicator when this action finishes.
self.clear_indicator();
wx_rs::set_status_text(&msg);
}
/// Start a background per-IP refresh (right-click "Refresh"): re-probes
@@ -1599,11 +1712,10 @@ impl App {
if let Some(old) = self.refresh.take() {
old.stop();
}
let msg = format!("refreshing {} miner(s)...", ips.len());
// Show "refreshing…" in each miner's Health cell while it re-probes (#4).
// Show "refreshing…" in each miner's Health cell while it re-probes (#4);
// the bottom-left scan line is left untouched (round 15 #8).
self.set_op_status(&ips, "refreshing…");
self.refresh = Some(scan::start_refresh(ips));
wx_rs::set_status_text(&msg);
}
/// Fetch the selected miner's log over its firmware API and show it in a
@@ -1659,9 +1771,9 @@ impl App {
Some(dlg)
}
/// Strong typed confirmation before restoring aftermarket firmware to stock
/// (round 12 #8a): the operator must type RESTORE, on top of seeing exactly
/// which miners (IP + firmware) will be reverted. DESTRUCTIVE + reboots.
/// Confirmation before restoring aftermarket firmware to stock (round 12 #8a,
/// simplified in round 15 #11 to a plain confirm): shows exactly which miners
/// (IP + firmware) will be reverted. DESTRUCTIVE + reboots.
fn build_restore_confirm_dialog(&mut self) -> Option<Widget> {
let targets: Vec<restore::RestoreTarget> = self
.selected_rows()
@@ -1683,34 +1795,26 @@ impl App {
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Restore to stock firmware");
let root = Widget::box_sizer(true);
let msg = format!(
"Restore these {n} miner(s) to STOCK firmware? This removes the aftermarket firmware and reboots the miner; it interrupts mining and cannot be undone remotely for all firmwares.\n\n{list}\n\nType RESTORE to confirm:"
);
// Simple confirmation (round 15 #11): the list of miners + a one-line
// question, no typed keyword and no long warning tidbit.
let msg = format!("Restore these {n} miner(s) to stock firmware?\n\n{list}");
root.add(Widget::static_text(dlg, &msg), 0, sf::BORDER_ALL, 12);
let input = Widget::text_ctrl(dlg, false);
input.set_min_size(200, -1);
root.add(input, 0, sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT, 12);
let btns = Widget::box_sizer(false);
btns.add_stretch(1);
btns.add(Widget::button(dlg, "Restore to stock", ID_RESTORE_OK), 0, sf::BORDER_ALL, 6);
btns.add(Widget::button(dlg, "Cancel", ID_RESTORE_CANCEL), 0, sf::BORDER_ALL, 6);
root.add_sizer(btns, 0, sf::EXPAND | sf::BORDER_ALL, 6);
root.set_sizer_on(dlg);
dlg.set_min_size(460, 200);
dlg.set_min_size(420, 180);
dlg.fit(dlg);
self.restore_dialog = dlg;
self.restore_input = input;
Some(dlg)
}
/// Apply the restore confirmation: only start if the operator typed RESTORE
/// exactly. Resolves the per-firmware credentials (VNish password from the
/// Apply the restore confirmation (round 15 #11: a plain confirm, no typed
/// keyword). Resolves the per-firmware credentials (VNish password from the
/// round 12 #13 defaults; Braiins SSH login from the saved SSH creds).
fn apply_restore_confirm(&mut self) {
if self.restore_input.get_value().trim() != "RESTORE" {
wx_rs::set_status_text("type RESTORE exactly to confirm");
return;
}
let targets = std::mem::take(&mut self.pending_restore);
if targets.is_empty() {
self.restore_dialog.close(0);
@@ -1723,12 +1827,10 @@ impl App {
.unwrap_or_else(|| credentials::firmware_default_for("VNish").1);
let vnish_pass = if vnish_pass.is_empty() { "admin".to_string() } else { vnish_pass };
let (ssh_user, ssh_pass) = credentials::load_ssh_credentials().unwrap_or_default();
let n = targets.len();
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
self.restore_dialog.close(1);
self.set_op_status(&ips, "restoring…");
self.restore = Some(restore::start_restore(targets, vnish_pass, ssh_user, ssh_pass));
wx_rs::set_status_text(&format!("restoring {n} miner(s) to stock..."));
}
/// Drain restore-to-stock results into the status bar.
@@ -1740,9 +1842,7 @@ impl App {
let mut op_clear: Vec<String> = Vec::new();
while let Ok(msg) = h.rx.try_recv() {
match msg {
restore::RestoreMsg::Started { total } => {
wx_rs::set_status_text(&format!("restoring {total} miner(s) to stock..."));
}
restore::RestoreMsg::Started { .. } => {}
restore::RestoreMsg::Result { ip, ok, detail } => {
op_clear.push(ip.clone());
if ok {
@@ -1764,18 +1864,12 @@ impl App {
if !op_clear.is_empty() || done {
self.fill_rows();
}
if done {
if fails.is_empty() {
wx_rs::set_status_text(&format!("restore-to-stock: {oks} started; miners reboot to stock"));
} else {
self.set_error_indicator(&format!("restore: {} failed", fails.len()));
wx_rs::set_status_text(&format!(
"restore-to-stock: {oks} ok, {} failed ({})",
fails.len(),
fails.join("; ")
));
}
// Only failures surface (bottom-right indicator); the bottom-left is
// scan-only and per-miner restore progress is in the Health column (#8).
if done && !fails.is_empty() {
self.set_error_indicator(&format!("restore: {} failed", fails.len()));
}
let _ = oks;
}
/// Start the access (lock-state) probe on the selected miners, using the
@@ -1801,11 +1895,9 @@ impl App {
return;
}
let creds = credentials::load_credentials().unwrap_or_else(|| ("root".into(), "root".into()));
let n = targets.len();
let ips: Vec<String> = targets.iter().map(|(ip, _)| ip.clone()).collect();
self.set_op_status(&ips, "checking…");
self.access_probe = Some(scan::start_access_probe(targets, creds));
wx_rs::set_status_text(&format!("checking access on {n} miner(s)..."));
}
/// Drain the running access probe: update each miner's write_locked as its
@@ -1859,17 +1951,21 @@ impl App {
}
if done {
self.access_probe = None;
self.action_result = status.clone();
self.action_result_ticks = ACTION_RESULT_TICKS;
}
if let Some(s) = status {
wx_rs::set_status_text(&s);
}
// Operation progress stays out of the bottom-left scan line (round 15 #8);
// per-miner status shows in the Health column.
let _ = status;
}
/// A menu item was chosen. Direct actions start immediately; the value-input
/// actions (power limit / tuning %) return a prompt dialog to show modally.
fn on_menu_item(&mut self, id: i32) -> Option<Widget> {
// Pool "+" dropdown selections (round 15 #1): the "add current" item and
// one id per dropdown entry from ID_POOL_MENU_BASE up.
if id == ID_POOL_MENU_ADD || id >= ID_POOL_MENU_BASE {
self.choose_pool_dropdown(id);
return None;
}
match id {
ID_HDR_SORT_ASC | ID_HDR_SORT_DESC | ID_HDR_SORT_REL_ASC | ID_HDR_SORT_REL_DESC
| ID_HDR_HIDE | ID_HDR_AUTOSIZE | ID_HDR_COLUMNS => return self.on_header_menu(id),
@@ -2118,15 +2214,6 @@ impl App {
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Credentials");
let root = Widget::box_sizer(true);
root.add(
Widget::static_text(
dlg,
"Logins used when auto-discovering password-protected miners. The global login\napplies to every firmware without its own row below. Blank fields mean no login;\nfirmware rows left at their shipped default are not saved as overrides.",
),
0,
sf::BORDER_ALL,
8,
);
// Global "all firmwares" login. Never re-display the saved password in
// plaintext: leave it blank, and a blank password on Save keeps whatever
// is already stored (see apply_firmware_creds_save).
@@ -2322,10 +2409,6 @@ impl App {
// Release the firmware-flash exclusive lock (harmless no-op for a
// plain config action, which never set it).
self.flashing = false;
// Keep the summary on the status bar for a few ticks so a fleet
// action's outcome (incl. failures) isn't clobbered by the next tick.
self.action_result = status.clone();
self.action_result_ticks = ACTION_RESULT_TICKS;
// Re-probe the miners the action touched so the table reflects the
// change (e.g. the identify light). Skip after a flash (the miner is
// rebooting and won't answer a refresh yet). The follow-up refresh
@@ -2341,7 +2424,9 @@ impl App {
self.fill_rows();
}
}
// Apply the captured indicator now the `h` borrow is gone.
// Apply the captured indicator now the `h` borrow is gone. Failures still
// surface in the bottom-right indicator; the bottom-left stays scan-only
// and per-miner progress is in the Health column (round 15 #8).
if let Some(ind) = indicator {
match ind {
None => self.clear_indicator(),
@@ -2349,12 +2434,10 @@ impl App {
Some((false, msg)) => self.set_warning_indicator(&msg),
}
}
if let Some(s) = status {
wx_rs::set_status_text(&s);
}
let _ = status;
}
/// Drain a running per-IP refresh's results into the status bar and the
/// Drain a running per-IP refresh's results into the rows it touches and the
/// rows it touches (mirrors `drain_action`'s shape, but a Row message
/// upserts a fresh row instead of reporting per-miner ok/fail).
fn drain_refresh(&mut self) {
@@ -2404,9 +2487,8 @@ impl App {
// Any stragglers still marked "refreshing…" revert to icons.
self.op_status.retain(|_, v| v != "refreshing…");
}
if let Some(s) = status {
wx_rs::set_status_text(&s);
}
// Refresh progress stays in the Health column, not the scan line (#8).
let _ = status;
if changed || !op_clear.is_empty() || finished {
self.fill_rows();
}
@@ -2499,26 +2581,12 @@ impl App {
self.drain_refresh();
self.drain_access_probe();
self.drain_restore();
// The bottom-left status is for the scan only (round 15 #8): per-miner
// operation progress lives in the Health column, so operations no longer
// hold or overwrite this line -- only an active scan does.
if self.scanning {
return; // status already shows scan progress
}
if self.access_probe.is_some() {
return; // a probe is in flight; keep its status
}
if self.action.is_some() {
return; // a config action is in flight; keep its status
}
if self.refresh.is_some() {
return; // a per-IP refresh is in flight; keep its status
}
if self.action_result_ticks > 0 {
// Hold the last action's result on the status bar briefly.
self.action_result_ticks -= 1;
if let Some(m) = &self.action_result {
wx_rs::set_status_text(m);
}
return;
}
if self.playing && self.auto_secs > 0 {
if self.countdown > 1 {
self.countdown -= 1;
@@ -2769,13 +2837,13 @@ impl App {
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Edit IP scanning ranges");
let root = Widget::box_sizer(true);
let hint = Widget::static_text(
dlg,
"One range per line:\n CIDR 10.255.1.0/24\n range 10.253.1.3-10.253.1.234\n single 10.253.1.5",
);
root.add(hint, 0, sf::BORDER_ALL, 6);
// The range-format help moved from an inline block to a tooltip on the
// text box (round 15 #10).
let edit = Widget::text_ctrl(dlg, true);
edit.set_value(&scan::load_ranges().join("\n"));
edit.set_tool_tip(
"One range per line:\n CIDR 10.255.1.0/24\n range 10.253.1.3-10.253.1.234\n single 10.253.1.5",
);
root.add(edit, 1, sf::EXPAND | sf::BORDER_ALL, 6);
// Auto-rescan interval (seconds; 0 = off) and per-miner scan timeout.
let auto_row = Widget::box_sizer(false);
@@ -2960,6 +3028,29 @@ impl App {
/// Build (but do not show) the columns chooser: a rearrangeable checklist of
/// every scannable metric. Check to show; drag or use the up/down arrows to
/// reorder. IP is always the first column and is not listed here.
/// Export the full scan data to a CSV the user picks (round 15 #14). Every
/// scanned data point is exported, one value per cell -- more complete and
/// machine-readable than the on-screen table.
fn apply_export(&mut self) {
if self.rows.is_empty() {
wx_rs::set_status_text("nothing to export yet -- run a scan first");
return;
}
let Some(path) = Widget::save_file_dialog(
Widget::main_frame(),
"Export scan data",
"alkane-export.csv",
"CSV files (*.csv)|*.csv|All files (*.*)|*.*",
) else {
return; // cancelled
};
let csv = crate::export::rows_to_csv(&self.rows);
match std::fs::write(&path, csv) {
Ok(()) => wx_rs::set_status_text(&format!("exported {} miner(s) to {path}", self.rows.len())),
Err(e) => self.set_error_indicator(&format!("export failed: {e}")),
}
}
fn build_columns_dialog(&mut self) -> Widget {
let frame = Widget::main_frame();
let dlg = Widget::dialog(frame, "Choose columns");
@@ -3406,6 +3497,7 @@ impl App {
ID_RANGES => return Some(self.build_ranges_dialog()),
ID_RANGES_APPLY => self.apply_ranges(),
ID_RANGES_CANCEL => self.ranges_dialog.close(0),
ID_EXPORT => self.apply_export(),
ID_COLUMNS => return Some(self.build_columns_dialog()),
ID_COLUMNS_OK => self.apply_columns(),
ID_COLUMNS_CANCEL => self.columns_dialog.close(0),
@@ -3449,6 +3541,10 @@ impl App {
}
ID_POOLS_OK => self.apply_pools(),
ID_POOLS_CANCEL => self.pools_dialog.close(0),
// Pool-field "+" dropdown buttons (round 15 #1).
id if (ID_POOL_PLUS_BASE..ID_POOL_PLUS_BASE + 12).contains(&id) => {
self.open_pool_dropdown((id - ID_POOL_PLUS_BASE) as usize);
}
ID_KPI_HASHING => self.toggle_kpi_filter("hashing"),
ID_KPI_SLOW => self.toggle_kpi_filter("slow"),
ID_KPI_NOT => self.toggle_kpi_filter("not hashing"),
@@ -0,0 +1,39 @@
Subject: [PATCH 0009] antminer: read Z15-style fans from higher fan slots
Round-15 #12. The v2020 backend's parse_fans only read fan1..hardware.fans, but
some models report their fans in higher slots and leave the low ones at 0 -- the
Z15 has fan_num=2 yet reports its two fans in fan3/fan4 with fan1/fan2 = 0, so no
fans were read. Scan a generous range of fan slots (1..16) and collect the
non-zero readings instead, renumbered 0.. in the order found. Verified against a
live Z15 (fan3=4920, fan4=5160). The antminer crate tests pass unchanged.
diff --git a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
index 0ce462c9..38935a59 100644
--- a/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
+++ b/vendor/asic-rs-firmwares-antminer/src/backends/v2020/mod.rs
@@ -833,15 +833,23 @@ impl GetFans for AntMinerV2020 {
let mut fans: Vec<FanData> = Vec::new();
if let Some(stats_data) = data.get(&DataField::Fans) {
- for i in 1..=self.device_info.hardware.fans.unwrap_or(4) {
+ // Some models report their fans in higher fan slots and leave the low
+ // ones at 0 -- the Z15, for example, has fan_num=2 but reports its two
+ // fans in fan3/fan4 with fan1/fan2 = 0. So scan a generous range of
+ // slots and collect the non-zero readings rather than only reading
+ // fan1..hardware.fans (which missed the Z15 entirely). The collected
+ // fans are renumbered 0.. in the order found (round 14 #12).
+ let mut pos: i16 = 0;
+ for i in 1..=16 {
if let Some(fan_speed) =
stats_data.get(format!("fan{}", i)).and_then(|v| v.as_f64())
&& fan_speed > 0.0
{
fans.push(FanData {
- position: (i - 1) as i16,
+ position: pos,
rpm: Some(AngularVelocity::from_rpm(fan_speed)),
});
+ pos += 1;
}
}
}
+57 -1
View File
@@ -10,7 +10,7 @@
+pub use widgets::*;
--- a/src/widgets.rs
+++ b/src/widgets.rs
@@ -0,0 +1,847 @@
@@ -0,0 +1,903 @@
+// widgets.rs — alkane-toolkit extension: Rust bindings for the widget bridge
+// in cpp_src/widgets_bridge.cpp. Handles are opaque pointers owned by the
+// wxWidgets object tree (parents own children; nothing to free in Rust).
@@ -40,6 +40,7 @@
+ pub fn wxbr_bind_size(win: *mut c_void);
+ pub fn wxbr_fit(win: *mut c_void);
+ pub fn wxbr_set_min_size(win: *mut c_void, w: c_int, h: c_int);
+ pub fn wxbr_set_tooltip(win: *mut c_void, text: *const c_char);
+ pub fn wxbr_static_text(parent: *mut c_void, label: *const c_char) -> *mut c_void;
+ pub fn wxbr_set_label(win: *mut c_void, label: *const c_char);
+ pub fn wxbr_get_label(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int;
@@ -50,6 +51,7 @@
+ pub fn wxbr_text_ctrl(parent: *mut c_void, multiline: c_int) -> *mut c_void;
+ pub fn wxbr_text_ctrl_get(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int;
+ pub fn wxbr_text_ctrl_set(win: *mut c_void, value: *const c_char);
+ pub fn wxbr_text_ctrl_write(win: *mut c_void, value: *const c_char);
+ pub fn wxbr_check_box(parent: *mut c_void, label: *const c_char) -> *mut c_void;
+ pub fn wxbr_check_box_get(win: *mut c_void) -> c_int;
+ pub fn wxbr_check_box_set(win: *mut c_void, v: c_int);
@@ -64,6 +66,7 @@
+ pub fn wxbr_dialog_show_modal(win: *mut c_void) -> c_int;
+ pub fn wxbr_dialog_close(win: *mut c_void, code: c_int);
+ pub fn wxbr_file_dialog(parent: *mut c_void, title: *const c_char, buf: *mut c_char, cap: c_int) -> c_int;
+ pub fn wxbr_save_file_dialog(parent: *mut c_void, title: *const c_char, default_name: *const c_char, wildcard: *const c_char, buf: *mut c_char, cap: c_int) -> c_int;
+ pub fn wxbr_dvlc(parent: *mut c_void) -> *mut c_void;
+ pub fn wxbr_dvlc_append_text_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int);
+ pub fn wxbr_dvlc_append_colored_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int) -> *mut c_void;
@@ -74,6 +77,7 @@
+ pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
+ pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
+ pub fn wxbr_dvlc_set_cell_tooltip(win: *mut c_void, row: usize, col: usize, text: *const c_char);
+ pub fn wxbr_dvlc_set_icon_tooltips(win: *mut c_void, row: usize, col: usize, joined: *const c_char);
+ pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
+ pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
+ pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
@@ -391,6 +395,12 @@
+ unsafe { notsafe::wxbr_set_min_size(self.0, w, h) }
+ }
+
+ /// Attach a hover tooltip to this widget (round 15 #10). Empty clears it.
+ pub fn set_tool_tip(&self, text: &str) {
+ let c = CString::new(text).unwrap_or_default();
+ unsafe { notsafe::wxbr_set_tooltip(self.0, c.as_ptr()) }
+ }
+
+ pub fn static_text(parent: Widget, label: &str) -> Widget {
+ let c = CString::new(label).unwrap_or_default();
+ Widget(unsafe { notsafe::wxbr_static_text(parent.0, c.as_ptr()) })
@@ -452,6 +462,13 @@
+ unsafe { notsafe::wxbr_text_ctrl_set(self.0, c.as_ptr()) }
+ }
+
+ /// Insert `value` at the text control's cursor (replacing any selection),
+ /// rather than replacing the whole contents (round 15 #1).
+ pub fn write_text(&self, value: &str) {
+ let c = CString::new(value).unwrap_or_default();
+ unsafe { notsafe::wxbr_text_ctrl_write(self.0, c.as_ptr()) }
+ }
+
+ pub fn check_box(parent: Widget, label: &str) -> Widget {
+ let c = CString::new(label).unwrap_or_default();
+ Widget(unsafe { notsafe::wxbr_check_box(parent.0, c.as_ptr()) })
@@ -529,6 +546,36 @@
+ Some(String::from_utf8_lossy(&bytes).into_owned())
+ }
+
+ /// Save-file dialog (round 15 #14): returns the chosen path, or None if
+ /// cancelled. `default_name` prefills the filename; `wildcard` is a wx filter
+ /// string like "CSV files (*.csv)|*.csv".
+ pub fn save_file_dialog(
+ parent: Widget,
+ title: &str,
+ default_name: &str,
+ wildcard: &str,
+ ) -> Option<String> {
+ let t = CString::new(title).unwrap_or_default();
+ let d = CString::new(default_name).unwrap_or_default();
+ let w = CString::new(wildcard).unwrap_or_default();
+ let mut buf = vec![0i8; 4096];
+ let n = unsafe {
+ notsafe::wxbr_save_file_dialog(
+ parent.0,
+ t.as_ptr(),
+ d.as_ptr(),
+ w.as_ptr(),
+ buf.as_mut_ptr(),
+ buf.len() as c_int,
+ )
+ };
+ if n <= 0 {
+ return None;
+ }
+ let bytes: Vec<u8> = buf[..(n - 1) as usize].iter().map(|&b| b as u8).collect();
+ Some(String::from_utf8_lossy(&bytes).into_owned())
+ }
+
+ // ---- data view list ctrl ----
+
+ pub fn dvlc(parent: Widget) -> Widget {
@@ -582,6 +629,15 @@
+ unsafe { notsafe::wxbr_dvlc_set_cell_tooltip(self.0, row, col, c.as_ptr()) }
+ }
+
+ /// Set per-icon hover tooltips for a cell (round 15 #15): one tooltip per icon
+ /// in draw order. The bridge shows the one under the pointer. Passing an empty
+ /// slice clears them.
+ pub fn dvlc_set_icon_tooltips(&self, row: usize, col: usize, tips: &[String]) {
+ let joined = tips.join("\u{1f}");
+ let c = CString::new(joined).unwrap_or_default();
+ unsafe { notsafe::wxbr_dvlc_set_icon_tooltips(self.0, row, col, c.as_ptr()) }
+ }
+
+ pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
+ let mut buf = vec![0i8; 4096];
+ let n = unsafe {
+182 -21
View File
@@ -1,6 +1,6 @@
--- a/cpp_src/widgets_bridge.cpp
+++ b/cpp_src/widgets_bridge.cpp
@@ -0,0 +1,1886 @@
@@ -0,0 +1,2047 @@
+// widgets_bridge.cpp — alkane-toolkit extension to wx-rs
+// Adds the widget/event surface the toolkit UI needs on top of the upstream
+// render-callback bridge (which is kept untouched).
@@ -88,6 +88,10 @@
+ // Per-cell hover tooltip text, keyed by (row, model column). Used for the
+ // Errors column's full-message tooltip (see the GTK query-tooltip handler).
+ std::map<std::pair<unsigned, unsigned>, wxString> cell_tip;
+ // Per-ICON hover tooltips for a cell (round 15 #15): the Health column stores
+ // one tooltip per component icon so the tooltip pertains to the icon under the
+ // pointer, not the whole cell.
+ std::map<std::pair<unsigned, unsigned>, std::vector<wxString>> icon_tip;
+ bool GetAttrByRow(unsigned int row, unsigned int col,
+ wxDataViewItemAttr& attr) const override {
+ (void)col;
@@ -176,6 +180,13 @@
+const wxUniChar SHAPE_BRAIN = 0x0E; // control board
+const wxUniChar SHAPE_FAN = 0x0F; // cooling fan
+const wxUniChar SHAPE_CHIP = 0x10; // hashboard
+// Locate-light beacon (round 15 #6): a green dot above a red dot, both flashing
+// quickly while the miner's locate light is on.
+const wxUniChar SHAPE_LIGHT_BEACON = 0x11;
+// Health-column alignment gap (round 15 #5): draws nothing but advances by one
+// health-icon width, so component icons line up in fixed slots across rows even
+// when a miner has fewer fans/boards than the widest in the fleet.
+const wxUniChar SHAPE_GAP = 0x12;
+const int SHAPE_ADVANCE = 15; // horizontal space one shape occupies
+
+// Table zoom factor (round 14 #3), 1.0 = 100%. A status-bar slider scales the
@@ -186,7 +197,7 @@
+static wxFont g_zoom_base_font; // its font at 100% (captured lazily)
+static wxVector<int> g_zoom_base_w; // column widths at 100% (per column)
+static wxSlider* g_zoom_slider = nullptr; // the status-bar zoom slider
+static wxStaticText* g_zoom_label = nullptr; // the "100%" readout next to it
+static wxTextCtrl* g_zoom_entry = nullptr; // the editable "100%" field next to it
+
+// Animation phase for the pulsing locate-light dot (round 12 #6), advanced by a
+// wxTimer while any such dot is on screen; the treeview it repaints is tracked so
@@ -199,7 +210,8 @@
+ wxUniChar c = s[0];
+ if (c == SHAPE_DOT || c == SHAPE_LOCK || c == SHAPE_UNLOCK ||
+ c == SHAPE_HASHING || c == SHAPE_SLOW || c == SHAPE_NOTHASHING ||
+ c == SHAPE_PAUSED || c == SHAPE_PULSE_DOT ||
+ c == SHAPE_PAUSED || c == SHAPE_PULSE_DOT || c == SHAPE_LIGHT_BEACON ||
+ c == SHAPE_GAP ||
+ c == SHAPE_BOLT || c == SHAPE_BRAIN || c == SHAPE_FAN || c == SHAPE_CHIP) {
+ out = c;
+ return true;
@@ -299,6 +311,18 @@
+int DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell,
+ const wxColour& colour, const wxColour& bg) {
+ int cy = cell.y + cell.height / 2;
+ // Health-column alignment gap (round 15 #5): occupy one health-icon width but
+ // draw nothing, so component icons line up in fixed slots across rows. The
+ // health icons are square, so the advance is (h - 3) just like a real one.
+ if (shape == SHAPE_GAP) {
+ int h = cell.height - 1;
+ int cap = (int)(28 * g_table_zoom + 0.5);
+ if (cap < 8) cap = 8;
+ if (h > cap) h = cap;
+ if (h < 8) h = 8;
+ int adv = h - 3;
+ return adv < 1 ? 1 : adv;
+ }
+ // SVG-backed icon (access padlocks #9, status KPI icons #11): recolour to the
+ // segment colour, rasterise (cached), and draw centred in its slot.
+ if (const ShapeSvg* sv = LookupShapeSvg(shape)) {
@@ -330,6 +354,20 @@
+ }
+ }
+ int cx = x + SHAPE_ADVANCE / 2;
+ if (shape == SHAPE_LIGHT_BEACON) {
+ // A green dot above a red dot, both flashing quickly (round 15 #6). The blink
+ // is a fast on/off (~0.5 s) driven by the shared pulse phase.
+ double a = (std::sin(g_pulse_phase * 3.0) > 0.0) ? 1.0 : 0.18;
+ wxColour green = BlendColour(bg, wxColour(30, 175, 70), a);
+ wxColour red = BlendColour(bg, wxColour(215, 45, 40), a);
+ int r = 3;
+ dc->SetPen(*wxTRANSPARENT_PEN);
+ dc->SetBrush(wxBrush(green));
+ dc->DrawCircle(cx, cy - (r + 1), r);
+ dc->SetBrush(wxBrush(red));
+ dc->DrawCircle(cx, cy + (r + 1), r);
+ return SHAPE_ADVANCE;
+ }
+ if (shape == SHAPE_DOT || shape == SHAPE_PULSE_DOT) {
+ wxColour fill = colour;
+ if (shape == SHAPE_PULSE_DOT) {
@@ -478,7 +516,12 @@
+ // with the table zoom (round 14 #3).
+ int hh = (int)((health ? 22 : 15) * g_table_zoom + 0.5);
+ if (hh < 8) hh = 8;
+ if (const ShapeSvg* sv = LookupShapeSvg(shape)) {
+ // The alignment gap is one health-icon-width slot that draws nothing
+ // (round 15 #5); health icons are square, so its advance is hh - 3.
+ if (shape == SHAPE_GAP) {
+ adv = hh - 3;
+ if (adv < 1) adv = 1;
+ } else if (const ShapeSvg* sv = LookupShapeSvg(shape)) {
+ int ww = (sv->vbh > 0) ? (int)((double)hh * sv->vbw / sv->vbh + 0.5) : hh;
+ if (health) {
+ adv = ww - 3;
@@ -641,6 +684,16 @@
+ ((wxWindow*)win)->SetMinSize(wxSize(w, h));
+}
+
+// Attach a hover tooltip to any widget (round 15 #10). An empty string clears it.
+void wxbr_set_tooltip(void* win, const char* text) {
+ wxWindow* w = (wxWindow*)win;
+ if (text && *text) {
+ w->SetToolTip(wxString::FromUTF8(text));
+ } else {
+ w->UnsetToolTip();
+ }
+}
+
+// ---- static text / fonts --------------------------------------------------
+
+void* wxbr_static_text(void* parent, const char* label) {
@@ -727,6 +780,15 @@
+ ((wxTextCtrl*)win)->SetValue(wxString::FromUTF8(value));
+}
+
+// Insert text at the current cursor position, replacing any selection (round 15
+// #1: worker-name placeholders are inserted, not overwritten). Leaves focus + the
+// cursor after the inserted text.
+void wxbr_text_ctrl_write(void* win, const char* value) {
+ wxTextCtrl* t = (wxTextCtrl*)win;
+ t->WriteText(wxString::FromUTF8(value));
+ t->SetFocus();
+}
+
+// ---- checkbox -------------------------------------------------------------
+
+void* wxbr_check_box(void* parent, const char* label) {
@@ -840,6 +902,25 @@
+ return n + 1;
+}
+
+// Save-file dialog (round 15 #14). `default_name` prefills the filename;
+// `wildcard` is a wxWidgets filter string (e.g. "CSV files (*.csv)|*.csv").
+// Returns the chosen path in `buf` (length+1), or 0 if cancelled.
+int wxbr_save_file_dialog(void* parent, const char* title, const char* default_name,
+ const char* wildcard, char* buf, int cap) {
+ wxString wc = (wildcard && *wildcard) ? wxString::FromUTF8(wildcard)
+ : wxString(wxFileSelectorDefaultWildcardStr);
+ wxFileDialog dlg((wxWindow*)parent, wxString::FromUTF8(title), wxEmptyString,
+ wxString::FromUTF8(default_name ? default_name : ""), wc,
+ wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+ if (dlg.ShowModal() != wxID_OK) return 0;
+ wxCharBuffer b = dlg.GetPath().ToUTF8();
+ int n = (int)strlen(b.data());
+ if (n >= cap) n = cap - 1;
+ memcpy(buf, b.data(), n);
+ buf[n] = 0;
+ return n + 1;
+}
+
+// ---- data view list ctrl ------------------------------------------------------
+
+static AttrListStore* dvlc_store(void* win) {
@@ -864,12 +945,38 @@
+ return FALSE;
+ gint* idx = gtk_tree_path_get_indices(path);
+ int row = idx ? idx[0] : -1;
+ gtk_tree_path_free(path);
+ if (row < 0 || !gcol) return FALSE;
+ if (row < 0 || !gcol) { gtk_tree_path_free(path); return FALSE; }
+ wxDataViewColumn* wxcol = dv->GTKColumnToWX(gcol);
+ if (!wxcol) return FALSE;
+ if (!wxcol) { gtk_tree_path_free(path); return FALSE; }
+ AttrListStore* store = static_cast<AttrListStore*>(dv->GetModel());
+ auto it = store->cell_tip.find({(unsigned)row, wxcol->GetModelColumn()});
+ unsigned mcol = wxcol->GetModelColumn();
+ // Per-icon tooltip (round 15 #15): if this cell has one tooltip per icon, pick
+ // the one under the pointer from the icon slot the x-offset falls in.
+ auto iit = store->icon_tip.find({(unsigned)row, mcol});
+ if (iit != store->icon_tip.end() && !iit->second.empty()) {
+ GdkRectangle crect;
+ gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, gcol, &crect);
+ gtk_tree_path_free(path);
+ // Icon advance matches DrawShape's health-icon width (square icons: h - 3).
+ int h = crect.height - 1;
+ int cap = (int)(28 * g_table_zoom + 0.5);
+ if (cap < 8) cap = 8;
+ if (h > cap) h = cap;
+ if (h < 8) h = 8;
+ int adv = h - 3;
+ if (adv < 1) adv = 1;
+ int off = bx - crect.x;
+ if (off < 0) off = 0;
+ int slot = off / adv;
+ if (slot < 0) slot = 0;
+ if (slot >= (int)iit->second.size()) slot = (int)iit->second.size() - 1;
+ const wxString& tip = iit->second[(size_t)slot];
+ if (tip.IsEmpty()) return FALSE;
+ gtk_tooltip_set_text(tooltip, tip.utf8_str());
+ return TRUE;
+ }
+ gtk_tree_path_free(path);
+ auto it = store->cell_tip.find({(unsigned)row, mcol});
+ if (it == store->cell_tip.end() || it->second.IsEmpty()) return FALSE;
+ gtk_tooltip_set_text(tooltip, it->second.utf8_str());
+ return TRUE;
@@ -1054,6 +1161,30 @@
+ store->DeleteAllItems();
+ store->row_fg.clear();
+ store->cell_tip.clear();
+ store->icon_tip.clear();
+}
+
+// Set per-icon tooltips for one cell (round 15 #15): `joined` is the tooltips for
+// each icon in draw order, separated by 0x1f. An empty string clears them.
+void wxbr_dvlc_set_icon_tooltips(void* win, unsigned row, unsigned col, const char* joined) {
+ AttrListStore* store = dvlc_store(win);
+ if (!joined || !joined[0]) {
+ store->icon_tip.erase({row, col});
+ return;
+ }
+ std::vector<wxString> tips;
+ wxString s = wxString::FromUTF8(joined);
+ wxString cur;
+ for (size_t i = 0; i < s.length(); i++) {
+ if (s[i] == wxUniChar(0x1f)) {
+ tips.push_back(cur);
+ cur.clear();
+ } else {
+ cur += s[i];
+ }
+ }
+ tips.push_back(cur);
+ store->icon_tip[{row, col}] = tips;
+}
+
+// Set (or clear, with an empty string) the hover tooltip for one cell,
@@ -1754,17 +1885,17 @@
+ g_status_indicator->SetSize(r.x + 4, y, r.width - 8, h);
+ }
+ }
+ // Zoom slider + "NNN%" label in the far-right field (round 14 #3): label at the
+ // right edge, slider filling the space to its left.
+ if (g_zoom_slider && g_zoom_label) {
+ // Zoom slider + editable "NNN%" entry in the far-right field (round 14 #3, #4):
+ // the entry at the right edge, slider filling the space to its left.
+ if (g_zoom_slider && g_zoom_entry) {
+ int fld = (sb->GetFieldsCount() >= 3) ? 2 : 1;
+ wxRect r;
+ if (sb->GetFieldRect(fld, r)) {
+ wxSize lbest = g_zoom_label->GetBestSize();
+ int lw = lbest.GetWidth() + 6;
+ int lh = lbest.GetHeight();
+ g_zoom_label->SetSize(r.x + r.width - lw, r.y + (r.height - lh) / 2, lw, lh);
+ int sw = r.width - lw - 8;
+ int ew = 52;
+ int eh = g_zoom_entry->GetBestSize().GetHeight();
+ if (eh > r.height - 2) eh = r.height - 2;
+ g_zoom_entry->SetSize(r.x + r.width - ew - 2, r.y + (r.height - eh) / 2, ew, eh);
+ int sw = r.width - ew - 10;
+ if (sw < 20) sw = 20;
+ int sh = r.height - 2;
+ g_zoom_slider->SetSize(r.x + 2, r.y + (r.height - sh) / 2, sw, sh);
@@ -1799,9 +1930,9 @@
+ g_zoom_table->Refresh();
+ g_zoom_table->Update();
+ }
+ if (g_zoom_label) {
+ g_zoom_label->SetLabel(wxString::Format(wxT("%d%%"), (int)(factor * 100 + 0.5)));
+ reposition_status_indicator();
+ if (g_zoom_entry) {
+ // ChangeValue does not fire wxEVT_TEXT, so this never loops back into a zoom.
+ g_zoom_entry->ChangeValue(wxString::Format(wxT("%d%%"), (int)(factor * 100 + 0.5)));
+ }
+}
+
@@ -1837,6 +1968,7 @@
+// #3). Widens the bar to three fields (status | indicator | zoom) and wires the
+// slider straight to apply_table_zoom -- no Rust round-trip. Call after the table
+// exists so the slider can find it.
+void wxbr_table_set_zoom(double factor); // defined below; used by the handlers here
+void wxbr_status_zoom_init(void* frame_ptr) {
+ wxFrame* frame = (wxFrame*)frame_ptr;
+ wxStatusBar* sb = frame->GetStatusBar();
@@ -1850,15 +1982,44 @@
+ if (!g_zoom_slider) {
+ g_zoom_slider = new wxSlider(sb, wxID_ANY, 100, 50, 250);
+ g_zoom_slider->SetToolTip(wxT("Table zoom"));
+ g_zoom_label = new wxStaticText(sb, wxID_ANY, wxT("100%"),
+ wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
+ // Editable percent field (round 15 #4): type an exact scale and press Enter.
+ g_zoom_entry = new wxTextCtrl(sb, wxID_ANY, wxT("100%"), wxDefaultPosition,
+ wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_RIGHT);
+ g_zoom_entry->SetToolTip(wxT("Table zoom (type a %, Enter)"));
+ g_zoom_slider->Bind(wxEVT_SLIDER, [](wxCommandEvent& e) {
+ apply_table_zoom(e.GetInt() / 100.0);
+ });
+ g_zoom_entry->Bind(wxEVT_TEXT_ENTER, [](wxCommandEvent&) {
+ if (!g_zoom_entry) return;
+ wxString s = g_zoom_entry->GetValue();
+ s.Replace("%", "");
+ s.Trim(true).Trim(false);
+ long pct = 0;
+ if (s.ToLong(&pct) && pct > 0) wxbr_table_set_zoom(pct / 100.0);
+ });
+ sb->Bind(wxEVT_SIZE, [](wxSizeEvent& ev) {
+ reposition_status_indicator();
+ ev.Skip();
+ });
+ // Ctrl +/- / Ctrl+0 zoom the table from anywhere in the window (round 15 #4).
+ frame->Bind(wxEVT_CHAR_HOOK, [](wxKeyEvent& e) {
+ if (e.ControlDown()) {
+ int k = e.GetKeyCode();
+ if (k == '=' || k == '+' || k == WXK_NUMPAD_ADD) {
+ wxbr_table_set_zoom(g_table_zoom + 0.1);
+ return;
+ }
+ if (k == '-' || k == WXK_NUMPAD_SUBTRACT) {
+ wxbr_table_set_zoom(g_table_zoom - 0.1);
+ return;
+ }
+ if (k == '0' || k == WXK_NUMPAD0) {
+ wxbr_table_set_zoom(1.0);
+ return;
+ }
+ }
+ e.Skip();
+ });
+ }
+ reposition_status_indicator();
+}
@@ -85,6 +85,10 @@ class AttrListStore : public wxDataViewListStore {
// Per-cell hover tooltip text, keyed by (row, model column). Used for the
// Errors column's full-message tooltip (see the GTK query-tooltip handler).
std::map<std::pair<unsigned, unsigned>, wxString> cell_tip;
// Per-ICON hover tooltips for a cell (round 15 #15): the Health column stores
// one tooltip per component icon so the tooltip pertains to the icon under the
// pointer, not the whole cell.
std::map<std::pair<unsigned, unsigned>, std::vector<wxString>> icon_tip;
bool GetAttrByRow(unsigned int row, unsigned int col,
wxDataViewItemAttr& attr) const override {
(void)col;
@@ -173,6 +177,13 @@ const wxUniChar SHAPE_BOLT = 0x0C; // power supply
const wxUniChar SHAPE_BRAIN = 0x0E; // control board
const wxUniChar SHAPE_FAN = 0x0F; // cooling fan
const wxUniChar SHAPE_CHIP = 0x10; // hashboard
// Locate-light beacon (round 15 #6): a green dot above a red dot, both flashing
// quickly while the miner's locate light is on.
const wxUniChar SHAPE_LIGHT_BEACON = 0x11;
// Health-column alignment gap (round 15 #5): draws nothing but advances by one
// health-icon width, so component icons line up in fixed slots across rows even
// when a miner has fewer fans/boards than the widest in the fleet.
const wxUniChar SHAPE_GAP = 0x12;
const int SHAPE_ADVANCE = 15; // horizontal space one shape occupies
// Table zoom factor (round 14 #3), 1.0 = 100%. A status-bar slider scales the
@@ -183,7 +194,7 @@ static wxDataViewCtrl* g_zoom_table = nullptr; // the table the zoom scales
static wxFont g_zoom_base_font; // its font at 100% (captured lazily)
static wxVector<int> g_zoom_base_w; // column widths at 100% (per column)
static wxSlider* g_zoom_slider = nullptr; // the status-bar zoom slider
static wxStaticText* g_zoom_label = nullptr; // the "100%" readout next to it
static wxTextCtrl* g_zoom_entry = nullptr; // the editable "100%" field next to it
// Animation phase for the pulsing locate-light dot (round 12 #6), advanced by a
// wxTimer while any such dot is on screen; the treeview it repaints is tracked so
@@ -196,7 +207,8 @@ bool IsShapeSentinel(const wxString& s, wxUniChar& out) {
wxUniChar c = s[0];
if (c == SHAPE_DOT || c == SHAPE_LOCK || c == SHAPE_UNLOCK ||
c == SHAPE_HASHING || c == SHAPE_SLOW || c == SHAPE_NOTHASHING ||
c == SHAPE_PAUSED || c == SHAPE_PULSE_DOT ||
c == SHAPE_PAUSED || c == SHAPE_PULSE_DOT || c == SHAPE_LIGHT_BEACON ||
c == SHAPE_GAP ||
c == SHAPE_BOLT || c == SHAPE_BRAIN || c == SHAPE_FAN || c == SHAPE_CHIP) {
out = c;
return true;
@@ -296,6 +308,18 @@ const wxBitmap& ShapeBitmap(wxUniChar shape, const ShapeSvg& sv, const wxColour&
int DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell,
const wxColour& colour, const wxColour& bg) {
int cy = cell.y + cell.height / 2;
// Health-column alignment gap (round 15 #5): occupy one health-icon width but
// draw nothing, so component icons line up in fixed slots across rows. The
// health icons are square, so the advance is (h - 3) just like a real one.
if (shape == SHAPE_GAP) {
int h = cell.height - 1;
int cap = (int)(28 * g_table_zoom + 0.5);
if (cap < 8) cap = 8;
if (h > cap) h = cap;
if (h < 8) h = 8;
int adv = h - 3;
return adv < 1 ? 1 : adv;
}
// SVG-backed icon (access padlocks #9, status KPI icons #11): recolour to the
// segment colour, rasterise (cached), and draw centred in its slot.
if (const ShapeSvg* sv = LookupShapeSvg(shape)) {
@@ -327,6 +351,20 @@ int DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell,
}
}
int cx = x + SHAPE_ADVANCE / 2;
if (shape == SHAPE_LIGHT_BEACON) {
// A green dot above a red dot, both flashing quickly (round 15 #6). The blink
// is a fast on/off (~0.5 s) driven by the shared pulse phase.
double a = (std::sin(g_pulse_phase * 3.0) > 0.0) ? 1.0 : 0.18;
wxColour green = BlendColour(bg, wxColour(30, 175, 70), a);
wxColour red = BlendColour(bg, wxColour(215, 45, 40), a);
int r = 3;
dc->SetPen(*wxTRANSPARENT_PEN);
dc->SetBrush(wxBrush(green));
dc->DrawCircle(cx, cy - (r + 1), r);
dc->SetBrush(wxBrush(red));
dc->DrawCircle(cx, cy + (r + 1), r);
return SHAPE_ADVANCE;
}
if (shape == SHAPE_DOT || shape == SHAPE_PULSE_DOT) {
wxColour fill = colour;
if (shape == SHAPE_PULSE_DOT) {
@@ -475,7 +513,12 @@ class SegmentRenderer : public wxDataViewCustomRenderer {
// with the table zoom (round 14 #3).
int hh = (int)((health ? 22 : 15) * g_table_zoom + 0.5);
if (hh < 8) hh = 8;
if (const ShapeSvg* sv = LookupShapeSvg(shape)) {
// The alignment gap is one health-icon-width slot that draws nothing
// (round 15 #5); health icons are square, so its advance is hh - 3.
if (shape == SHAPE_GAP) {
adv = hh - 3;
if (adv < 1) adv = 1;
} else if (const ShapeSvg* sv = LookupShapeSvg(shape)) {
int ww = (sv->vbh > 0) ? (int)((double)hh * sv->vbw / sv->vbh + 0.5) : hh;
if (health) {
adv = ww - 3;
@@ -638,6 +681,16 @@ void wxbr_set_min_size(void* win, int w, int h) {
((wxWindow*)win)->SetMinSize(wxSize(w, h));
}
// Attach a hover tooltip to any widget (round 15 #10). An empty string clears it.
void wxbr_set_tooltip(void* win, const char* text) {
wxWindow* w = (wxWindow*)win;
if (text && *text) {
w->SetToolTip(wxString::FromUTF8(text));
} else {
w->UnsetToolTip();
}
}
// ---- static text / fonts --------------------------------------------------
void* wxbr_static_text(void* parent, const char* label) {
@@ -724,6 +777,15 @@ void wxbr_text_ctrl_set(void* win, const char* value) {
((wxTextCtrl*)win)->SetValue(wxString::FromUTF8(value));
}
// Insert text at the current cursor position, replacing any selection (round 15
// #1: worker-name placeholders are inserted, not overwritten). Leaves focus + the
// cursor after the inserted text.
void wxbr_text_ctrl_write(void* win, const char* value) {
wxTextCtrl* t = (wxTextCtrl*)win;
t->WriteText(wxString::FromUTF8(value));
t->SetFocus();
}
// ---- checkbox -------------------------------------------------------------
void* wxbr_check_box(void* parent, const char* label) {
@@ -837,6 +899,25 @@ int wxbr_file_dialog(void* parent, const char* title, char* buf, int cap) {
return n + 1;
}
// Save-file dialog (round 15 #14). `default_name` prefills the filename;
// `wildcard` is a wxWidgets filter string (e.g. "CSV files (*.csv)|*.csv").
// Returns the chosen path in `buf` (length+1), or 0 if cancelled.
int wxbr_save_file_dialog(void* parent, const char* title, const char* default_name,
const char* wildcard, char* buf, int cap) {
wxString wc = (wildcard && *wildcard) ? wxString::FromUTF8(wildcard)
: wxString(wxFileSelectorDefaultWildcardStr);
wxFileDialog dlg((wxWindow*)parent, wxString::FromUTF8(title), wxEmptyString,
wxString::FromUTF8(default_name ? default_name : ""), wc,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
if (dlg.ShowModal() != wxID_OK) return 0;
wxCharBuffer b = dlg.GetPath().ToUTF8();
int n = (int)strlen(b.data());
if (n >= cap) n = cap - 1;
memcpy(buf, b.data(), n);
buf[n] = 0;
return n + 1;
}
// ---- data view list ctrl ------------------------------------------------------
static AttrListStore* dvlc_store(void* win) {
@@ -861,12 +942,38 @@ static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keybo
return FALSE;
gint* idx = gtk_tree_path_get_indices(path);
int row = idx ? idx[0] : -1;
gtk_tree_path_free(path);
if (row < 0 || !gcol) return FALSE;
if (row < 0 || !gcol) { gtk_tree_path_free(path); return FALSE; }
wxDataViewColumn* wxcol = dv->GTKColumnToWX(gcol);
if (!wxcol) return FALSE;
if (!wxcol) { gtk_tree_path_free(path); return FALSE; }
AttrListStore* store = static_cast<AttrListStore*>(dv->GetModel());
auto it = store->cell_tip.find({(unsigned)row, wxcol->GetModelColumn()});
unsigned mcol = wxcol->GetModelColumn();
// Per-icon tooltip (round 15 #15): if this cell has one tooltip per icon, pick
// the one under the pointer from the icon slot the x-offset falls in.
auto iit = store->icon_tip.find({(unsigned)row, mcol});
if (iit != store->icon_tip.end() && !iit->second.empty()) {
GdkRectangle crect;
gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, gcol, &crect);
gtk_tree_path_free(path);
// Icon advance matches DrawShape's health-icon width (square icons: h - 3).
int h = crect.height - 1;
int cap = (int)(28 * g_table_zoom + 0.5);
if (cap < 8) cap = 8;
if (h > cap) h = cap;
if (h < 8) h = 8;
int adv = h - 3;
if (adv < 1) adv = 1;
int off = bx - crect.x;
if (off < 0) off = 0;
int slot = off / adv;
if (slot < 0) slot = 0;
if (slot >= (int)iit->second.size()) slot = (int)iit->second.size() - 1;
const wxString& tip = iit->second[(size_t)slot];
if (tip.IsEmpty()) return FALSE;
gtk_tooltip_set_text(tooltip, tip.utf8_str());
return TRUE;
}
gtk_tree_path_free(path);
auto it = store->cell_tip.find({(unsigned)row, mcol});
if (it == store->cell_tip.end() || it->second.IsEmpty()) return FALSE;
gtk_tooltip_set_text(tooltip, it->second.utf8_str());
return TRUE;
@@ -1051,6 +1158,30 @@ void wxbr_dvlc_clear(void* win) {
store->DeleteAllItems();
store->row_fg.clear();
store->cell_tip.clear();
store->icon_tip.clear();
}
// Set per-icon tooltips for one cell (round 15 #15): `joined` is the tooltips for
// each icon in draw order, separated by 0x1f. An empty string clears them.
void wxbr_dvlc_set_icon_tooltips(void* win, unsigned row, unsigned col, const char* joined) {
AttrListStore* store = dvlc_store(win);
if (!joined || !joined[0]) {
store->icon_tip.erase({row, col});
return;
}
std::vector<wxString> tips;
wxString s = wxString::FromUTF8(joined);
wxString cur;
for (size_t i = 0; i < s.length(); i++) {
if (s[i] == wxUniChar(0x1f)) {
tips.push_back(cur);
cur.clear();
} else {
cur += s[i];
}
}
tips.push_back(cur);
store->icon_tip[{row, col}] = tips;
}
// Set (or clear, with an empty string) the hover tooltip for one cell,
@@ -1751,17 +1882,17 @@ static void reposition_status_indicator() {
g_status_indicator->SetSize(r.x + 4, y, r.width - 8, h);
}
}
// Zoom slider + "NNN%" label in the far-right field (round 14 #3): label at the
// right edge, slider filling the space to its left.
if (g_zoom_slider && g_zoom_label) {
// Zoom slider + editable "NNN%" entry in the far-right field (round 14 #3, #4):
// the entry at the right edge, slider filling the space to its left.
if (g_zoom_slider && g_zoom_entry) {
int fld = (sb->GetFieldsCount() >= 3) ? 2 : 1;
wxRect r;
if (sb->GetFieldRect(fld, r)) {
wxSize lbest = g_zoom_label->GetBestSize();
int lw = lbest.GetWidth() + 6;
int lh = lbest.GetHeight();
g_zoom_label->SetSize(r.x + r.width - lw, r.y + (r.height - lh) / 2, lw, lh);
int sw = r.width - lw - 8;
int ew = 52;
int eh = g_zoom_entry->GetBestSize().GetHeight();
if (eh > r.height - 2) eh = r.height - 2;
g_zoom_entry->SetSize(r.x + r.width - ew - 2, r.y + (r.height - eh) / 2, ew, eh);
int sw = r.width - ew - 10;
if (sw < 20) sw = 20;
int sh = r.height - 2;
g_zoom_slider->SetSize(r.x + 2, r.y + (r.height - sh) / 2, sw, sh);
@@ -1796,9 +1927,9 @@ static void apply_table_zoom(double factor) {
g_zoom_table->Refresh();
g_zoom_table->Update();
}
if (g_zoom_label) {
g_zoom_label->SetLabel(wxString::Format(wxT("%d%%"), (int)(factor * 100 + 0.5)));
reposition_status_indicator();
if (g_zoom_entry) {
// ChangeValue does not fire wxEVT_TEXT, so this never loops back into a zoom.
g_zoom_entry->ChangeValue(wxString::Format(wxT("%d%%"), (int)(factor * 100 + 0.5)));
}
}
@@ -1834,6 +1965,7 @@ void wxbr_status_indicator_set(const char* text, int r, int g, int b) {
// #3). Widens the bar to three fields (status | indicator | zoom) and wires the
// slider straight to apply_table_zoom -- no Rust round-trip. Call after the table
// exists so the slider can find it.
void wxbr_table_set_zoom(double factor); // defined below; used by the handlers here
void wxbr_status_zoom_init(void* frame_ptr) {
wxFrame* frame = (wxFrame*)frame_ptr;
wxStatusBar* sb = frame->GetStatusBar();
@@ -1847,15 +1979,44 @@ void wxbr_status_zoom_init(void* frame_ptr) {
if (!g_zoom_slider) {
g_zoom_slider = new wxSlider(sb, wxID_ANY, 100, 50, 250);
g_zoom_slider->SetToolTip(wxT("Table zoom"));
g_zoom_label = new wxStaticText(sb, wxID_ANY, wxT("100%"),
wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
// Editable percent field (round 15 #4): type an exact scale and press Enter.
g_zoom_entry = new wxTextCtrl(sb, wxID_ANY, wxT("100%"), wxDefaultPosition,
wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_RIGHT);
g_zoom_entry->SetToolTip(wxT("Table zoom (type a %, Enter)"));
g_zoom_slider->Bind(wxEVT_SLIDER, [](wxCommandEvent& e) {
apply_table_zoom(e.GetInt() / 100.0);
});
g_zoom_entry->Bind(wxEVT_TEXT_ENTER, [](wxCommandEvent&) {
if (!g_zoom_entry) return;
wxString s = g_zoom_entry->GetValue();
s.Replace("%", "");
s.Trim(true).Trim(false);
long pct = 0;
if (s.ToLong(&pct) && pct > 0) wxbr_table_set_zoom(pct / 100.0);
});
sb->Bind(wxEVT_SIZE, [](wxSizeEvent& ev) {
reposition_status_indicator();
ev.Skip();
});
// Ctrl +/- / Ctrl+0 zoom the table from anywhere in the window (round 15 #4).
frame->Bind(wxEVT_CHAR_HOOK, [](wxKeyEvent& e) {
if (e.ControlDown()) {
int k = e.GetKeyCode();
if (k == '=' || k == '+' || k == WXK_NUMPAD_ADD) {
wxbr_table_set_zoom(g_table_zoom + 0.1);
return;
}
if (k == '-' || k == WXK_NUMPAD_SUBTRACT) {
wxbr_table_set_zoom(g_table_zoom - 0.1);
return;
}
if (k == '0' || k == WXK_NUMPAD0) {
wxbr_table_set_zoom(1.0);
return;
}
}
e.Skip();
});
}
reposition_status_indicator();
}
+56
View File
@@ -27,6 +27,7 @@ mod notsafe {
pub fn wxbr_bind_size(win: *mut c_void);
pub fn wxbr_fit(win: *mut c_void);
pub fn wxbr_set_min_size(win: *mut c_void, w: c_int, h: c_int);
pub fn wxbr_set_tooltip(win: *mut c_void, text: *const c_char);
pub fn wxbr_static_text(parent: *mut c_void, label: *const c_char) -> *mut c_void;
pub fn wxbr_set_label(win: *mut c_void, label: *const c_char);
pub fn wxbr_get_label(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int;
@@ -37,6 +38,7 @@ mod notsafe {
pub fn wxbr_text_ctrl(parent: *mut c_void, multiline: c_int) -> *mut c_void;
pub fn wxbr_text_ctrl_get(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int;
pub fn wxbr_text_ctrl_set(win: *mut c_void, value: *const c_char);
pub fn wxbr_text_ctrl_write(win: *mut c_void, value: *const c_char);
pub fn wxbr_check_box(parent: *mut c_void, label: *const c_char) -> *mut c_void;
pub fn wxbr_check_box_get(win: *mut c_void) -> c_int;
pub fn wxbr_check_box_set(win: *mut c_void, v: c_int);
@@ -51,6 +53,7 @@ mod notsafe {
pub fn wxbr_dialog_show_modal(win: *mut c_void) -> c_int;
pub fn wxbr_dialog_close(win: *mut c_void, code: c_int);
pub fn wxbr_file_dialog(parent: *mut c_void, title: *const c_char, buf: *mut c_char, cap: c_int) -> c_int;
pub fn wxbr_save_file_dialog(parent: *mut c_void, title: *const c_char, default_name: *const c_char, wildcard: *const c_char, buf: *mut c_char, cap: c_int) -> c_int;
pub fn wxbr_dvlc(parent: *mut c_void) -> *mut c_void;
pub fn wxbr_dvlc_append_text_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int);
pub fn wxbr_dvlc_append_colored_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int) -> *mut c_void;
@@ -61,6 +64,7 @@ mod notsafe {
pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
pub fn wxbr_dvlc_set_cell_tooltip(win: *mut c_void, row: usize, col: usize, text: *const c_char);
pub fn wxbr_dvlc_set_icon_tooltips(win: *mut c_void, row: usize, col: usize, joined: *const c_char);
pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
@@ -378,6 +382,12 @@ impl Widget {
unsafe { notsafe::wxbr_set_min_size(self.0, w, h) }
}
/// Attach a hover tooltip to this widget (round 15 #10). Empty clears it.
pub fn set_tool_tip(&self, text: &str) {
let c = CString::new(text).unwrap_or_default();
unsafe { notsafe::wxbr_set_tooltip(self.0, c.as_ptr()) }
}
pub fn static_text(parent: Widget, label: &str) -> Widget {
let c = CString::new(label).unwrap_or_default();
Widget(unsafe { notsafe::wxbr_static_text(parent.0, c.as_ptr()) })
@@ -439,6 +449,13 @@ impl Widget {
unsafe { notsafe::wxbr_text_ctrl_set(self.0, c.as_ptr()) }
}
/// Insert `value` at the text control's cursor (replacing any selection),
/// rather than replacing the whole contents (round 15 #1).
pub fn write_text(&self, value: &str) {
let c = CString::new(value).unwrap_or_default();
unsafe { notsafe::wxbr_text_ctrl_write(self.0, c.as_ptr()) }
}
pub fn check_box(parent: Widget, label: &str) -> Widget {
let c = CString::new(label).unwrap_or_default();
Widget(unsafe { notsafe::wxbr_check_box(parent.0, c.as_ptr()) })
@@ -516,6 +533,36 @@ impl Widget {
Some(String::from_utf8_lossy(&bytes).into_owned())
}
/// Save-file dialog (round 15 #14): returns the chosen path, or None if
/// cancelled. `default_name` prefills the filename; `wildcard` is a wx filter
/// string like "CSV files (*.csv)|*.csv".
pub fn save_file_dialog(
parent: Widget,
title: &str,
default_name: &str,
wildcard: &str,
) -> Option<String> {
let t = CString::new(title).unwrap_or_default();
let d = CString::new(default_name).unwrap_or_default();
let w = CString::new(wildcard).unwrap_or_default();
let mut buf = vec![0i8; 4096];
let n = unsafe {
notsafe::wxbr_save_file_dialog(
parent.0,
t.as_ptr(),
d.as_ptr(),
w.as_ptr(),
buf.as_mut_ptr(),
buf.len() as c_int,
)
};
if n <= 0 {
return None;
}
let bytes: Vec<u8> = buf[..(n - 1) as usize].iter().map(|&b| b as u8).collect();
Some(String::from_utf8_lossy(&bytes).into_owned())
}
// ---- data view list ctrl ----
pub fn dvlc(parent: Widget) -> Widget {
@@ -569,6 +616,15 @@ impl Widget {
unsafe { notsafe::wxbr_dvlc_set_cell_tooltip(self.0, row, col, c.as_ptr()) }
}
/// Set per-icon hover tooltips for a cell (round 15 #15): one tooltip per icon
/// in draw order. The bridge shows the one under the pointer. Passing an empty
/// slice clears them.
pub fn dvlc_set_icon_tooltips(&self, row: usize, col: usize, tips: &[String]) {
let joined = tips.join("\u{1f}");
let c = CString::new(joined).unwrap_or_default();
unsafe { notsafe::wxbr_dvlc_set_icon_tooltips(self.0, row, col, c.as_ptr()) }
}
pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
let mut buf = vec![0i8; 4096];
let n = unsafe {
+1 -1
View File
@@ -1 +1 @@
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"6e42d50107b1a43fd7cf4a4c4f538468a337ed219ad8d6b23bd9abdabd123bd5","Cargo.lock":"7f984c7231c91f2def8f3e2e923a85c2e0b3239492f5ce23400881ea4de1aa16","Cargo.toml":"8a447efc18cd97d019a9771fb258b06f694499500561564eec75480e46bcc554","Cargo.toml.orig":"6c9e7b86804255debe03545c6358eb975d3d470810a19e6c40c680299a686b1f","src/backends/mod.rs":"65cdc60cdf38968f5a7e197338f4cf6173406ce69a4f0aaa96a9e29f4f581b6e","src/backends/v2020/firmware.rs":"5a41bfb8f42f17523e68f8702e87d75bcdb268bd4950bb66227f6966ef3576a9","src/backends/v2020/mod.rs":"cf1bd56ca56178968f8ef57955f06d14f4c3775f27ca3a85ac280919f19b8e50","src/backends/v2020/rpc.rs":"b517f88b9125fe1d8a20d5167f5d0d105b1339fce3d1a9fad5592e00470f46fb","src/backends/v2020/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/backends/v2023_07/firmware.rs":"c07668e351d48dab3e24511b1aa9ab5e408bbcb5a438fdb0542a1377f94b9bbb","src/backends/v2023_07/mod.rs":"278e4dd04a753858e12df96ead3522aef0616ebf6f27b3da4f1a12b064c19ee6","src/backends/v2023_07/rpc.rs":"2b24bbb432b302dd15f7a354054fc96c6a75cac2c8e75b8bcc11da37255a05a3","src/backends/v2023_07/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/firmware.rs":"e75c21d63218204b61bfab067599402e5c0b20452beaf0b16bfa79bf8afb6b35","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"a3ef4d6805bb4f8ea087e3a9b875e5a1664580e1ff3e3cd2015bb0c5c18ae7bb","src/test/json/v2020/devs.json":"df17cdfc9522e23450702b93f70ff701892db54c6ce6d986300453ad5e0d22db","src/test/json/v2020/mod.rs":"4c2512d36af834d400a865a94c2e8b1919f9d8dcbf54ab2530c73861c51af67d","src/test/json/v2020/pools.json":"4c4d19ad3ef0de84bfb18daaa48428b5f7917d23287c0196eacf3a6e389e7634","src/test/json/v2020/stats.json":"6d3cb463abb7539ae77aa44ef38e62a5dc0db54670aeacf3bbd01e83f49aa1fd","src/test/json/v2020/summary.json":"2f18c81f989b7c5f70dcb0ddac0520e56ec98b6da25c24e59354a6126c965dae","src/test/json/v2020/system_info.json":"51d1ce922e39a254518a24be56ca86ef1b5843582fb26c1ff0ec4ff6f8f91ccf","src/test/json/v2020/version.json":"ae898c4c9ea3462c3e79f9de755f1fccb4ef122b94a4a512e61aa74491c1a8e9","src/test/json/v2023_07/l11_stats.json":"2eab324f253ced9a0ea4e46466691e0e71fc6fde7558fec86bd5acf6bb9c717d","src/test/json/v2023_07/l11_summary.json":"1e0fdb61b968005d0ec5393d9dc889b09efb1398ffa427629bcc0a98d1b67c22","src/test/json/v2023_07/l11_version.json":"d116921a71731c6e492aed109731c39561e34a24c7df2a88d11ac52b80f6100a","src/test/json/v2023_07/l9_stats.json":"731ee545f16dafd356d22703248b91a37f74585ad73cc27441eb3461ce53dca0","src/test/json/v2023_07/l9_summary.json":"b32b5131ad46859b270d2dbb6bdba3c4e5d7301298daee4ce56332c98faaf81d","src/test/json/v2023_07/l9_version.json":"82f03ca6ea8873f12c4d9455f21b98c547801b58fbff1dcd83c837c0f337a129","src/test/json/v2023_07/mod.rs":"1360a8b155b120f2e755ede0736bcc0d76a9d1d693b984a1b51a16e6c0413791","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"0c06e3ecbf95ae3fe5e30aacae55cf6e7ad3d965f4a93b2f85c7b64f61fc75e2"}
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"6e42d50107b1a43fd7cf4a4c4f538468a337ed219ad8d6b23bd9abdabd123bd5","Cargo.lock":"7f984c7231c91f2def8f3e2e923a85c2e0b3239492f5ce23400881ea4de1aa16","Cargo.toml":"8a447efc18cd97d019a9771fb258b06f694499500561564eec75480e46bcc554","Cargo.toml.orig":"6c9e7b86804255debe03545c6358eb975d3d470810a19e6c40c680299a686b1f","src/backends/mod.rs":"65cdc60cdf38968f5a7e197338f4cf6173406ce69a4f0aaa96a9e29f4f581b6e","src/backends/v2020/firmware.rs":"5a41bfb8f42f17523e68f8702e87d75bcdb268bd4950bb66227f6966ef3576a9","src/backends/v2020/mod.rs":"e4bda5bdd5322c293daf15679b84c41c51edc4749eaaad2ca5f34f01aa2a902f","src/backends/v2020/rpc.rs":"b517f88b9125fe1d8a20d5167f5d0d105b1339fce3d1a9fad5592e00470f46fb","src/backends/v2020/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/backends/v2023_07/firmware.rs":"c07668e351d48dab3e24511b1aa9ab5e408bbcb5a438fdb0542a1377f94b9bbb","src/backends/v2023_07/mod.rs":"278e4dd04a753858e12df96ead3522aef0616ebf6f27b3da4f1a12b064c19ee6","src/backends/v2023_07/rpc.rs":"2b24bbb432b302dd15f7a354054fc96c6a75cac2c8e75b8bcc11da37255a05a3","src/backends/v2023_07/web.rs":"d39b67ed83781b2c4fa84a445b9ffe785ae3001941f800ad9860e050c61c6506","src/firmware.rs":"e75c21d63218204b61bfab067599402e5c0b20452beaf0b16bfa79bf8afb6b35","src/lib.rs":"53f7acddeff8f7d82f80d09e0a9f91962011f9ccf2e441c4ca05cd7fc4eb292e","src/test/json/mod.rs":"a3ef4d6805bb4f8ea087e3a9b875e5a1664580e1ff3e3cd2015bb0c5c18ae7bb","src/test/json/v2020/devs.json":"df17cdfc9522e23450702b93f70ff701892db54c6ce6d986300453ad5e0d22db","src/test/json/v2020/mod.rs":"4c2512d36af834d400a865a94c2e8b1919f9d8dcbf54ab2530c73861c51af67d","src/test/json/v2020/pools.json":"4c4d19ad3ef0de84bfb18daaa48428b5f7917d23287c0196eacf3a6e389e7634","src/test/json/v2020/stats.json":"6d3cb463abb7539ae77aa44ef38e62a5dc0db54670aeacf3bbd01e83f49aa1fd","src/test/json/v2020/summary.json":"2f18c81f989b7c5f70dcb0ddac0520e56ec98b6da25c24e59354a6126c965dae","src/test/json/v2020/system_info.json":"51d1ce922e39a254518a24be56ca86ef1b5843582fb26c1ff0ec4ff6f8f91ccf","src/test/json/v2020/version.json":"ae898c4c9ea3462c3e79f9de755f1fccb4ef122b94a4a512e61aa74491c1a8e9","src/test/json/v2023_07/l11_stats.json":"2eab324f253ced9a0ea4e46466691e0e71fc6fde7558fec86bd5acf6bb9c717d","src/test/json/v2023_07/l11_summary.json":"1e0fdb61b968005d0ec5393d9dc889b09efb1398ffa427629bcc0a98d1b67c22","src/test/json/v2023_07/l11_version.json":"d116921a71731c6e492aed109731c39561e34a24c7df2a88d11ac52b80f6100a","src/test/json/v2023_07/l9_stats.json":"731ee545f16dafd356d22703248b91a37f74585ad73cc27441eb3461ce53dca0","src/test/json/v2023_07/l9_summary.json":"b32b5131ad46859b270d2dbb6bdba3c4e5d7301298daee4ce56332c98faaf81d","src/test/json/v2023_07/l9_version.json":"82f03ca6ea8873f12c4d9455f21b98c547801b58fbff1dcd83c837c0f337a129","src/test/json/v2023_07/mod.rs":"1360a8b155b120f2e755ede0736bcc0d76a9d1d693b984a1b51a16e6c0413791","src/test/mod.rs":"ed52c3d613eabc4a0346bb38bcfdf7a94933d61e368d3c9094821edeab92f81b"},"package":"0c06e3ecbf95ae3fe5e30aacae55cf6e7ad3d965f4a93b2f85c7b64f61fc75e2"}
+10 -2
View File
@@ -833,15 +833,23 @@ impl GetFans for AntMinerV2020 {
let mut fans: Vec<FanData> = Vec::new();
if let Some(stats_data) = data.get(&DataField::Fans) {
for i in 1..=self.device_info.hardware.fans.unwrap_or(4) {
// Some models report their fans in higher fan slots and leave the low
// ones at 0 -- the Z15, for example, has fan_num=2 but reports its two
// fans in fan3/fan4 with fan1/fan2 = 0. So scan a generous range of
// slots and collect the non-zero readings rather than only reading
// fan1..hardware.fans (which missed the Z15 entirely). The collected
// fans are renumbered 0.. in the order found (round 14 #12).
let mut pos: i16 = 0;
for i in 1..=16 {
if let Some(fan_speed) =
stats_data.get(format!("fan{}", i)).and_then(|v| v.as_f64())
&& fan_speed > 0.0
{
fans.push(FanData {
position: (i - 1) as i16,
position: pos,
rpm: Some(AngularVelocity::from_rpm(fan_speed)),
});
pos += 1;
}
}
}