diff --git a/miner.php b/miner.php index 6e501ba6..14b249ee 100644 --- a/miner.php +++ b/miner.php @@ -1,7 +1,7 @@ td { color:blue; font-family:verdana,arial,sans; font-size:13pt; } td.h { color:blue; font-family:verdana,arial,sans; font-size:13pt; background:#d0ffff } +td.err { color:black; font-family:verdana,arial,sans; font-size:13pt; background:#ff3050 } +td.warn { color:black; font-family:verdana,arial,sans; font-size:13pt; background:#ffb050 } td.sta { color:green; font-family:verdana,arial,sans; font-size:13pt; } @@ -177,55 +185,87 @@ function getparam($name, $both = false) # function fmt($section, $name, $value) { + $errorclass = ' class=err'; + $warnclass = ' class=warn'; $b = ' '; + $ret = $value; + $class = ''; + switch ($section.'.'.$name) { case 'GPU.Last Share Time': case 'PGA.Last Share Time': - return date('H:i:s', $value); + $ret = date('H:i:s', $value); break; case 'SUMMARY.Elapsed': $s = $value % 60; $value -= $s; $value /= 60; if ($value == 0) - { - return $s.'s'; - } + $ret = $s.'s'; else { $m = $value % 60; $value -= $m; $value /= 60; if ($value == 0) - { - return sprintf("%dm$b%02ds", $m, $s); - } + $ret = sprintf("%dm$b%02ds", $m, $s); else { $h = $value % 24; $value -= $h; $value /= 24; if ($value == 0) - return sprintf("%dh$b%02dm$b%02ds", $h, $m, $s); + $ret = sprintf("%dh$b%02dm$b%02ds", $h, $m, $s); else - return sprintf("%ddays$b%02dh$b%02dm$b%02ds", $value, $h, $m, $s); + $ret = sprintf("%ddays$b%02dh$b%02dm$b%02ds", $value, $h, $m, $s); } } break; + case 'NOTIFY.Last Well': + if ($value == '0') + { + $ret = 'Never'; + $class = $warnclass; + } + else + $ret = date('H:i:s', $value); + break; + case 'NOTIFY.Last Not Well': + if ($value == '0') + $ret = 'Never'; + else + { + $ret = date('H:i:s', $value); + $class = $errorclass; + } + break; + case 'NOTIFY.Reason Not Well': + if ($value != 'None') + $class = $errorclass; + break; case 'GPU.Utility': case 'PGA.Utility': case 'SUMMARY.Utility': - return $value.'/m'; + $ret = $value.'/m'; break; case 'GPU.Temperature': case 'PGA.Temperature': - return $value.'°C'; + $ret = $value.'°C'; break; } - return $value; + if ($section == 'NOTIFY') + { + $code = preg_split('/ /', $name); + if (count($code) > 1) + if ($code[0] == 'Thread' || $code[0] == 'Dev') + if ($value != '0') + $class = $errorclass; + } + + return array($ret, $class); } # global $poolcmd; @@ -302,7 +342,10 @@ function details($cmd, $list) echo ''; foreach ($values as $name => $value) - echo ''.fmt($section, $name, $value).''; + { + list($showvalue, $class) = fmt($section, $name, $value); + echo "$showvalue"; + } if ($cmd == 'pools' && $readonly === false) { @@ -444,7 +487,7 @@ function process($cmds, $rd, $ro) # function display() { - global $error, $readonly; + global $error, $readonly, $notify; $error = null; @@ -464,8 +507,12 @@ function display() $cmds = array( 'devs' => 'device list', 'summary' => 'summary information', - 'pools' => 'pool list', - 'config' => 'cgminer config'); + 'pools' => 'pool list'); + + if ($notify) + $cmds['notify'] = 'device status'; + + $cmds['config'] = 'cgminer config'; process($cmds, $rd, $ro);