Beispiel #1
0
        /// <summary>
        /// Here is the behaviour logic depending on internet GPU load status.
        /// </summary>
        private void LoadActions()
        {
            if (isStopped)
            {
                return;
            }

            var gpus    = computer.Hardware.Where(x => x.HardwareType == HardwareType.GpuNvidia || x.HardwareType == HardwareType.GpuAti);
            var minLoad = Single.MaxValue;

            foreach (var gpu in gpus)
            {
                gpu.Update();
                var load = Single.NaN;
                var tmpr = Single.NaN;
                foreach (var sensor in gpu.Sensors)
                {
                    if (sensor.SensorType == SensorType.Load && sensor.Name == "GPU Core")
                    {
                        if (sensor.Value != null)
                        {
                            load = sensor.Value.Value;
                        }
                    }
                    if (sensor.SensorType == SensorType.Temperature && sensor.Name == "GPU Core")
                    {
                        if (sensor.Value != null)
                        {
                            tmpr = sensor.Value.Value;
                        }
                    }
                    if (load < minLoad)
                    {
                        minLoad = load;
                    }
                }
                Output.Write($"gpu{Regex.Match(gpu.Identifier.ToString(), @"\d+").Value}(ld={load}%, t={tmpr} C);  ", ConsoleColor.Cyan);
            }
            Output.WriteLine();

            if (minLoad < args.GpuLoadThreshold)
            {
                Output.WriteLine(args.Restart
                        ? $"GPU LOAD {minLoad}%, THRESHOLD {args.GpuLoadThreshold}! RESTART PC IN {--gpuLoadIterations}"
                        : $"GPU LOAD {minLoad}%, THRESHOLD {args.GpuLoadThreshold}! RESTART MINER IN {--gpuLoadIterations}",
                                 ConsoleColor.Red);
            }

            else
            {
                gpuLoadIterations = MaxItertions;
            }

            if (gpuLoadIterations > 0)
            {
                return;
            }

            if (args.Restart)
            {
                Output.Write("RESTARTING PC IN 5 SECONDS", ConsoleColor.Yellow);
                utilMgr.RestartPc();
            }
            Output.Write("RESTARTING MINER...", ConsoleColor.Yellow);
            utilMgr.RestartProcess(supervisedProcess);
            Output.WriteLine(" OK!", ConsoleColor.Yellow);
            gpuLoadIterations = MaxItertions;
        }