void _antMinerBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { try { _antMinerData = AntminerConnector.GetStats(Ip); } catch (Exception) { } }
void antminerStatusBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { var ant = e.Argument as Antminer; if (ant == null) { return; } _inProgressCount++; var status = new AntminerStatus { Id = ant.Id, IpAddress = ant.IpAddress, Name = ant.Name }; var updatingRow = grdAntminers.Rows.SingleOrDefault(x => x.Tag.Equals(status.Id)); if (updatingRow != null) { grdAntminers.Invoke(new MethodInvoker(() => { updatingRow.Cells[2].Value = "-------------"; })); } try { var summary = AntminerConnector.GetSummary(IPAddress.Parse(ant.IpAddress)); var stats = AntminerConnector.GetStats(IPAddress.Parse(ant.IpAddress)); var hwError = Convert.ToInt32(summary["Hardware Errors"].ToString()); var diffA = Convert.ToDouble(summary["Difficulty Accepted"].ToString()); var diffR = Convert.ToDouble(summary["Difficulty Rejected"].ToString()); var rejects = Convert.ToDouble(summary["Rejected"].ToString()); var accepted = Convert.ToDouble(summary["Accepted"].ToString()); var stale = Convert.ToDouble(summary["Stale"].ToString()); status.Status = "Alive"; status.Ghs5S = Convert.ToDouble(summary["GHS 5s"].ToString()); status.GhsAv = Convert.ToDouble(summary["GHS av"].ToString()); status.Blocks = summary["Found Blocks"].ToString(); status.HardwareErrorPercentage = Math.Round(hwError / (diffA + diffR) * 100, 2); status.RejectPercentage = (Math.Round(rejects / accepted) * 100); status.StalePercentage = (Math.Round(stale / accepted) * 100); status.BestShare = Convert.ToDouble(summary["Best Share"].ToString()); status.Fans = string.Format("{0}, {1}", stats["fan1"], stats["fan2"]); status.FanSpeed = Convert.ToInt32(stats["fan1"]); status.Temps = string.Format("{0}, {1}", stats["temp1"], stats["temp2"]); status.Freq = stats["frequency"].ToString(); status.AsicStatus = string.Format("{0} - {1}", stats["chain_acs1"], stats["chain_acs2"]); status.WorkUtility = Convert.ToDouble(summary["Work Utility"]); } catch (Exception) { status.Status = "Dead"; status.Ghs5S = 0; status.GhsAv = 0; status.Blocks = "-"; status.HardwareErrorPercentage = 0; status.RejectPercentage = 0; status.StalePercentage = 0; status.Fans = "-"; status.Temps = "-"; status.Freq = "-"; status.AsicStatus = "-"; } e.Result = status; }