protected void FillAlgorithm(string aname, ref APIData AD) { if (CurrentMiningAlgorithm.MinerName.Equals(aname)) { AD.AlgorithmID = CurrentMiningAlgorithm.NiceHashID; AD.AlgorithmName = CurrentMiningAlgorithm.NiceHashName; } }
protected async Task <APIData> GetSummaryCPUAsync(string method = "", bool overrideLoop = false) { APIData ad = new APIData(MiningSetup.CurrentAlgorithmType); try { _currentMinerReadStatus = MinerAPIReadStatus.WAIT; string dataToSend = GetHttpRequestNHMAgentStrin(method); string respStr = await GetAPIDataAsync(APIPort, dataToSend); if (String.IsNullOrEmpty(respStr)) { _currentMinerReadStatus = MinerAPIReadStatus.NETWORK_EXCEPTION; throw new Exception("Response is empty!"); } if (respStr.IndexOf("HTTP/1.1 200 OK") > -1) { respStr = respStr.Substring(respStr.IndexOf(HTTPHeaderDelimiter) + HTTPHeaderDelimiter.Length); } else { throw new Exception("Response not HTTP formed! " + respStr); } dynamic resp = JsonConvert.DeserializeObject(respStr); if (resp != null) { JArray totals = resp.hashrate.total; foreach (var total in totals) { if (total.Value <string>() == null) { continue; } ad.Speed = total.Value <double>(); break; } if (ad.Speed == 0) { _currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO; } else { _currentMinerReadStatus = MinerAPIReadStatus.GOT_READ; } } else { throw new Exception($"Response does not contain speed data: {respStr.Trim()}"); } } catch (Exception ex) { Helpers.ConsolePrint(MinerTAG(), ex.Message); } return(ad); }
protected void FillAlgorithm(string aname, ref APIData AD) { for (int i = 0; i < SupportedAlgorithms.Length; i++) { if (SupportedAlgorithms[i].MinerName.Equals(aname)) { AD.AlgorithmID = SupportedAlgorithms[i].NiceHashID; AD.AlgorithmName = SupportedAlgorithms[i].NiceHashName; } } }
protected async Task <APIData> GetSummaryCPU_CCMINERAsync() { string resp; // TODO aname string aname = null; APIData ad = new APIData(MiningSetup.CurrentAlgorithmType); string DataToSend = GetHttpRequestNHMAgentStrin("summary"); resp = await GetAPIDataAsync(APIPort, DataToSend); if (resp == null) { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " summary is null"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return(null); } try { string[] resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) { continue; } if (optval[0] == "ALGO") { aname = optval[1]; } else if (optval[0] == "KHS") { ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } } catch { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Could not read data from API bind port"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return(null); } _currentMinerReadStatus = MinerAPIReadStatus.GOT_READ; // check if speed zero if (ad.Speed == 0) { _currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO; } return(ad); }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatSpeedOutput(iAPIData.Speed) + iAPIData.AlgorithmName + ApiGetExceptionString; string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = CurrencyConverter.CurrencyConverter.ConvertToActiveCurrency(paying * Globals.BitcoinRate).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ConfigManager.Instance.GeneralConfig.DisplayCurrency) + International.GetText("Day"); ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); UpdateGlobalRate(); }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatDualSpeedOutput(iAPIData.AlgorithmID, iAPIData.Speed, iAPIData.SecondarySpeed) + iAPIData.AlgorithmName + ApiGetExceptionString; string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = ExchangeRateAPI.ConvertToActiveCurrency(paying * Globals.BitcoinUSDRate * factorTimeUnit).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ExchangeRateAPI.ActiveDisplayCurrency) + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); try { // flowLayoutPanelRatesIndex may be OOB, so catch ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); } catch { } UpdateGlobalRate(); }
private void MinerStatsCheck_Tick(object sender, EventArgs e) { string CPUAlgoName = ""; double CPUTotalSpeed = 0; double CPUTotalRate = 0; foreach (Miner m in Miners) { if (m.EnabledDeviceCount() == 0) { continue; } APIData AD = m.GetSummary(); if (AD == null) { // API is inaccessible, try to restart miner m.Restart(); continue; } if (NiceHashData != null) { m.CurrentRate = NiceHashData[AD.AlgorithmID].paying * AD.Speed * 0.000000001; } if (m is cpuminer) { CPUAlgoName = AD.AlgorithmName; CPUTotalSpeed += AD.Speed; CPUTotalRate += m.CurrentRate; } else if (m is ccminer_tpruvot) { SetNVIDIAtpStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } else if (m is ccminer_sp) { SetNVIDIAspStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } } if (CPUAlgoName.Length > 0) { SetCPUStats(CPUAlgoName, CPUTotalSpeed, CPUTotalRate); } }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatDualSpeedOutput(iAPIData.Speed, iAPIData.SecondarySpeed) + iAPIData.AlgorithmName + ApiGetExceptionString; if (iAPIData.AlgorithmID == AlgorithmType.Equihash) { speedString = speedString.Replace("H/s", "Sols/s"); } string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = ExchangeRateAPI.ConvertToActiveCurrency(paying * Globals.BitcoinUSDRate).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ExchangeRateAPI.ActiveDisplayCurrency) + International.GetText("Day"); ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); UpdateGlobalRate(); }
public APIData GetSummary() { string resp = GetAPIData(APIPort, "summary"); if (resp == null) { return(null); } string aname = null; APIData ad = new APIData(); try { string[] resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) { continue; } if (optval[0] == "ALGO") { aname = optval[1]; } else if (optval[0] == "KHS") { ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } } catch { return(null); } FillAlgorithm(aname, ref ad); return(ad); }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, List <String> devNames, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatDualSpeedOutput(iAPIData.Speed, iAPIData.SecondarySpeed) + iAPIData.AlgorithmName + ApiGetExceptionString; if (iAPIData.AlgorithmID == AlgorithmType.Equihash) { speedString = speedString.Replace("H/s", "Sols/s"); } string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = ExchangeRateAPI.ConvertToActiveCurrency(paying * Globals.BitcoinUSDRate).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ExchangeRateAPI.ActiveDisplayCurrency) + International.GetText("Day"); ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); double Balance = NiceHashStats.GetBalance(textBoxBTCAddress.Text.Trim(), textBoxBTCAddress.Text.Trim() + "." + textBoxWorkerName.Text.Trim()); Dictionary <string, string> localDevNames = new Dictionary <string, string>(); localDevNames = new Dictionary <string, string>(); localDevNames["Devices"] = String.Join(",", devNames.ToArray()); localDevNames["BTCExRate"] = ExchangeRateAPI.ConvertToActiveCurrency(Globals.BitcoinUSDRate).ToString("F2", CultureInfo.InvariantCulture) + " " + ExchangeRateAPI.ActiveDisplayCurrency; localDevNames["BTCBalance"] = (Balance * 1000).ToString("F5", CultureInfo.InvariantCulture); bool found = false; int pos = 0; foreach (Dictionary <string, string> foundData in hashData) { if (foundData.ContainsKey("Devices")) { hashData[pos] = localDevNames; found = true; break; } pos++; } if (!found) { hashData.Add(localDevNames); } string[] devicesStrings = deviceStringInfo.Trim('{', ' ').Trim(' ', '}').Split(new string[] { ", " }, StringSplitOptions.None); Dictionary <string, string> localData = new Dictionary <string, string>(); localData = new Dictionary <string, string>(); localData["DeviceInfo"] = deviceStringInfo; localData["Speed"] = speedString; localData["RateBTC"] = rateBTCString; localData["RateCurrency"] = rateCurrencyString; localData["GroupName"] = groupName; found = false; pos = 0; foreach (Dictionary <string, string> foundData in hashData.ToArray()) { if (foundData.ContainsKey("GroupName")) { if (foundData["GroupName"] == groupName) { hashData[pos] = localData; found = true; break; } else { foreach (string deviceString in devicesStrings) { if (foundData["DeviceInfo"].Contains(deviceString)) { hashData.RemoveAt(pos); pos--; break; } } } } pos++; } if (!found) { hashData.Add(localData); } UpdateGlobalRate(); }
private void MinerStatsCheck_Tick(object sender, EventArgs e) { string CPUAlgoName = ""; double CPUTotalSpeed = 0; double CPUTotalRate = 0; // Reset all stats SetCPUStats("", 0, 0); SetNVIDIAtp21Stats("", 0, 0); SetNVIDIAspStats("", 0, 0); SetNVIDIAtpStats("", 0, 0); SetAMDOpenCLStats("", 0, 0); foreach (Miner m in Miners) { if (m.EnabledDeviceCount() == 0) { continue; } APIData AD = m.GetSummary(); if (AD == null) { // Make sure sgminer or ethminer has time to start // properly on slow CPU system if (m.StartingUpDelay && m.NumRetries > 0) { m.NumRetries--; if (m.NumRetries == 0) { m.StartingUpDelay = false; } Helpers.ConsolePrint(m.MinerDeviceName, "NumRetries: " + m.NumRetries); continue; } if (m is sgminer && m.NumRetries > 0 && !m.AlgoNameIs("ethereum")) { m.NumRetries--; continue; } // API is inaccessible, try to restart miner m.Restart(); continue; } else { m.StartingUpDelay = false; } if (NiceHashData != null) { m.CurrentRate = NiceHashData[AD.AlgorithmID].paying * AD.Speed * 0.000000001; } if (m is cpuminer) { CPUAlgoName = AD.AlgorithmName; CPUTotalSpeed += AD.Speed; CPUTotalRate += m.CurrentRate; } else if (m is ccminer_tpruvot_sm21) { SetNVIDIAtp21Stats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } else if (m is ccminer_tpruvot) { SetNVIDIAtpStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } else if (m is ccminer_sp) { SetNVIDIAspStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } else if (m is sgminer) { SetAMDOpenCLStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } } if (CPUAlgoName.Length > 0) { SetCPUStats(CPUAlgoName, CPUTotalSpeed, CPUTotalRate); } }
private void MinerStatsCheck_Tick(object sender, EventArgs e) { string CPUAlgoName = ""; double CPUTotalSpeed = 0; double CPUTotalRate = 0; // Reset all stats SetCPUStats("", 0, 0); SetNVIDIAtp21Stats("", 0, 0); SetNVIDIAspStats("", 0, 0); SetNVIDIAtpStats("", 0, 0); SetAMDOpenCLStats("", 0, 0); foreach (Miner m in Globals.Miners) { if (!m.IsRunning) { continue; } if (m is cpuminer && m.AlgoNameIs("hodl")) { string pname = m.Path.Split('\\')[2]; pname = pname.Substring(0, pname.Length - 4); Process[] processes = Process.GetProcessesByName(pname); if (processes.Length < CPUID.GetPhysicalProcessorCount()) { m.Restart(); } int algoIndex = m.GetAlgoIndex("hodl"); CPUAlgoName = "hodl"; CPUTotalSpeed = m.SupportedAlgorithms[algoIndex].BenchmarkSpeed; CPUTotalRate = Globals.NiceHashData[m.SupportedAlgorithms[algoIndex].NiceHashID].paying * CPUTotalSpeed * 0.000000001; continue; } APIData AD = m.GetSummary(); if (AD == null) { Helpers.ConsolePrint(m.MinerDeviceName, "GetSummary returned null.."); // Make sure sgminer has time to start // properly on slow CPU system if (m.StartingUpDelay && m.NumRetries > 0) { m.NumRetries--; if (m.NumRetries == 0) { m.StartingUpDelay = false; } Helpers.ConsolePrint(m.MinerDeviceName, "NumRetries: " + m.NumRetries); continue; } // API is inaccessible, try to restart miner m.Restart(); continue; } else { m.StartingUpDelay = false; } if (Globals.NiceHashData != null) { m.CurrentRate = Globals.NiceHashData[AD.AlgorithmID].paying * AD.Speed * 0.000000001; } else { m.CurrentRate = 0; } if (m is cpuminer) { CPUAlgoName = AD.AlgorithmName; CPUTotalSpeed += AD.Speed; CPUTotalRate += m.CurrentRate; } else if (m is ccminer_tpruvot_sm21) { SetNVIDIAtp21Stats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } else if (m is ccminer_tpruvot) { SetNVIDIAtpStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } else if (m is ccminer_sp) { SetNVIDIAspStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } else if (m is sgminer) { SetAMDOpenCLStats(AD.AlgorithmName, AD.Speed, m.CurrentRate); } } if (CPUAlgoName != null && CPUAlgoName.Length > 0) { SetCPUStats(CPUAlgoName, CPUTotalSpeed, CPUTotalRate); } }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatSpeedOutput(iAPIData.Speed) + iAPIData.AlgorithmName + ApiGetExceptionString; if (iAPIData.AlgorithmID == AlgorithmType.Equihash) { speedString = speedString.Replace("H/s", "Sols/s"); } string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = CurrencyConverter.ConvertToActiveCurrency(paying * Globals.BitcoinRate).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", CurrencyConverter.ActiveDisplayCurrency) + International.GetText("Day"); ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); UpdateGlobalRate(); }
public APIData GetSummary() { string resp; string aname = null; APIData ad = new APIData(); if (AlgoNameIs("ethereum")) { try { resp = NiceHashStats.GetNiceHashAPIData("http://127.0.0.1:" + Config.ConfigData.APIBindPortEthereumFrontEnd + "/stats", MinerDeviceName); if (resp == null) { return(null); } if (resp.Length < 800) { return(null); // response is too short } Eth <EthMiner> oo; oo = JsonConvert.DeserializeObject <Eth <EthMiner> >(resp); ad.Speed = 0; aname = "ethereum"; for (int i = 0; i < oo.miners.Length; i++) { if (!oo.miners[i].name.Equals(MinerDeviceName)) { continue; } if (oo.miners[i].timeout == true) { Helpers.ConsolePrint(MinerDeviceName, "Ethminer ERROR!"); return(null); } else if (oo.miners[i].warning == true) { Helpers.ConsolePrint(MinerDeviceName, "Ethminer WARNING!"); } ad.Speed = oo.miners[i].hashrate * 1000; break; } if (ad.Speed == 0) { return(null); } } catch (Exception e) { Helpers.ConsolePrint(MinerDeviceName, "GetSummary: " + e.Message); return(null); } } else { resp = GetAPIData(APIPort, "summary"); if (resp == null) { return(null); } try { string[] resps; if (!MinerDeviceName.Equals("AMD_OpenCL")) { resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) { continue; } if (optval[0] == "ALGO") { aname = optval[1]; } else if (optval[0] == "KHS") { ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } } else { // Checks if all the GPUs are Alive first string resp2 = GetAPIData(APIPort, "devs"); if (resp2 == null) { return(null); } string[] checkGPUStatus = resp2.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < checkGPUStatus.Length - 1; i++) { if (!checkGPUStatus[i].Contains("Status=Alive")) { Helpers.ConsolePrint(MinerDeviceName, "GPU " + i + ": Sick/Dead/NoStart/Initialising/Disabled/Rejecting/Unknown"); return(null); } } resps = resp.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (resps[1].Contains("SUMMARY")) { string[] data = resps[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total speed string[] speed = data[4].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total MH double total_mh = Double.Parse(data[18].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1], new CultureInfo("en-US")); ad.Speed = Double.Parse(speed[1]) * 1000; aname = SupportedAlgorithms[CurrentAlgo].MinerName; if (total_mh <= PreviousTotalMH) { Helpers.ConsolePrint(MinerDeviceName, "SGMiner might be stuck as no new hashes are being produced"); Helpers.ConsolePrint(MinerDeviceName, "Prev Total MH: " + PreviousTotalMH + " .. Current Total MH: " + total_mh); return(null); } PreviousTotalMH = total_mh; } else { ad.Speed = 0; } } } catch { return(null); } } FillAlgorithm(aname, ref ad); return(ad); }
public APIData GetSummary() { string resp; string aname = null; APIData ad = new APIData(); if (AlgoNameIs("daggerhashimoto")) { try { FillAlgorithm("daggerhashimoto", ref ad); if (ER.GetIsRunning() && ER.GetDAGprogress() != 100 && ER.GetSpeed() < 1) { ad.AlgorithmName = "Creating DAG " + ER.GetDAGprogress().ToString() + "%"; aname = "Creating DAG File"; ad.Speed = 0; } else { double time = 10; if (ER.GetIsRunning()) { time = 30; } if ((DateTime.Now.Subtract(ER.GetLastActiveTime())).TotalSeconds > time) { Helpers.ConsolePrint(MinerDeviceName, "ethminer is not running.. restarting.."); Restart(); return(null); } ad.Speed = ER.GetSpeed() * 1000 * 1000; } } catch (Exception e) { Helpers.ConsolePrint(MinerDeviceName, "GetSummary: " + e.Message); return(null); } } else { resp = GetAPIData(APIPort, "summary"); if (resp == null) { return(null); } try { string[] resps; if (!MinerDeviceName.Equals("AMD_OpenCL")) { resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) { continue; } if (optval[0] == "ALGO") { aname = optval[1]; } else if (optval[0] == "KHS") { ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } } else { // Checks if all the GPUs are Alive first string resp2 = GetAPIData(APIPort, "devs"); if (resp2 == null) { return(null); } string[] checkGPUStatus = resp2.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < checkGPUStatus.Length - 1; i++) { if (!checkGPUStatus[i].Contains("Status=Alive")) { Helpers.ConsolePrint(MinerDeviceName, "GPU " + i + ": Sick/Dead/NoStart/Initialising/Disabled/Rejecting/Unknown"); return(null); } } resps = resp.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (resps[1].Contains("SUMMARY")) { string[] data = resps[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total speed string[] speed = data[4].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total MH double total_mh = Double.Parse(data[18].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1], new CultureInfo("en-US")); ad.Speed = Double.Parse(speed[1]) * 1000; aname = SupportedAlgorithms[CurrentAlgo].MinerName; if (total_mh <= PreviousTotalMH) { Helpers.ConsolePrint(MinerDeviceName, "SGMiner might be stuck as no new hashes are being produced"); Helpers.ConsolePrint(MinerDeviceName, "Prev Total MH: " + PreviousTotalMH + " .. Current Total MH: " + total_mh); return(null); } PreviousTotalMH = total_mh; } else { ad.Speed = 0; } } } catch { return(null); } FillAlgorithm(aname, ref ad); } return(ad); }
protected APIData GetSummaryCPU_CCMINER() { string resp; // TODO aname string aname = null; APIData ad = new APIData(MiningSetup.CurrentAlgorithmType); resp = GetAPIData(APIPort, "summary"); if (resp == null) { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " summary is null"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return null; } try { string[] resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) continue; if (optval[0] == "ALGO") aname = optval[1]; else if (optval[0] == "KHS") ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } catch { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Could not read data from API bind port"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return null; } _currentMinerReadStatus = MinerAPIReadStatus.GOT_READ; // check if speed zero if (ad.Speed == 0) _currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO; return ad; }
protected void FillAlgorithm(string aname, ref APIData AD) { for (int i = 0; i < SupportedAlgorithms.Length; i++) { if (SupportedAlgorithms[i].MinerName == aname) { AD.AlgorithmID = SupportedAlgorithms[i].NiceHashID; AD.AlgorithmName = SupportedAlgorithms[i].NiceHashName; } } }
public APIData GetSummary() { string resp = GetAPIData(APIPort, "summary"); if (resp == null) return null; string aname = null; APIData ad = new APIData(); try { string[] resps; if (MinerDeviceName != "AMD_OpenCL") { resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) continue; if (optval[0] == "ALGO") aname = optval[1]; else if (optval[0] == "KHS") ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } else { // Checks if all the GPUs are Alive first string resp2 = GetAPIData(APIPort, "devs"); if (resp2 == null) return null; string [] checkGPUStatus = resp2.Split(new char [] { '|' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < checkGPUStatus.Length - 1; i++) { if (!checkGPUStatus[i].Contains("Status=Alive")) { Helpers.ConsolePrint("GPU " + i + ": Sick/Dead/NoStart/Initialising/Disabled/Rejecting/Unknown"); return null; } } Helpers.ConsolePrint("AMD_OpenCL: All GPUs are alive"); resps = resp.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (resps.Length == 3) { string[] data = resps[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total speed string[] speed = data[4].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total MH double total_mh = Double.Parse(data[18].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1]); ad.Speed = Double.Parse(speed[1]) * 1000; aname = SupportedAlgorithms[CurrentAlgo].MinerName; if (total_mh <= PreviousTotalMH) { Helpers.ConsolePrint("AMD_OpenCL: sgminer might be stuck as no new hashes are being produced"); Helpers.ConsolePrint("Prev Total MH: " + PreviousTotalMH + " .. Current Total MH: " + total_mh); return null; } PreviousTotalMH = total_mh; } else { ad.Speed = 0; } } } catch { return null; } FillAlgorithm(aname, ref ad); return ad; }
public APIData GetSummary() { string resp = GetAPIData(APIPort, "summary"); if (resp == null) return null; string aname = null; APIData ad = new APIData(); try { string[] resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) continue; if (optval[0] == "ALGO") aname = optval[1]; else if (optval[0] == "KHS") ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } catch { return null; } FillAlgorithm(aname, ref ad); return ad; }
public APIData GetSummary() { string resp; string aname = null; APIData ad = new APIData(); if (AlgoNameIs("daggerhashimoto")) { FillAlgorithm("daggerhashimoto", ref ad); bool ismining; if (!ethminerLink.GetSpeed(out ismining, out ad.Speed)) { if (NumRetries > 0) { NumRetries--; ad.Speed = 0; return(ad); } Helpers.ConsolePrint(MinerDeviceName, "ethminer is not running.. restarting.."); Stop(false); _Start(); ad.Speed = 0; return(ad); } else if (!ismining) { // resend start mining command ethminerLink.StartMining(); } ad.Speed *= 1000 * 1000; } else { resp = GetAPIData(APIPort, "summary"); if (resp == null) { return(null); } try { string[] resps; if (!MinerDeviceName.Equals("AMD_OpenCL")) { resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) { continue; } if (optval[0] == "ALGO") { aname = optval[1]; } else if (optval[0] == "KHS") { ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } } else { // Checks if all the GPUs are Alive first string resp2 = GetAPIData(APIPort, "devs"); if (resp2 == null) { return(null); } string[] checkGPUStatus = resp2.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < checkGPUStatus.Length - 1; i++) { if (!checkGPUStatus[i].Contains("Status=Alive")) { Helpers.ConsolePrint(MinerDeviceName, "GPU " + i + ": Sick/Dead/NoStart/Initialising/Disabled/Rejecting/Unknown"); return(null); } } resps = resp.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (resps[1].Contains("SUMMARY")) { string[] data = resps[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total speed string[] speed = data[4].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); // Get miner's current total MH double total_mh = Double.Parse(data[18].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1], new CultureInfo("en-US")); ad.Speed = Double.Parse(speed[1]) * 1000; aname = SupportedAlgorithms[CurrentAlgo].MinerName; if (total_mh <= PreviousTotalMH) { Helpers.ConsolePrint(MinerDeviceName, "SGMiner might be stuck as no new hashes are being produced"); Helpers.ConsolePrint(MinerDeviceName, "Prev Total MH: " + PreviousTotalMH + " .. Current Total MH: " + total_mh); return(null); } PreviousTotalMH = total_mh; } else { ad.Speed = 0; } } } catch { return(null); } FillAlgorithm(aname, ref ad); } return(ad); }