public bool SetTDPSimple(TDPSimpleType level)
        {
            if (DeviceMonitorManager.DisableDevicePowerModeSettings)
            {
                Logger.InfoDelayed(LogTag, $"SetTDPSimple Disabled DeviceMonitorManager.DisableDevicePowerModeSettings==true", TimeSpan.FromSeconds(30));
                return(false);
            }
            var percentage = PowerLevelToTDPPercentage(level);

            if (!percentage.HasValue)
            {
                Logger.Error(LogTag, $"SetTDPSimple unkown PowerLevel {level}. Defaulting to {TDPSimpleType.HIGH}");
                level      = TDPSimpleType.HIGH;
                percentage = PowerLevelToTDPPercentage(level);
            }
            Logger.Info(LogTag, $"SetTDPSimple setting PowerLevel to {level}.");
            var execRet = ExecNvmlSetTDP($"{nameof(SetTDPSimple)}({level})", percentage.Value);

            if (execRet)
            {
                TDPSimple = level;
            }
            Logger.Info(LogTag, $"SetTDPSimple {execRet}.");
            return(execRet);
        }
        private static double?PowerLevelToTDPPercentage(TDPSimpleType level)
        {
            switch (level)
            {
            case TDPSimpleType.LOW: return(0.5d);    // 50%

            case TDPSimpleType.MEDIUM: return(0.8d); // 80%

            case TDPSimpleType.HIGH: return(1.0d);   // 100%
            }
            return(null);
        }
Beispiel #3
0
        private static void SetPowerMode(string device, TDPSimpleType level)
        {
            if (GlobalDeviceSettings.Instance.DisableDevicePowerModeSettings)
            {
                throw new RpcException("Not able to set Power Mode: Device Power Mode Settings Disabled", ErrorCode.UnableToHandleRpc);
            }

            var devs = device == "*" ?
                       AvailableDevices.Devices :
                       AvailableDevices.Devices.Where(d => d.B64Uuid == device);

            var found      = devs.Count() > 0;
            var hasEnabled = false;
            var setSuccess = new List <(bool success, DeviceType type)>();

            foreach (var dev in devs)
            {
                if (!dev.Enabled)
                {
                    continue;
                }
                if (!dev.CanSetPowerMode)
                {
                    continue;
                }
                hasEnabled = true;
                // TODO check if set
                var result = dev.SetPowerMode(level);
                setSuccess.Add((result, dev.DeviceType));
            }

            if (!setSuccess.All(t => t.success))
            {
                if (setSuccess.Any(res => res.type == DeviceType.NVIDIA && !Helpers.IsElevated && !res.success))
                {
                    throw new RpcException("Not able to set power modes for devices: Must start NiceHashMiner as Admin", ErrorCode.UnableToHandleRpc);
                }
                throw new RpcException("Not able to set power modes for all devices", ErrorCode.UnableToHandleRpc);
            }

            if (found && !hasEnabled)
            {
                throw new RpcException("No settable devices found", ErrorCode.UnableToHandleRpc);
            }

            if (!found)
            {
                throw new RpcException("No settable devices found", ErrorCode.UnableToHandleRpc);
            }
        }
Beispiel #4
0
        private static void SetPowerMode(string device, TDPSimpleType level)
        {
            var devs = device == "*" ?
                       AvailableDevices.Devices :
                       AvailableDevices.Devices.Where(d => d.B64Uuid == device);

            var found      = devs.Count() > 0;
            var hasEnabled = false;
            var setSuccess = new List <bool>();

            foreach (var dev in devs)
            {
                if (!dev.Enabled)
                {
                    continue;
                }
                if (!dev.CanSetPowerMode)
                {
                    continue;
                }
                hasEnabled = true;
                // TODO check if set
                var result = dev.SetPowerMode(level);
                setSuccess.Add(result);
            }

            if (setSuccess.Any(t => t) && !setSuccess.All(t => t))
            {
                throw new RpcException("Not able to set power modes for all devices", ErrorCode.UnableToHandleRpc);
            }

            if (found && !hasEnabled)
            {
                throw new RpcException("No settable devices found", ErrorCode.UnableToHandleRpc);
            }

            if (!found)
            {
                throw new RpcException("No settable devices found", ErrorCode.UnableToHandleRpc);
            }
        }
 public void SetSimple(TDPSimpleType type)
 {
     TDPSet(_tdpMon.SetTDPSimple(type));
 }