protected double BenchmarkParseLine_cpu_ccminer_extra(string outdata) { // parse line if (outdata.Contains("Benchmark: ") && outdata.Contains("/s")) { int i = outdata.IndexOf("Benchmark:"); int k = outdata.IndexOf("/s"); string hashspeed = outdata.Substring(i + 11, k - i - 9); Helpers.ConsolePrint("BENCHMARK", "Final Speed: " + hashspeed); // save speed int b = hashspeed.IndexOf(" "); if (b < 0) { int stub; for (int _i = hashspeed.Length - 1; _i >= 0; --_i) { if (Int32.TryParse(hashspeed[_i].ToString(), out stub)) { b = _i; break; } } } if (b >= 0) { string speedStr = hashspeed.Substring(0, b); double spd = Helpers.ParseDouble(speedStr); if (hashspeed.Contains("kH/s")) { spd *= 1000; } else if (hashspeed.Contains("MH/s")) { spd *= 1000000; } else if (hashspeed.Contains("GH/s")) { spd *= 1000000000; } return(spd); } } return(0.0d); }
public static void UpdateApi(string worker) { var resp = NiceHashStats.GetNiceHashApiData(ApiUrl, worker); if (resp != null) { try { var lastResponse = JsonConvert.DeserializeObject <ExchangeRateJson>(resp, Globals.JsonSettings); // set that we have a response if (lastResponse != null) { var lastResult = lastResponse.result; _exchangesFiat = lastResult.exchanges_fiat; if (_exchangesFiat == null) { Helpers.ConsolePrint("CurrencyConverter", "Unable to retrieve update, Falling back to USD"); ActiveDisplayCurrency = "USD"; } else { ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; } // ActiveDisplayCurrency = "USD"; // check if currency avaliable and fill currency list foreach (var pair in lastResult.exchanges) { if (pair.ContainsKey("USD") && pair.ContainsKey("coin") && pair["coin"] == "BTC" && pair["USD"] != null) { _usdBtcRate = Helpers.ParseDouble(pair["USD"]); break; } } } } catch (Exception e) { Helpers.ConsolePrint("ExchangeRateAPI", "UpdateAPI got Exception: " + e.Message); } } else { Helpers.ConsolePrint("ExchangeRateAPI", "UpdateAPI got NULL"); } }