Esempio n. 1
0
 public void GetTemperature(IGpu gpu, out uint coreTemperature, out uint memoryTemperature)
 {
     coreTemperature   = 0;
     memoryTemperature = 0;
     if (NvapiNativeMethods.NvGetThermalSettings == null)
     {
         return;
     }
     try {
         int busId = gpu.GetOverClockId();
         if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle))
         {
             return;
         }
         NvGPUThermalSettings settings = NvGPUThermalSettings.Create();
         var r = NvapiNativeMethods.NvGetThermalSettings(handle, (int)NvThermalTarget.ALL, ref settings);
         if (r != NvStatus.NVAPI_OK)
         {
             settings.Count = 0;
             NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetThermalSettings)} {r.ToString()}");
         }
         if (settings.Count > 0)
         {
             coreTemperature = settings.Sensor[0].CurrentTemp;
         }
         // TODO:3090是支持显存温度的,但不知道用什么接口读取
         if (settings.Count > 1)
         {
             memoryTemperature = settings.Sensor[1].CurrentTemp;
         }
     }
     catch (Exception e) {
         Logger.ErrorDebugLine(e);
     }
 }