private void PopulateOpenCLApiData(Miner.OpenCL miner, Miner.Device device, double divisor, ref JsonAPI.OpenCLMiner openCLMiner) { try { openCLMiner = new JsonAPI.OpenCLMiner() { Type = device.Type, DeviceID = device.DeviceID, ModelName = device.Name, HashRate = (float)(miner.GetHashrateByDevice(device.Platform, device.DeviceID) / divisor), HasMonitoringAPI = miner.HasMonitoringAPI, Platform = device.Platform, SettingIntensity = device.Intensity }; } catch (Exception ex) { var errorMessage = string.Empty; var currentEx = ex; while (currentEx != null) { if (!string.IsNullOrEmpty(errorMessage)) { errorMessage += " "; } errorMessage += currentEx.Message; currentEx = currentEx.InnerException; } Program.Print(string.Format("[ERROR] {0}", errorMessage)); } }
private void PopulateAmdApiData(Miner.OpenCL miner, Miner.Device device, double divisor, ref JsonAPI.AMD_Miner amdMiner) { try { var tempValue = 0; var tempStr = new StringBuilder(1024); var instancePtr = miner.m_instance; amdMiner = new JsonAPI.AMD_Miner() { Type = device.Type, DeviceID = device.DeviceID, PciBusID = device.PciBusID, ModelName = device.Name, HashRate = (float)(miner.GetHashrateByDevice(device.Platform, device.DeviceID) / divisor), HasMonitoringAPI = miner.HasMonitoringAPI, Platform = device.Platform, SettingIntensity = device.Intensity }; if (miner.UseLinuxQuery) { amdMiner.SettingMaxCoreClockMHz = -1; amdMiner.SettingMaxMemoryClockMHz = -1; amdMiner.SettingPowerLimitPercent = -1; amdMiner.SettingThermalLimitC = int.MinValue; amdMiner.SettingFanLevelPercent = Miner.API.AmdLinuxQuery.GetDeviceSettingFanLevelPercent(device.PciBusID); amdMiner.CurrentFanTachometerRPM = Miner.API.AmdLinuxQuery.GetDeviceCurrentFanTachometerRPM(device.PciBusID); amdMiner.CurrentTemperatureC = Miner.API.AmdLinuxQuery.GetDeviceCurrentTemperature(device.PciBusID); amdMiner.CurrentCoreClockMHz = Miner.API.AmdLinuxQuery.GetDeviceCurrentCoreClock(device.PciBusID); amdMiner.CurrentMemoryClockMHz = Miner.API.AmdLinuxQuery.GetDeviceCurrentCoreClock(device.PciBusID); amdMiner.CurrentUtilizationPercent = Miner.API.AmdLinuxQuery.GetDeviceCurrentUtilizationPercent(device.PciBusID); } else { Miner.OpenCL.Solver.GetDeviceSettingMaxCoreClock(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.SettingMaxCoreClockMHz = tempValue; Miner.OpenCL.Solver.GetDeviceSettingMaxMemoryClock(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.SettingMaxMemoryClockMHz = tempValue; Miner.OpenCL.Solver.GetDeviceSettingPowerLimit(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.SettingPowerLimitPercent = tempValue; Miner.OpenCL.Solver.GetDeviceSettingThermalLimit(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.SettingThermalLimitC = tempValue; Miner.OpenCL.Solver.GetDeviceSettingFanLevelPercent(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.SettingFanLevelPercent = tempValue; Miner.OpenCL.Solver.GetDeviceCurrentFanTachometerRPM(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.CurrentFanTachometerRPM = tempValue; Miner.OpenCL.Solver.GetDeviceCurrentTemperature(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.CurrentTemperatureC = tempValue; Miner.OpenCL.Solver.GetDeviceCurrentCoreClock(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.CurrentCoreClockMHz = tempValue; Miner.OpenCL.Solver.GetDeviceCurrentMemoryClock(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.CurrentMemoryClockMHz = tempValue; Miner.OpenCL.Solver.GetDeviceCurrentUtilizationPercent(instancePtr, new StringBuilder(device.Platform), device.DeviceID, ref tempValue); amdMiner.CurrentUtilizationPercent = tempValue; } } catch (Exception ex) { var errorMessage = string.Empty; var currentEx = ex; while (currentEx != null) { if (!string.IsNullOrEmpty(errorMessage)) { errorMessage += " "; } errorMessage += currentEx.Message; currentEx = currentEx.InnerException; } Program.Print(string.Format("[ERROR] {0}", errorMessage)); } }