public static void PopulateFrom(this MiningStatistics miningStatistics, DeviceInformationResponse deviceInformation) { miningStatistics.AcceptedShares = deviceInformation.AcceptedShares; miningStatistics.AverageHashrate = deviceInformation.AverageHashrate; miningStatistics.CurrentHashrate = deviceInformation.CurrentHashrate; miningStatistics.Enabled = deviceInformation.Enabled; miningStatistics.FanPercent = deviceInformation.FanPercent; miningStatistics.FanSpeed = deviceInformation.FanSpeed; miningStatistics.GpuActivity = deviceInformation.GpuActivity; miningStatistics.GpuClock = deviceInformation.GpuClock; miningStatistics.GpuVoltage = deviceInformation.GpuVoltage; miningStatistics.HardwareErrors = deviceInformation.HardwareErrors; miningStatistics.Index = deviceInformation.Index; miningStatistics.Intensity = deviceInformation.Intensity; miningStatistics.Kind = deviceInformation.Kind; miningStatistics.MemoryClock = deviceInformation.MemoryClock; miningStatistics.PowerTune = deviceInformation.PowerTune; miningStatistics.RejectedShares = deviceInformation.RejectedShares; miningStatistics.Status = deviceInformation.Status; miningStatistics.Temperature = deviceInformation.Temperature; //new properties from bfgminer miningStatistics.Name = deviceInformation.Name; miningStatistics.DeviceID = deviceInformation.ID; miningStatistics.PoolIndex = deviceInformation.PoolIndex; //miningStatistics.PoolName = deviceInformation.PoolName; miningStatistics.RejectedSharesPercent = deviceInformation.RejectedSharesPercent; miningStatistics.HardwareErrorsPercent = deviceInformation.HardwareErrorsPercent; }
private void workersGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { for (int i = e.RowIndex; i < (e.RowIndex + e.RowCount); i++) { DeviceInformationResponse deviceInformation = this.deviceInformation[i]; DeviceDetailsResponse deviceDetails = this.deviceDetails.SingleOrDefault(d => d.Name.Equals(deviceInformation.Name) && (d.Index == deviceInformation.Index)); if (deviceDetails != null) { workersGridView.Rows[i].Cells[workerNameColumn.Index].Value = deviceDetails.DevicePath; } } }
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 ParseTextForDeviceInformation(string text, List <DeviceInformationResponse> deviceInformation) { 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) { DeviceInformationResponse newDevice = new DeviceInformationResponse(); newDevice.Kind = keyValuePairs.ElementAt(0).Key; newDevice.Index = TryToParseInt(keyValuePairs, newDevice.Kind, -1); if (newDevice.Index == -1) { continue; } if (keyValuePairs.ContainsKey("Enabled")) //seen this needed with a user { newDevice.Enabled = keyValuePairs["Enabled"].Equals("Y"); } if (keyValuePairs.ContainsKey("Status")) //check required for bfgminer { newDevice.Status = keyValuePairs["Status"]; } if (keyValuePairs.ContainsKey("Name")) { newDevice.Name = keyValuePairs["Name"]; } else { //default to Kind for older RPC API versions newDevice.Name = newDevice.Kind; } //default to Index for older RPC API versions newDevice.ID = newDevice.Index; if (keyValuePairs.ContainsKey("ID")) { newDevice.ID = TryToParseInt(keyValuePairs, "ID", newDevice.Index); } //parse regardless of device type = ASICs may have Temp newDevice.Temperature = TryToParseDouble(keyValuePairs, "Temperature", 0.00); newDevice.FanSpeed = TryToParseInt(keyValuePairs, "Fan Speed", 0); newDevice.FanPercent = TryToParseInt(keyValuePairs, "Fan Percent", 0); newDevice.GpuClock = TryToParseInt(keyValuePairs, "GPU Clock", 0); newDevice.MemoryClock = TryToParseInt(keyValuePairs, "Memory Clock", 0); newDevice.GpuVoltage = TryToParseDouble(keyValuePairs, "GPU Voltage", 0.00); newDevice.GpuActivity = TryToParseInt(keyValuePairs, "GPU Activity", 0); newDevice.PowerTune = TryToParseInt(keyValuePairs, "Powertune", 0); if (keyValuePairs.ContainsKey("Intensity")) //check required for bfgminer 3.3.0 { newDevice.Intensity = keyValuePairs["Intensity"]; } newDevice.AverageHashrate = TryToParseDouble(keyValuePairs, "MHS av", 0.00) * 1000; //seen both MHS 5s and MHS 1s if (keyValuePairs.ContainsKey("MHS 5s")) { newDevice.CurrentHashrate = TryToParseDouble(keyValuePairs, "MHS 5s", 0.00) * 1000; } else if (keyValuePairs.ContainsKey("MHS 1s")) { newDevice.CurrentHashrate = TryToParseDouble(keyValuePairs, "MHS 1s", 0.00) * 1000; } newDevice.AcceptedShares = TryToParseInt(keyValuePairs, "Accepted", 0); newDevice.RejectedShares = TryToParseInt(keyValuePairs, "Rejected", 0); newDevice.HardwareErrors = TryToParseInt(keyValuePairs, "Hardware Errors", 0); newDevice.Utility = TryToParseDouble(keyValuePairs, "Utility", 0.00); newDevice.PoolIndex = TryToParseInt(keyValuePairs, "Last Share Pool", -1); newDevice.HardwareErrorsPercent = TryToParseDouble(keyValuePairs, "Device Hardware%", 0.00); newDevice.RejectedSharesPercent = TryToParseDouble(keyValuePairs, "Device Rejected%", 0.00); deviceInformation.Add(newDevice); } } }