Example #1
0
 private int GetTemperature(int gpuIndex)
 {
     try {
         if (!TryGetAtiGpu(gpuIndex, out ATIGPU gpu))
         {
             return(0);
         }
         if (gpu.OverdriveVersion >= 7)
         {
             var r = AdlNativeMethods.ADL2_OverdriveN_Temperature_Get(_context, gpu.AdapterIndex, ADLODNTemperatureType.CORE, out int temperature);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL2_OverdriveN_Temperature_Get)} {r.ToString()}");
                 return(0);
             }
             return((int)(0.001f * temperature));
         }
         else
         {
             ADLTemperature info = new ADLTemperature();
             var            r    = AdlNativeMethods.ADL_Overdrive5_Temperature_Get(gpu.AdapterIndex, 0, ref info);
             if (r < AdlStatus.ADL_OK)
             {
                 NTMinerConsole.DevError(() => $"{nameof(AdlNativeMethods.ADL_Overdrive5_Temperature_Get)} {r.ToString()}");
                 return(0);
             }
             return((int)(0.001f * info.Temperature));
         }
     }
     catch {
     }
     return(0);
 }