Exemplo n.º 1
0
        private void PopulateCpuApiData(Miner.CPU miner, Miner.Device device, double divisor, ref JsonAPI.Miner cpuMiner)
        {
            try
            {
                cpuMiner = new JsonAPI.Miner()
                {
                    Type      = device.Type,
                    DeviceID  = device.DeviceID,
                    ModelName = device.Name,
                    HashRate  = (float)(miner.GetHashrateByDevice(device.Platform,
                                                                  (device.Type == "CPU")
                                                                 ? Array.IndexOf(miner.Devices, device)
                                                                 : device.DeviceID) / divisor),
                    HasMonitoringAPI = miner.HasMonitoringAPI
                };
            }
            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));
            }
        }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 4
0
        private void PopulateCudaApiData(Miner.CUDA miner, Miner.Device device, double divisor, ref JsonAPI.CUDA_Miner cudaMiner)
        {
            try
            {
                var instancePtr = miner.m_instance;

                cudaMiner = new JsonAPI.CUDA_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,
                    SettingIntensity = device.Intensity
                };

                if (miner.UseNvSMI)
                {
                    cudaMiner.SettingMaxCoreClockMHz = -1;

                    cudaMiner.SettingMaxMemoryClockMHz = -1;

                    cudaMiner.SettingPowerLimitPercent = Miner.API.NvSMI.GetDeviceSettingPowerLimit(device.PciBusID);

                    cudaMiner.SettingThermalLimitC = Miner.API.NvSMI.GetDeviceSettingThermalLimit(device.PciBusID);

                    cudaMiner.SettingFanLevelPercent = Miner.API.NvSMI.GetDeviceSettingFanLevelPercent(device.PciBusID);

                    cudaMiner.CurrentFanTachometerRPM = -1;

                    cudaMiner.CurrentTemperatureC = Miner.API.NvSMI.GetDeviceCurrentTemperature(device.PciBusID);

                    cudaMiner.CurrentCoreClockMHz = Miner.API.NvSMI.GetDeviceCurrentCoreClock(device.PciBusID);

                    cudaMiner.CurrentMemoryClockMHz = Miner.API.NvSMI.GetDeviceCurrentMemoryClock(device.PciBusID);

                    cudaMiner.CurrentUtilizationPercent = Miner.API.NvSMI.GetDeviceCurrentUtilizationPercent(device.PciBusID);

                    cudaMiner.CurrentPState = Miner.API.NvSMI.GetDeviceCurrentPstate(device.PciBusID);

                    cudaMiner.CurrentThrottleReasons = Miner.API.NvSMI.GetDeviceCurrentThrottleReasons(device.PciBusID);
                }
                else
                {
                    var tempValue = 0;
                    var tempSize  = 0ul;
                    var tempStr   = new StringBuilder(1024);

                    Miner.CUDA.Solver.GetDeviceSettingMaxCoreClock(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.SettingMaxCoreClockMHz = tempValue;

                    Miner.CUDA.Solver.GetDeviceSettingMaxMemoryClock(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.SettingMaxMemoryClockMHz = tempValue;

                    Miner.CUDA.Solver.GetDeviceSettingPowerLimit(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.SettingPowerLimitPercent = tempValue;

                    Miner.CUDA.Solver.GetDeviceSettingThermalLimit(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.SettingThermalLimitC = tempValue;

                    Miner.CUDA.Solver.GetDeviceSettingFanLevelPercent(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.SettingFanLevelPercent = tempValue;

                    Miner.CUDA.Solver.GetDeviceCurrentFanTachometerRPM(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.CurrentFanTachometerRPM = tempValue;

                    Miner.CUDA.Solver.GetDeviceCurrentTemperature(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.CurrentTemperatureC = tempValue;

                    Miner.CUDA.Solver.GetDeviceCurrentCoreClock(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.CurrentCoreClockMHz = tempValue;

                    Miner.CUDA.Solver.GetDeviceCurrentMemoryClock(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.CurrentMemoryClockMHz = tempValue;

                    Miner.CUDA.Solver.GetDeviceCurrentUtilizationPercent(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.CurrentUtilizationPercent = tempValue;

                    Miner.CUDA.Solver.GetDeviceCurrentPstate(instancePtr, device.DeviceID, ref tempValue);
                    cudaMiner.CurrentPState = tempValue;

                    Miner.CUDA.Solver.GetDeviceCurrentThrottleReasons(instancePtr, device.DeviceID, tempStr, ref tempSize);
                    cudaMiner.CurrentThrottleReasons = tempStr.ToString();
                }
            }
            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));
            }
        }