private static void SetVoltage(int busId, int voltage) { voltage *= 1000; if (NvapiNativeMethods.NvSetClockBoostLock == null) { return; } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return; } NvGpuClockLock clockLock = NvGpuClockLock.Create(); var r = NvapiNativeMethods.NvGetClockBoostLock(HandlesByBusId[busId], ref clockLock); if (r != NvStatus.NVAPI_OK) { NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetClockBoostLock)} {r.ToString()}"); } if (r == NvStatus.NVAPI_OK) { uint index = clockLock.Enties[0].index; foreach (var item in clockLock.Enties) { if (item.index > index) { index = item.index; } } if (voltage != 0) { clockLock.Enties[index].mode = 3; } else { clockLock.Enties[index].mode = 0; } clockLock.Enties[index].voltageUV = (uint)voltage; r = NvapiNativeMethods.NvSetClockBoostLock(handle, ref clockLock); if (r != NvStatus.NVAPI_OK) { NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvSetClockBoostLock)} {r.ToString()}"); } } } catch { } }
private static int GetVoltage(int busId) { if (NvapiNativeMethods.NvGetClockBoostLock == null) { return(0); } try { if (!HandlesByBusId.TryGetValue(busId, out NvPhysicalGpuHandle handle)) { return(0); } NvGpuClockLock clockLock = NvGpuClockLock.Create(); var r = NvapiNativeMethods.NvGetClockBoostLock(HandlesByBusId[busId], ref clockLock); if (r != NvStatus.NVAPI_OK) { NTMinerConsole.DevError(() => $"{nameof(NvapiNativeMethods.NvGetClockBoostLock)} {r.ToString()}"); } if (r == NvStatus.NVAPI_OK) { int v = (int)clockLock.Enties[0].voltageUV; uint index = clockLock.Enties[0].index; foreach (var item in clockLock.Enties) { if (item.index > index) { index = item.index; v = (int)item.voltageUV; } } return(v / 1000); } } catch { } return(0); }