Counter ASIC 3.0 PC 1 AMD: the identities job posts the app's cards-array shape (400 on the flat object) and prints the live lines from the caller (a function's output joins its return value)
This commit is contained in:
parent
fc0441d4cb
commit
d118a18d0c
1 changed files with 14 additions and 13 deletions
|
|
@ -26,27 +26,27 @@ if (-not $base) { "RESULT identities error=no app.url under ${appDir}: nothing p
|
|||
$wantKey = 'amd:gfx1201'
|
||||
$wantIdent = 8
|
||||
|
||||
function ReadLive([string] $tag) {
|
||||
# the 9070 XT's live entry from api/state: key, identities, state, pid, MH/s now and avg, watts
|
||||
function ReadLive {
|
||||
# the 9070 XT's live entry from api/state: the object only (a function's every output joins its return value in
|
||||
# PowerShell, so the RESULT line is printed by the caller, never inside here)
|
||||
try {
|
||||
$st = Invoke-RestMethod -Uri "$base/api/state" -Method GET -TimeoutSec 10
|
||||
$cards = $st.mining.cards; if (-not $cards) { $cards = $st.cards }
|
||||
foreach ($c in @($cards)) {
|
||||
if ($c.vendor -eq 'amd' -and ("$($c.key)" -match 'gfx1201')) {
|
||||
"RESULT live_$tag key=$($c.key) enabled=$($c.enabled) identities=$($c.identities) state=$($c.state) pid=$($c.pid) mhs_now=$($c.hash_now) mhs_avg=$($c.hash_avg) watts=$($c.power_w) at=$(Stamp)"
|
||||
return $c
|
||||
}
|
||||
}
|
||||
"RESULT live_$tag error=no gfx1201 card in api/state"
|
||||
foreach ($c in @($cards)) { if ($c.vendor -eq 'amd' -and ("$($c.key)" -match 'gfx1201')) { return $c } }
|
||||
return $null
|
||||
} catch { "RESULT live_$tag error=$($_.Exception.Message)"; return $null }
|
||||
} catch { return $null }
|
||||
}
|
||||
function LiveLine([string] $tag, $c) {
|
||||
if ($c) { "RESULT live_$tag key=$($c.key) enabled=$($c.enabled) identities=$($c.identities) state=$($c.state) pid=$($c.pid) mhs_now=$($c.hash_now) mhs_avg=$($c.hash_avg) watts=$($c.power_w) at=$(Stamp)" }
|
||||
else { "RESULT live_$tag error=no gfx1201 card in api/state (or api/state answered nothing)" }
|
||||
}
|
||||
|
||||
$before = ReadLive 'before'
|
||||
$before = ReadLive
|
||||
LiveLine 'before' $before
|
||||
if ($before -and "$($before.key)" -ne $wantKey) { "RESULT identities note=the live key is $($before.key), not $wantKey; posting to $wantKey as main ordered, the live key read after decides" }
|
||||
|
||||
# the one POST
|
||||
$body = @{ key = $wantKey; enabled = $true; identities = $wantIdent } | ConvertTo-Json -Compress
|
||||
$body = @{ cards = @(@{ key = $wantKey; enabled = $true; identities = $wantIdent }) } | ConvertTo-Json -Depth 5 # the app's shape: a cards array (server.rs /api/cards), as the g1-shadow job posts it
|
||||
try {
|
||||
Invoke-RestMethod -Uri "$base/api/cards" -Method POST -Body $body -ContentType 'application/json' -TimeoutSec 10 | Out-Null
|
||||
"RESULT posted key=$wantKey enabled=true identities=$wantIdent at=$(Stamp)"
|
||||
|
|
@ -55,7 +55,8 @@ try {
|
|||
# settle: the card's worker restarts under the new count; the rate needs its first STATUS window
|
||||
"RESULT settle 120 s"
|
||||
Start-Sleep -Seconds 120
|
||||
$after = ReadLive 'after'
|
||||
$after = ReadLive
|
||||
LiveLine 'after' $after
|
||||
|
||||
$ok = $false
|
||||
if ($after) { $ok = ("$($after.identities)" -eq "$wantIdent") -and ($after.state -eq 'mining') }
|
||||
|
|
|
|||
Loading…
Reference in a new issue