Exemple #1
0
 private static bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = NvCoolerSettings.Create();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     if (_nvGetCoolerSettingsNotSupporteds.Contains(busId))
     {
         return(false);
     }
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(handle, coolerIndex, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED || r == NvStatus.NVAPI_GPU_NOT_POWERED)
             {
                 _nvGetCoolerSettingsNotSupporteds.Add(busId);
             }
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Exemple #2
0
 private bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = new NvCoolerSettings();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     if (_nvGetCoolerSettingsNotSupporteds.Contains(busId))
     {
         return(false);
     }
     info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerSettings))));
     try {
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return(false);
         }
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(handle, coolerIndex, ref info);
         if (r != NvStatus.NVAPI_OK)
         {
             if (r == NvStatus.NVAPI_NOT_SUPPORTED || r == NvStatus.NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED || r == NvStatus.NVAPI_GPU_NOT_POWERED)
             {
                 _nvGetCoolerSettingsNotSupporteds.Add(busId);
             }
             Write.DevError($"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r.ToString()}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }
Exemple #3
0
 // 20卡不支持该方法,所以尝试两次返回值不正确不再尝试
 private bool GetCoolerSettings(int busId, out NvCoolerSettings info)
 {
     info = new NvCoolerSettings();
     if (NvapiNativeMethods.NvGetCoolerSettings == null)
     {
         return(false);
     }
     info.version = (uint)(VERSION1 | (Marshal.SizeOf(typeof(NvCoolerSettings))));
     try {
         NvCoolerTarget coolerIndex = NvCoolerTarget.NVAPI_COOLER_TARGET_ALL;
         var            r           = NvapiNativeMethods.NvGetCoolerSettings(HandlesByBusId[busId], coolerIndex, ref info);
         if (r != NvStatus.OK)
         {
             Write.DevError($"{nameof(NvapiNativeMethods.NvGetCoolerSettings)} {r}");
             return(false);
         }
         return(true);
     }
     catch {
     }
     return(false);
 }