public void InspectDetails(Device device, CoinConfiguration coinConfiguration, CoinInformation coinInformation, List <DeviceInformationResponse> deviceInformation, PoolInformationResponse poolInformation, List <DeviceDetailsResponse> deviceDetails) { this.deviceDetails = deviceDetails; this.deviceInformation = deviceInformation; noDetailsPanel.Visible = false; double hashrate = 0; foreach (DeviceInformationResponse individualDevice in deviceInformation) { hashrate += individualDevice.AverageHashrate; } hashrateLabel.Text = hashrate.ToHashrateString(); workersGridView.Visible = (device.Kind == DeviceKind.PXY) && (deviceInformation.Count > 0); workersTitleLabel.Visible = workersGridView.Visible; //Internet or Coin API could be down if (coinInformation != null) { } //device may not be configured if (coinConfiguration != null) { cryptoCoinBindingSource.DataSource = coinConfiguration.Coin; } else { cryptoCoinBindingSource.DataSource = new CryptoCoin(); } deviceInformationResponseBindingSource.DataSource = deviceInformation; //may not be hashing yet if (deviceDetails != null) { deviceDetailsResponseBindingSource.DataSource = deviceDetails; } else { deviceDetailsResponseBindingSource.DataSource = new DeviceDetailsResponse(); } deviceBindingSource.DataSource = device; switch (device.Kind) { case DeviceKind.CPU: pictureBox1.Image = imageList1.Images[3]; break; case DeviceKind.GPU: pictureBox1.Image = imageList1.Images[0]; break; case DeviceKind.USB: pictureBox1.Image = imageList1.Images[1]; break; case DeviceKind.PXY: pictureBox1.Image = imageList1.Images[2]; break; } nameLabel.Width = this.Width - nameLabel.Left - closeDetailsButton.Width; acceptedLabel.Text = deviceInformation.Sum(d => d.AcceptedShares).ToString(); rejectedLabel.Text = deviceInformation.Sum(d => d.RejectedShares).ToString(); errorsLabel.Text = deviceInformation.Sum(d => d.HardwareErrors).ToString(); utilityLabel.Text = deviceInformation.Sum(d => d.Utility).ToString(); DeviceInformationResponse deviceInfo = (DeviceInformationResponse)deviceInformationResponseBindingSource.Current; if (deviceInfo != null) { if (deviceInfo.Temperature > 0) { tempLabel.Text = deviceInfo.Temperature + "°"; } else { tempLabel.Text = String.Empty; } if (deviceInfo.FanPercent > 0) { fanLabel.Text = deviceInfo.FanPercent + "%"; } else { fanLabel.Text = String.Empty; } } else { tempLabel.Text = String.Empty; fanLabel.Text = String.Empty; } UpdateColumnVisibility(); //may not be hashing yet if (poolInformation != null) { poolInformationResponseBindingSource.DataSource = poolInformation; } else { poolInformationResponseBindingSource.DataSource = new PoolInformationResponse(); } }
public static void ParseTextForDeviceDetails(string text, List <PoolInformationResponse> poolInformation) { List <string> deviceBlob = text.Split('|').ToList(); deviceBlob.RemoveAt(0); foreach (string deviceText in deviceBlob) { if (deviceText == "\0") { continue; } //bfgminer may have multiple entries for the same key, e.g. Hardware Errors //seen with customer data/hardware //remove dupes using Distinct() var deviceAttributes = deviceText.Split(',').ToList().Distinct(); Dictionary <string, string> keyValuePairs = deviceAttributes .Where(value => value.Contains('=')) .Select(value => value.Split('=')) .ToDictionary(pair => pair[0], pair => pair[1]); //seen Count == 0 with user API logs if (keyValuePairs.Count > 0) { PoolInformationResponse newPool = new PoolInformationResponse(); newPool.Index = int.Parse(keyValuePairs["POOL"]); //user bug reports indicate this key may not exist if (keyValuePairs.ContainsKey("URL")) { newPool.Url = keyValuePairs["URL"]; } //user bug reports indicate this key may not exist if (keyValuePairs.ContainsKey("Status")) { newPool.Status = keyValuePairs["Status"]; } newPool.Priority = TryToParseInt(keyValuePairs, "Priority", 0); newPool.Quota = TryToParseInt(keyValuePairs, "Quota", 0); if (keyValuePairs.ContainsKey("Long Pool")) { newPool.LongPoll = !keyValuePairs["Long Pool"].Equals("n", StringComparison.OrdinalIgnoreCase); } newPool.GetWorks = TryToParseInt(keyValuePairs, "Getworks", 0); newPool.Accepted = TryToParseInt(keyValuePairs, "Accepted", 0); newPool.Rejected = TryToParseInt(keyValuePairs, "Rejected", 0); newPool.Works = TryToParseInt(keyValuePairs, "Works", 0); newPool.Discarded = TryToParseInt(keyValuePairs, "Discarded", 0); newPool.Stale = TryToParseInt(keyValuePairs, "Stale", 0); newPool.GetFailures = TryToParseInt(keyValuePairs, "Get Failures", 0); newPool.RemoteFailures = TryToParseInt(keyValuePairs, "Remote Failures", 0); //user bug reports indicate this key may not exist if (keyValuePairs.ContainsKey("User")) { newPool.User = keyValuePairs["User"]; } newPool.LastShareTime = TryToParseInt(keyValuePairs, "Last Share Time", 0).UnixTimeToDateTime(); newPool.Diff1Shares = TryToParseInt(keyValuePairs, "Diff1 Shares", 0); //user bug reports indicate this key may not exist if (keyValuePairs.ContainsKey("Proxy")) { newPool.Proxy = keyValuePairs["Proxy"]; } newPool.DifficultyAccepted = TryToParseDouble(keyValuePairs, "Difficulty Accepted", 0.0); newPool.DifficultyRejected = TryToParseDouble(keyValuePairs, "Difficulty Rejected", 0.0); newPool.DifficultyStale = TryToParseDouble(keyValuePairs, "Difficulty Stale", 0.0); newPool.LastShareDifficulty = TryToParseDouble(keyValuePairs, "Last Share Difficulty", 0.0); newPool.HasStratum = keyValuePairs["Has Stratum"].Equals("true", StringComparison.OrdinalIgnoreCase); newPool.StratumActive = keyValuePairs["Stratum Active"].Equals("true", StringComparison.OrdinalIgnoreCase); newPool.StratumUrl = keyValuePairs["Stratum URL"]; newPool.BestShare = TryToParseInt(keyValuePairs, "Best Share", 0); newPool.PoolRejectedPercent = TryToParseDouble(keyValuePairs, "Pool Rejected%", 0.0); newPool.PoolStalePercent = TryToParseDouble(keyValuePairs, "Pool Stale%", 0.0); poolInformation.Add(newPool); } } }