private void PopulateOpenCLApiData(Miner.OpenCL miner, Miner.Device.OpenCL 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) / 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.OpenCL device, double divisor, ref JsonAPI.AMD_Miner amdMiner) { try { var tempValue = 0; var errorMessage = new StringBuilder(1024); var instancePtr = miner.UnmanagedInstance; amdMiner = new JsonAPI.AMD_Miner() { Type = device.Type, DeviceID = device.DeviceID, PciBusID = device.PciBusID, ModelName = device.Name, HashRate = (float)(miner.GetHashRateByDevice(device) / 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 { var deviceCL = device.DeviceCL_Struct; OpenCL.Solver.GetDeviceSettingMaxCoreClock(deviceCL, ref tempValue, errorMessage); amdMiner.SettingMaxCoreClockMHz = tempValue; OpenCL.Solver.GetDeviceSettingMaxMemoryClock(deviceCL, ref tempValue, errorMessage); amdMiner.SettingMaxMemoryClockMHz = tempValue; OpenCL.Solver.GetDeviceSettingPowerLimit(deviceCL, ref tempValue, errorMessage); amdMiner.SettingPowerLimitPercent = tempValue; OpenCL.Solver.GetDeviceSettingThermalLimit(deviceCL, ref tempValue, errorMessage); amdMiner.SettingThermalLimitC = tempValue; OpenCL.Solver.GetDeviceSettingFanLevelPercent(deviceCL, ref tempValue, errorMessage); amdMiner.SettingFanLevelPercent = tempValue; OpenCL.Solver.GetDeviceCurrentFanTachometerRPM(deviceCL, ref tempValue, errorMessage); amdMiner.CurrentFanTachometerRPM = tempValue; OpenCL.Solver.GetDeviceCurrentTemperature(deviceCL, ref tempValue, errorMessage); amdMiner.CurrentTemperatureC = tempValue; OpenCL.Solver.GetDeviceCurrentCoreClock(deviceCL, ref tempValue, errorMessage); amdMiner.CurrentCoreClockMHz = tempValue; OpenCL.Solver.GetDeviceCurrentMemoryClock(deviceCL, ref tempValue, errorMessage); amdMiner.CurrentMemoryClockMHz = tempValue; OpenCL.Solver.GetDeviceCurrentUtilizationPercent(deviceCL, ref tempValue, errorMessage); 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)); } }