package com.btctoronto.antminer.s1;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class FindS1sEffHashrate {
public static void main(String[] args) {
try {
WebDriver wdDriver = new HtmlUnitDriver();
//Get login page
wdDriver.get("http://192.168.1.102/"); //Put your S1's IP here.
//Find the username and password input fields and enter your values
WebElement weUsername = wdDriver.findElement(By.className("cbi-input-user"));
weUsername.clear();
weUsername.sendKeys("root");
WebElement wePassword = wdDriver.findElement(By.className("cbi-input-password"));
wePassword.clear();
wePassword.sendKeys("YourPrettyComplicated(IHope)Password");
wePassword.submit();
//Go to Miner Status page and pull the required data
WebElement weMinerStatus = wdDriver.findElement(By.linkText("Miner Status"));
String sLink = weMinerStatus.getAttribute("href");
wdDriver.get(sLink);
double fGHs = Double.parseDouble(wdDriver.findElement(By.id("cbi-table-1-ghsav")).getText().replaceAll(",", ""));
long fHWE = Long.parseLong(wdDriver.findElement(By.id("cbi-table-1-hw")).getText().replaceAll(",", ""));
long fDiffA = Long.parseLong(wdDriver.findElement(By.id("cbi-table-1-diffaccepted")).getText().replaceAll(",", ""));
long fDiffR = Long.parseLong(wdDriver.findElement(By.id("cbi-table-1-diffrejected")).getText().replaceAll(",", ""));
double fEffGHs = 1.0 * (fDiffA + fDiffR) / (fDiffA + fDiffR + fHWE) * fGHs;
//Display the data
System.out.println("Miner has been running for: " + wdDriver.findElement(By.id("cbi-table-1-elapsed")).getText());
System.out.println("Reported GH/s: " + fGHs);
System.out.println("HW errors: " + fHWE);
System.out.println("Accepted difficulty: " + fDiffA);
System.out.println("Rejected difficulty: " + fDiffR);
System.out.println("Effective hash rate: " + fEffGHs);
} catch (NoSuchElementException e) {
e.printStackTrace();
}
catch (Exception e) {
// TODO: handle exception
}
}
}
BTC TO