Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34a1a1f3b1 |
@@ -570,7 +570,14 @@ async fn settune(ip_s: &str, kind: &str, value: f64) {
|
||||
// power-limit setter for a power target (LuxOS/Braiins tune by power
|
||||
// and expose no set_tuning_config).
|
||||
if m.supports_tuning_config() {
|
||||
match m.set_tuning_config(TuningConfig::new(target), None).await {
|
||||
// Mirror the GUI apply path: preserve the firmware's current tuning
|
||||
// algorithm + scaling (ePIC requires both for set_tuning_config).
|
||||
let mut cfg = TuningConfig::new(target);
|
||||
if let Some(algo) = m.get_tuning_config().await.ok().and_then(|c| c.algorithm) {
|
||||
cfg = cfg.with_algorithm(algo);
|
||||
}
|
||||
let scaling = m.get_scaling_config().await.ok();
|
||||
match m.set_tuning_config(cfg, scaling).await {
|
||||
Ok(v) => println!("set_tuning_config({kind} {value}) -> Ok({v})"),
|
||||
Err(e) => println!("set_tuning_config({kind} {value}) -> Err: {e:#}"),
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@ impl Board {
|
||||
resume: self.mining,
|
||||
power_limit: self.mining,
|
||||
tuning: self.mining,
|
||||
hashrate_target: self.mining,
|
||||
firmware_flash,
|
||||
pools: true,
|
||||
timezone: self.mining,
|
||||
|
||||
@@ -213,6 +213,10 @@ pub struct MinerCaps {
|
||||
pub resume: bool,
|
||||
pub power_limit: bool,
|
||||
pub tuning: bool,
|
||||
/// Round 17 C: supports setting a structured hashrate target via
|
||||
/// `set_tuning_config` (the firmware actively tunes by hashrate, e.g. ePIC).
|
||||
/// Power targets are covered by `power_limit`.
|
||||
pub hashrate_target: bool,
|
||||
/// Whether this miner's asic-rs driver supports `upgrade_firmware`
|
||||
/// (probed via `supports_upgrade_firmware()` at scan time).
|
||||
pub firmware_flash: bool,
|
||||
@@ -236,6 +240,7 @@ impl MinerCaps {
|
||||
resume: self.resume && other.resume,
|
||||
power_limit: self.power_limit && other.power_limit,
|
||||
tuning: self.tuning && other.tuning,
|
||||
hashrate_target: self.hashrate_target && other.hashrate_target,
|
||||
firmware_flash: self.firmware_flash && other.firmware_flash,
|
||||
pools: self.pools && other.pools,
|
||||
timezone: self.timezone && other.timezone,
|
||||
@@ -268,6 +273,7 @@ impl MinerCaps {
|
||||
|| self.resume
|
||||
|| self.power_limit
|
||||
|| self.tuning
|
||||
|| self.hashrate_target
|
||||
|| self.firmware_flash
|
||||
|| self.pools
|
||||
|| self.timezone
|
||||
@@ -422,6 +428,17 @@ pub struct MinerRow {
|
||||
/// shows "V / A" for a healthy PSU instead of a bare "PSU OK".
|
||||
pub psu_out_voltage_v: Option<f64>,
|
||||
pub psu_out_current_a: Option<f64>,
|
||||
/// Current structured tuning target, rendered for display (e.g. "2832 W",
|
||||
/// "96 TH/s", "preset 3550"), or None (round 17 C).
|
||||
pub tuning_target_label: Option<String>,
|
||||
/// Advertised power-target envelope in watts, when the firmware reports one
|
||||
/// (round 17 C, e.g. Braiins 944-6435 W). Bounds + validate the power-target
|
||||
/// prompt; `None` leaves it unbounded.
|
||||
pub power_target_min_w: Option<f64>,
|
||||
pub power_target_max_w: Option<f64>,
|
||||
/// Advertised hashrate-target envelope in TH/s, when reported (round 17 C).
|
||||
pub hashrate_target_min_ths: Option<f64>,
|
||||
pub hashrate_target_max_ths: Option<f64>,
|
||||
pub tuning_percent: Option<u8>,
|
||||
// thermal / cooling
|
||||
/// Average chip temperature (used for sorting/colour banding of the
|
||||
@@ -2326,6 +2343,7 @@ mod tests {
|
||||
resume: true,
|
||||
power_limit: true,
|
||||
tuning: true,
|
||||
hashrate_target: true,
|
||||
firmware_flash: true,
|
||||
pools: true,
|
||||
timezone: true,
|
||||
|
||||
@@ -675,6 +675,47 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
// VNish; Braiins and the rest keep asic-rs's answer.
|
||||
let power_limit = miner.supports_set_power_limit()
|
||||
&& !data.device_info.firmware.eq_ignore_ascii_case("VNish");
|
||||
// Structured tuning (round 17 C). Extract the current target + the advertised
|
||||
// envelope so the "Set performance target" prompt can show/validate bounds.
|
||||
use asic_rs::core::data::miner::TuningTarget;
|
||||
let target_watts = |t: &TuningTarget| match t {
|
||||
TuningTarget::Power(p) => Some(p.as_watts()),
|
||||
_ => None,
|
||||
};
|
||||
let target_ths = |t: &TuningTarget| match t {
|
||||
TuningTarget::HashRate(h) => Some(
|
||||
h.clone()
|
||||
.as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash)
|
||||
.value,
|
||||
),
|
||||
_ => None,
|
||||
};
|
||||
let (power_target_min_w, power_target_max_w, hashrate_target_min_ths, hashrate_target_max_ths) =
|
||||
match &data.tuning_capabilities {
|
||||
Some(c) => (
|
||||
c.power.as_ref().and_then(|p| p.minimum.as_ref()).and_then(&target_watts),
|
||||
c.power.as_ref().and_then(|p| p.maximum.as_ref()).and_then(&target_watts),
|
||||
c.hashrate.as_ref().and_then(|h| h.minimum.as_ref()).and_then(&target_ths),
|
||||
c.hashrate.as_ref().and_then(|h| h.maximum.as_ref()).and_then(&target_ths),
|
||||
),
|
||||
None => (None, None, None, None),
|
||||
};
|
||||
let tuning_target_label = data.tuning_target.as_ref().map(|t| match t {
|
||||
TuningTarget::Power(p) => format!("{:.0} W", p.as_watts()),
|
||||
TuningTarget::HashRate(h) => format!(
|
||||
"{:.0} TH/s",
|
||||
h.clone().as_unit(asic_rs::core::data::hashrate::HashRateUnit::TeraHash).value
|
||||
),
|
||||
TuningTarget::MiningMode(m) => format!("mode {m}"),
|
||||
TuningTarget::Preset(s) => format!("preset {s}"),
|
||||
TuningTarget::Manual { .. } => "manual".to_string(),
|
||||
});
|
||||
// A hashrate target is offerable only where the firmware actively tunes by
|
||||
// hashrate through set_tuning_config (ePIC); Braiins advertises a hashrate
|
||||
// envelope but has no set_tuning_config wired, so it is excluded.
|
||||
let tunes_by_hashrate = matches!(data.tuning_target, Some(TuningTarget::HashRate(_)))
|
||||
|| data.tuning_capabilities.as_ref().map(|c| c.hashrate.is_some()).unwrap_or(false);
|
||||
let hashrate_target = miner.supports_tuning_config() && tunes_by_hashrate;
|
||||
// Probe what this miner supports being told to do (sync, no extra I/O).
|
||||
let caps = MinerCaps {
|
||||
fault_light: miner.supports_set_fault_light(),
|
||||
@@ -683,6 +724,7 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
resume: miner.supports_resume(),
|
||||
power_limit,
|
||||
tuning: miner.supports_set_tuning_percent(),
|
||||
hashrate_target,
|
||||
firmware_flash: miner.supports_upgrade_firmware(),
|
||||
pools: miner.supports_pools_config(),
|
||||
timezone: miner.supports_timezone_config(),
|
||||
@@ -773,6 +815,11 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
|
||||
// falls back to a status string until it is.
|
||||
psu_out_voltage_v: None,
|
||||
psu_out_current_a: None,
|
||||
tuning_target_label,
|
||||
power_target_min_w,
|
||||
power_target_max_w,
|
||||
hashrate_target_min_ths,
|
||||
hashrate_target_max_ths,
|
||||
tuning_percent: data.tuning_percent,
|
||||
chip_temp_c,
|
||||
board_temps,
|
||||
@@ -810,7 +857,8 @@ pub enum ConfigAction {
|
||||
Restart,
|
||||
Pause,
|
||||
Resume,
|
||||
PowerLimit(f64), // watts
|
||||
PowerLimit(f64), // watts
|
||||
HashRateTarget(f64), // TH/s -- structured hashrate target (round 17 C)
|
||||
TuningPercent(u8),
|
||||
Timezone(String), // IANA zone, e.g. "America/Edmonton" (round 17 B / G10)
|
||||
ChangePassword(String), // new web/API password (round 17 B / G11)
|
||||
@@ -826,7 +874,8 @@ impl ConfigAction {
|
||||
ConfigAction::Restart => "restart".into(),
|
||||
ConfigAction::Pause => "pause".into(),
|
||||
ConfigAction::Resume => "resume".into(),
|
||||
ConfigAction::PowerLimit(w) => format!("power limit {w:.0} W"),
|
||||
ConfigAction::PowerLimit(w) => format!("power target {w:.0} W"),
|
||||
ConfigAction::HashRateTarget(t) => format!("hashrate target {t:.0} TH/s"),
|
||||
ConfigAction::TuningPercent(p) => format!("tuning {p}%"),
|
||||
ConfigAction::Timezone(tz) => format!("timezone {tz}"),
|
||||
ConfigAction::ChangePassword(_) => "change password".into(),
|
||||
@@ -844,6 +893,7 @@ impl ConfigAction {
|
||||
ConfigAction::Pause => "pausing…".into(),
|
||||
ConfigAction::Resume => "resuming…".into(),
|
||||
ConfigAction::PowerLimit(_) => "setting power…".into(),
|
||||
ConfigAction::HashRateTarget(_) => "setting hashrate…".into(),
|
||||
ConfigAction::TuningPercent(_) => "tuning…".into(),
|
||||
ConfigAction::Timezone(_) => "setting timezone…".into(),
|
||||
ConfigAction::ChangePassword(_) => "changing password…".into(),
|
||||
@@ -878,6 +928,28 @@ async fn apply_action(miner: &dyn Miner, action: &ConfigAction) -> Result<bool,
|
||||
ConfigAction::Pause => miner.pause(None).await,
|
||||
ConfigAction::Resume => miner.resume(None).await,
|
||||
ConfigAction::PowerLimit(w) => miner.set_power_limit(Power::from_watts(*w)).await,
|
||||
ConfigAction::HashRateTarget(ths) => {
|
||||
use asic_rs::core::config::tuning::TuningConfig;
|
||||
use asic_rs::core::data::hashrate::HashRateUnit;
|
||||
use asic_rs::core::data::miner::TuningTarget;
|
||||
// Build a HashRate target by cloning the miner's current hashrate to
|
||||
// inherit its algorithm (HashAlgorithm is not publicly nameable),
|
||||
// overriding value + unit.
|
||||
let data = miner.get_data().await;
|
||||
let Some(mut hr) = data.hashrate.clone() else {
|
||||
return Err("miner reports no current hashrate; cannot set a hashrate target".into());
|
||||
};
|
||||
hr.value = *ths;
|
||||
hr.unit = HashRateUnit::TeraHash;
|
||||
let mut cfg = TuningConfig::new(TuningTarget::HashRate(hr));
|
||||
// Preserve the firmware's current tuning algorithm + scaling (ePIC
|
||||
// requires both for set_tuning_config; other firmware ignore them).
|
||||
if let Some(algo) = miner.get_tuning_config().await.ok().and_then(|c| c.algorithm) {
|
||||
cfg = cfg.with_algorithm(algo);
|
||||
}
|
||||
let scaling = miner.get_scaling_config().await.ok();
|
||||
miner.set_tuning_config(cfg, scaling).await
|
||||
}
|
||||
ConfigAction::TuningPercent(p) => miner.set_tuning_percent(*p).await,
|
||||
ConfigAction::Timezone(tz) => {
|
||||
use asic_rs::core::config::timezone::{Tz, TimezoneConfig};
|
||||
|
||||
@@ -66,6 +66,7 @@ const ID_CTX_PAUSE: i32 = 725;
|
||||
const ID_CTX_RESUME: i32 = 726;
|
||||
const ID_CTX_TUNING: i32 = 727;
|
||||
const ID_CTX_POWER: i32 = 728;
|
||||
const ID_CTX_HASHRATE: i32 = 740; // Set hashrate target (round 17 C)
|
||||
const ID_CTX_RESTART: i32 = 729;
|
||||
// Round 17 B: timezone / change-password / factory-reset config actions.
|
||||
const ID_CTX_TIMEZONE: i32 = 737;
|
||||
@@ -97,6 +98,7 @@ const ID_ACTION_CANCEL: i32 = 741;
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum PromptKind {
|
||||
Power,
|
||||
HashRateTarget,
|
||||
Tuning,
|
||||
Timezone,
|
||||
Password,
|
||||
@@ -1483,7 +1485,10 @@ impl App {
|
||||
menu.menu_append(ID_CTX_TUNING, &format!("Set tuning %...{sfx}"));
|
||||
}
|
||||
if caps.power_limit {
|
||||
menu.menu_append(ID_CTX_POWER, &format!("Set power limit...{sfx}"));
|
||||
menu.menu_append(ID_CTX_POWER, &format!("Set power target...{sfx}"));
|
||||
}
|
||||
if caps.hashrate_target {
|
||||
menu.menu_append(ID_CTX_HASHRATE, &format!("Set hashrate target...{sfx}"));
|
||||
}
|
||||
if caps.restart {
|
||||
menu.menu_append(ID_CTX_RESTART, &format!("Restart{sfx}"));
|
||||
@@ -2115,6 +2120,7 @@ impl App {
|
||||
ID_CTX_RESTART => return Some(self.build_confirm_dialog(scan::ConfigAction::Restart)),
|
||||
// Value entry is itself the confirmation.
|
||||
ID_CTX_POWER => return Some(self.build_action_prompt(PromptKind::Power)),
|
||||
ID_CTX_HASHRATE => return Some(self.build_action_prompt(PromptKind::HashRateTarget)),
|
||||
ID_CTX_TUNING => return Some(self.build_action_prompt(PromptKind::Tuning)),
|
||||
ID_CTX_TIMEZONE => return Some(self.build_action_prompt(PromptKind::Timezone)),
|
||||
ID_CTX_PASSWORD => return Some(self.build_action_prompt(PromptKind::Password)),
|
||||
@@ -2165,21 +2171,81 @@ impl App {
|
||||
|
||||
/// A small modal to enter a power limit (watts) or tuning percent for the
|
||||
/// selection. Built here, shown modally by `dispatch` outside the App borrow.
|
||||
/// The tightest common tuning envelope (max of the mins .. min of the maxes)
|
||||
/// across the captured-selection miners that advertise one, plus their shared
|
||||
/// current-target label ("varies" if they differ), for the target prompts
|
||||
/// (round 17 C). `get` picks the (min, max) pair for the target kind.
|
||||
fn selected_envelope(
|
||||
&self,
|
||||
get: impl Fn(&MinerRow) -> (Option<f64>, Option<f64>),
|
||||
) -> (Option<(f64, f64)>, Option<String>) {
|
||||
let sel = self
|
||||
.rows
|
||||
.iter()
|
||||
.filter(|r| self.action_ips.contains(&r.ip));
|
||||
let mut lo: Option<f64> = None;
|
||||
let mut hi: Option<f64> = None;
|
||||
let mut labels: std::collections::HashSet<String> = std::collections::HashSet::new();
|
||||
for r in sel {
|
||||
let (mn, mx) = get(r);
|
||||
if let Some(m) = mn {
|
||||
lo = Some(lo.map_or(m, |v: f64| v.max(m)));
|
||||
}
|
||||
if let Some(m) = mx {
|
||||
hi = Some(hi.map_or(m, |v: f64| v.min(m)));
|
||||
}
|
||||
if let Some(l) = &r.tuning_target_label {
|
||||
labels.insert(l.clone());
|
||||
}
|
||||
}
|
||||
let range = match (lo, hi) {
|
||||
(Some(a), Some(b)) if a <= b => Some((a, b)),
|
||||
_ => None,
|
||||
};
|
||||
let label = match labels.len() {
|
||||
0 => None,
|
||||
1 => labels.into_iter().next(),
|
||||
_ => Some("varies".to_string()),
|
||||
};
|
||||
(range, label)
|
||||
}
|
||||
|
||||
fn build_action_prompt(&mut self, kind: PromptKind) -> Widget {
|
||||
self.action_ips = self.selected_ip_list();
|
||||
self.action_kind = kind;
|
||||
let n = self.action_ips.len();
|
||||
let frame = Widget::main_frame();
|
||||
let title = match kind {
|
||||
PromptKind::Power => "Set power limit",
|
||||
PromptKind::Power => "Set power target",
|
||||
PromptKind::HashRateTarget => "Set hashrate target",
|
||||
PromptKind::Tuning => "Set tuning percent",
|
||||
PromptKind::Timezone => "Set timezone",
|
||||
PromptKind::Password => "Change password",
|
||||
};
|
||||
let dlg = Widget::dialog(frame, title);
|
||||
let root = Widget::box_sizer(true);
|
||||
// Append the current target and the advertised valid range to the target
|
||||
// prompts (round 17 C), so the operator sees what the firmware will accept.
|
||||
let target_hint = |range: Option<(f64, f64)>, cur: Option<String>, unit: &str| {
|
||||
let mut s = String::new();
|
||||
if let Some(c) = cur {
|
||||
s.push_str(&format!("\nCurrent: {c}."));
|
||||
}
|
||||
if let Some((a, b)) = range {
|
||||
s.push_str(&format!(" Valid range: {a:.0}-{b:.0} {unit}."));
|
||||
}
|
||||
s
|
||||
};
|
||||
let lbl = match kind {
|
||||
PromptKind::Power => format!("Power limit in watts for {n} miner(s):"),
|
||||
PromptKind::Power => {
|
||||
let (range, cur) = self.selected_envelope(|r| (r.power_target_min_w, r.power_target_max_w));
|
||||
format!("Power target in watts for {n} miner(s):{}", target_hint(range, cur, "W"))
|
||||
}
|
||||
PromptKind::HashRateTarget => {
|
||||
let (range, cur) =
|
||||
self.selected_envelope(|r| (r.hashrate_target_min_ths, r.hashrate_target_max_ths));
|
||||
format!("Hashrate target in TH/s for {n} miner(s):{}", target_hint(range, cur, "TH/s"))
|
||||
}
|
||||
PromptKind::Tuning => format!("Tuning percent (0-100) for {n} miner(s):"),
|
||||
PromptKind::Timezone => format!("IANA timezone (e.g. America/Edmonton) for {n} miner(s):"),
|
||||
PromptKind::Password => format!("New web/API password for {n} miner(s):"),
|
||||
@@ -2206,9 +2272,35 @@ impl App {
|
||||
/// captured selection) so the operator can correct it.
|
||||
fn apply_action_prompt(&mut self) {
|
||||
let val = self.action_input.get_value();
|
||||
// A target must be positive, finite, and within the advertised range when
|
||||
// one exists (round 17 C).
|
||||
let in_range = |v: f64, range: Option<(f64, f64)>| {
|
||||
v > 0.0 && v.is_finite() && range.map_or(true, |(a, b)| v >= a && v <= b)
|
||||
};
|
||||
let action = match self.action_kind {
|
||||
PromptKind::Power => match val.trim().parse::<f64>() {
|
||||
Ok(w) if w > 0.0 && w.is_finite() => Some(scan::ConfigAction::PowerLimit(w)),
|
||||
Ok(w)
|
||||
if in_range(
|
||||
w,
|
||||
self.selected_envelope(|r| (r.power_target_min_w, r.power_target_max_w)).0,
|
||||
) =>
|
||||
{
|
||||
Some(scan::ConfigAction::PowerLimit(w))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
PromptKind::HashRateTarget => match val.trim().parse::<f64>() {
|
||||
Ok(t)
|
||||
if in_range(
|
||||
t,
|
||||
self.selected_envelope(|r| {
|
||||
(r.hashrate_target_min_ths, r.hashrate_target_max_ths)
|
||||
})
|
||||
.0,
|
||||
) =>
|
||||
{
|
||||
Some(scan::ConfigAction::HashRateTarget(t))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
PromptKind::Tuning => match val.trim().parse::<u8>() {
|
||||
@@ -2237,7 +2329,8 @@ impl App {
|
||||
}
|
||||
None => {
|
||||
let hint = match self.action_kind {
|
||||
PromptKind::Power => "enter a positive number of watts",
|
||||
PromptKind::Power => "enter a number of watts within the valid range",
|
||||
PromptKind::HashRateTarget => "enter a hashrate in TH/s within the valid range",
|
||||
PromptKind::Tuning => "enter a percent from 0 to 100",
|
||||
PromptKind::Timezone => "enter a valid IANA zone, e.g. America/Edmonton",
|
||||
PromptKind::Password => "enter a non-empty password",
|
||||
|
||||
Reference in New Issue
Block a user