Skip to content
This repository has been archived by the owner on Oct 13, 2019. It is now read-only.

Commit

Permalink
feat/rig-devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Stoyvo committed Jan 23, 2015
1 parent f31aee3 commit 5d3c53a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
4 changes: 4 additions & 0 deletions debug.php
Expand Up @@ -66,6 +66,7 @@ function runCMD($host, $port, $cmd) {
$devdetails = json_decode(runCMD($_POST['address'], $_POST['port'], '{"command":"devdetails"}'), true);
$eStats = json_decode(runCMD($_POST['address'], $_POST['port'], '{"command":"estats","parameter":1}'), true);
$pools = json_decode(runCMD($_POST['address'], $_POST['port'], '{"command":"pools"}'), true);
$ascset = json_decode(runCMD($_POST['address'], $_POST['port'], '{"command":"ascset","parameter":"0, help"}'), true);

echo "<pre>SUMMARY:";
print_r($summary);
Expand All @@ -84,6 +85,9 @@ function runCMD($host, $port, $cmd) {
echo "<pre>POOLS:";
print_r($pools);
echo "</pre>";
echo "<pre>ascset:";
print_r($ascset);
echo "</pre>";
} else if ($_POST['submit'] == 'all') {
// Show errors
ini_set("display_errors", 1);
Expand Down
28 changes: 27 additions & 1 deletion includes/classes/miners/cgminer.php
Expand Up @@ -25,7 +25,6 @@ class Miners_Cgminer extends Miners_Abstract {
// Version Handling
protected $_shareTypePrefix = ''; // This will set shares to 'Difficulty Accepted' or just 'Accepted'


// PUBLIC
public function __construct($rig) {
parent::__construct($rig);
Expand Down Expand Up @@ -291,6 +290,33 @@ public function disableDevice($devType, $devId) {
return $this->cmd('{"command":"'.$devType.'disable","parameter":"'. $devId .'"}');
}

public function updateDevice($deviceData) {
foreach ($deviceData as $devId => $settings) {
foreach ($settings as $key => $val) {
switch ($key) {
case "frequency":
// Currently no options for frequencies
break;
case "intensity":
$this->cmd('{"command":"gpuintensity","parameter":"'. $devId .', '. $val .'"}');
break;
case "fan_percent":
$this->cmd('{"command":"gpufan","parameter":"'. $devId .', '. $val .'"}');
break;
case "engine_clock":
$this->cmd('{"command":"gpuengine","parameter":"'. $devId .', '. $val .'"}');
break;
case "memory_clock":
$this->cmd('{"command":"gpumem","parameter":"'. $devId .', '. $val .'"}');
break;
case "gpu_voltage":
$this->cmd('{"command":"gpuvddc","parameter":"'. $devId .', '. $val .'"}');
break;
}
}
}
}

public function resetStats() {
$this->cmd('{"command":"zero","parameter":"all,false"}');
}
Expand Down
6 changes: 6 additions & 0 deletions includes/classes/rigs.php
Expand Up @@ -65,6 +65,12 @@ public function changeDeviceStatus() {
return $result;
}

public function updateDevices() {
if ($_POST['devices']) {
return $this->_objs[0]->updateDevice($_POST['devices']);
}
}

public function resetStats() {
$this->_objs[0]->resetStats();
}
Expand Down
7 changes: 6 additions & 1 deletion js/rig/script.js
Expand Up @@ -308,9 +308,14 @@
setTimeout(function() {
$(btnIcon).removeClass('ajax-saver');

var successMsg = '<b>Saved!</b><br />Your settings have successfully been saved.';
if ($('#rigDetails .nav-pills .active a').attr('href') == '#devices') {
successMsg = '<b>Saved!</b><br />Attempted to save new device settings.<br />Some devices do not allow settings to be changed.';
}

$().toastmessage('showToast', {
sticky : false,
text : '<b>Saved!</b><br />Your settings have successfully been saved.',
text : successMsg,
type : 'success'
});
}, 500);
Expand Down
2 changes: 1 addition & 1 deletion rig.php
Expand Up @@ -263,7 +263,7 @@
<?php } else if ($dev['type'] == 'ASC' || $dev['type'] == 'PGA') { ?>
<td>
<?php if ($dev['frequency']) { ?>
<input name="devices[<?php echo $dev['id']; ?>][frequency]" type="text" class="form-control" value="<?php echo $dev['frequency']; ?>" />
<input name="devices[<?php echo $dev['id']; ?>][frequency]" type="text" class="form-control" value="<?php echo $dev['frequency']; ?>" disabled="disabled" />
<?php } else { ?>
Unknown
<?php } ?>
Expand Down

0 comments on commit 5d3c53a

Please sign in to comment.