示例#1
0
        // ReSharper disable once TooManyDeclarations
        private static void Main()
        {
            NVIDIA.Initialize();
            var navigation = new Dictionary <object, Action>
            {
                { "Connected Displays", PrintConnectedDisplays },
                { "Disconnected Displays", PrintDisconnectedDisplays },
                { "Display Configurations", PrintDisplayPathInformation },
                { "Physical GPUs", PrintPhysicalGPUs },
                { "GPU Temperatures", PrintGPUSensors },
                { "GPU Coolers", PrintGPUCoolers },
                { "GPU Performance States", PrintGPUPerformanceStates },
                { "TCC GPUs", PrintTCCGPUs },
                { "Grid Topologies (Mosaic - NVIDIA Surround)", PrintGridTopologies },
                { "NVIDIA Driver and API version", PrintDriverVersion },
                { "System Chipset Information", PrintChipsetInformation },
                { "Lid and Dock Information", PrintDockInformation }
            };

            ConsoleNavigation.Default.PrintNavigation(
                navigation.Keys.ToArray(),
                (i, o) => navigation[o](),
                "Select an execution line to browse NvAPIWrapper functionalities."
                );
        }
示例#2
0
 protected override void Uninitialize()
 {
     if (_initialized)
     {
         NVIDIA.Unload();
     }
 }
示例#3
0
        /// <summary>
        ///     Created in Program, instantiated by GuiInitializer.
        ///     Finds the Batman: Arkham Asylum Profile or creates it if it doesn't exist yet.
        ///     Calls getNVSettings().
        /// </summary>
        public NvidiaWorker()
        {
            NVIDIA.Initialize();
            logger.Debug("Constructor - NVIDIA API initialized.");
            _session = DriverSettingsSession.CreateAndLoad();
            try
            {
                _session.FindProfileByName("Batman: Arkham Asylum");
            }
            catch (NVIDIAApiException e)
            {
                Console.WriteLine(e);
                DriverSettingsProfile profile =
                    DriverSettingsProfile.CreateProfile(_session, "Batman: Arkham Asylum", null);
                ProfileApplication profApp = ProfileApplication.CreateApplication(profile, "shippingpc-bmgame.exe");
                profile = profApp.Profile;
                profile.SetSetting(KnownSettingId.AmbientOcclusionModeActive, 0);
                profile.SetSetting(KnownSettingId.AmbientOcclusionMode, 0);
                _session.Save();
                logger.Warn("Constructor - NVIDIA profile not found. Creating profile: {0}", profile.ToString());
            }

            _prof = _session.FindProfileByName("Batman: Arkham Asylum");
            getNVSettings();
            logger.Info("Constructor - NVIDIA profile fully processed.");
        }
示例#4
0
        public static void Init()
        {
            try
            {
                NVIDIA.Initialize();
                PhysicalGPU[] gpus = PhysicalGPU.GetPhysicalGPUs();

                if (gpus.Length == 0)
                {
                    return;
                }

                gpuList = gpus.ToList();

                List <string> gpuNames = new List <string>();

                foreach (PhysicalGPU gpu in gpus)
                {
                    gpuNames.Add(gpu.FullName);
                }

                string gpuNamesList = string.Join(", ", gpuNames);

                Logger.Log($"Initialized Nvidia API. GPU{(gpus.Length > 1 ? "s" : "")}: {gpuNamesList}");
            }
            catch (Exception e)
            {
                Logger.Log("No Nvidia GPU(s) detected. You will not be able to use CUDA implementations.");
                Logger.Log($"Failed to initialize NvApi: {e.Message}\nIgnore this if you don't have an Nvidia GPU.", true);
            }
        }
示例#5
0
        public static string GetGpuName()
        {
            try
            {
                NVIDIA.Initialize();
                PhysicalGPU[] gpus = PhysicalGPU.GetPhysicalGPUs();
                if (gpus.Length == 0)
                {
                    return("");
                }

                return(gpus[0].FullName);
            }
            catch
            {
                return("");
            }
        }
示例#6
0
        public static void Initialize()
        {
#if DEBUG
            try
            {
#endif
            ThreadPriorityHook = new SetThreadPriority();
            ThreadPriorityHook.OnThreadPriorityChanged = OnThreadPriorityChanged;
            ThreadPriorityHook.Install();

            var NVPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "nvapi64.dll");
            if (File.Exists(NVPath))
            {
                NVIDIA.Initialize();
                using (var Session = DriverSettingsSession.CreateAndLoad())
                {
                    var Application = Session.FindApplication(Process.GetCurrentProcess().MainModule.FileName);
                    if (Application != null)
                    {
                        Application.Profile.SetSetting(KnownSettingId.OpenGLThreadControl, 1);
                        Session.Save();
                    }
#if DEBUG
                    else
                    {
                        LOG.WriteLine("Failed to Find the Application Profile");
                        LOG.Flush();
                    }
#endif
                }
                NVIDIA.Unload();
            }
#if DEBUG
        }

        catch (Exception ex)
        {
            LOG.WriteLine(ex);
            LOG.Flush();
        }
#endif
        }
示例#7
0
        public static async void Init()
        {
            try
            {
                NVIDIA.Initialize();
                PhysicalGPU[] gpus = PhysicalGPU.GetPhysicalGPUs();
                if (gpus.Length == 0)
                {
                    return;
                }
                gpu = gpus[0];

                while (true)
                {
                    RefreshVram();
                    await Task.Delay(1000);
                }
            }
            catch (Exception e)
            {
                Logger.Log($"Failed to initialize NvApi: {e.Message}\nIgnore this if you don't have an Nvidia GPU.");
            }
        }
示例#8
0
 protected override void Initialize()
 {
     NVIDIA.Initialize();
     _initialized = true;
 }
示例#9
0
        public void start()
        {
            Monitor.Enter(mLock);
            if (mIsStart == true)
            {
                Monitor.Exit(mLock);
                return;
            }
            mIsStart = true;

            string mutexName = "Global\\Access_ISABUS.HTP.Method";

            this.createBusMutex(mutexName, ref mISABusMutex);

            mutexName = "Global\\Access_SMBUS.HTP.Method";
            this.createBusMutex(mutexName, ref mSMBusMutex);

            mutexName = "Global\\Access_PCI";
            this.createBusMutex(mutexName, ref mPCIMutex);

            // Gigabyte
            if (OptionManager.getInstance().IsGigabyte == true)
            {
                mGigabyte = new Gigabyte();
                mGigabyte.AddChangeValue += addChangeValue;
                mGigabyte.LockBus        += lockBus;
                mGigabyte.UnlockBus      += unlockBus;

                mIsGigabyte = mGigabyte.start();
            }
            else
            {
                mIsGigabyte = false;
                Gigabyte.stopService();
            }

            if (mIsGigabyte == false)
            {
                mGigabyte = null;

                // LibreHardwareMonitor
                if (OptionManager.getInstance().LibraryType == LibraryType.LibreHardwareMonitor)
                {
                    mLHM = new LHM();
                    mLHM.start();
                }

                // OpenHardwareMonitor
                else
                {
                    mOHM = new OHM();
                    mOHM.start();
                }
            }

            // NvAPIWrapper
            if (OptionManager.getInstance().IsNvAPIWrapper == true)
            {
                NVIDIA.Initialize();
            }

            this.createTemp();
            this.createFan();
            this.createControl();

            if (OptionManager.getInstance().IsKraken == true)
            {
                // NZXT Kraken
                try
                {
                    mKraken = new Kraken();

                    // X2
                    if (mKraken.start(USBProductID.KrakenX2) == false)
                    {
                        // X3
                        if (mKraken.start(USBProductID.KrakenX3) == false)
                        {
                            mKraken = null;
                        }
                    }

                    if (mKraken != null)
                    {
                        var sensor = new KrakenLiquidTemp(mKraken);
                        mSensorList.Add(sensor);

                        if (mKraken.ProductID == USBProductID.KrakenX2)
                        {
                            var fan = new KrakenFanSpeed(mKraken);
                            mFanList.Add(fan);
                        }

                        var pump = new KrakenPumpSpeed(mKraken);
                        mFanList.Add(pump);

                        if (mKraken.ProductID == USBProductID.KrakenX2)
                        {
                            var fanControl = new KrakenFanControl(mKraken);
                            mControlList.Add(fanControl);
                            this.addChangeValue(30, fanControl);
                        }

                        var pumpControl = new KrakenPumpControl(mKraken);
                        mControlList.Add(pumpControl);
                        this.addChangeValue(50, pumpControl);
                    }
                }
                catch
                {
                    mKraken = null;
                }
            }

            if (OptionManager.getInstance().IsCLC == true)
            {
                try
                {
                    mCLC = new CLC();
                    if (mCLC.start(USBProductID.CLC) == false)
                    {
                        mCLC = null;
                    }

                    if (mCLC != null)
                    {
                        var sensor = new CLCLiquidTemp(mCLC);
                        mSensorList.Add(sensor);

                        var fan = new CLCFanSpeed(mCLC);
                        mFanList.Add(fan);

                        var pump = new CLCPumpSpeed(mCLC);
                        mFanList.Add(pump);

                        var fanControl = new CLCFanControl(mCLC);
                        mControlList.Add(fanControl);
                        this.addChangeValue(25, fanControl);

                        var pumpControl = new CLCPumpControl(mCLC);
                        mControlList.Add(pumpControl);
                        this.addChangeValue(50, pumpControl);
                    }
                }
                catch
                {
                    mCLC = null;
                }
            }

            if (OptionManager.getInstance().IsRGBnFC == true)
            {
                try
                {
                    mRGBnFC = new RGBnFC();
                    if (mRGBnFC.start() == false)
                    {
                        mRGBnFC = null;
                    }

                    if (mRGBnFC != null)
                    {
                        for (int i = 0; i < RGBnFC.cMaxFanCount; i++)
                        {
                            var fan = new RGBnFCFanSpeed(mRGBnFC, i);
                            mFanList.Add(fan);

                            var control = new RGBnFCControl(mRGBnFC, i);
                            mControlList.Add(control);
                            this.addChangeValue(control.getMinSpeed(), control);
                        }
                    }
                }
                catch
                {
                    mRGBnFC = null;
                }
            }

            // DIMM thermal sensor
            if (OptionManager.getInstance().IsDimm == true)
            {
                this.lockSMBus(0);
                if (SMBusController.open(false) == true)
                {
                    int num      = 1;
                    int busCount = SMBusController.getCount();

                    for (int i = 0; i < busCount; i++)
                    {
                        var detectBytes = SMBusController.i2cDetect(i);
                        if (detectBytes != null)
                        {
                            // 0x18 ~ 0x20
                            for (int j = 0; j < detectBytes.Length; j++)
                            {
                                if (j < 24)
                                {
                                    continue;
                                }
                                else if (j > 32)
                                {
                                    break;
                                }

                                if (detectBytes[j] == (byte)j)
                                {
                                    var sensor = new DimmTemp("DIMM #" + num++, i, detectBytes[j]);
                                    sensor.onSetDimmTemperature += onSetDimmTemperature;
                                    mSensorList.Add(sensor);
                                }
                            }
                        }
                    }
                }
                this.unlockSMBus();
            }

            // Motherboard temperature
            this.createMotherBoardTemp();

            // GPU
            this.createGPUTemp();
            this.createGPUFan();
            this.createGPUControl();

            // osd sensor
            this.createOSDSensor();

            Monitor.Exit(mLock);
        }
示例#10
0
        public void start()
        {
            Monitor.Enter(mLock);
            if (mIsStart == true)
            {
                Monitor.Exit(mLock);
                return;
            }
            mIsStart = true;

            string mutexName = "Global\\Access_ISABUS.HTP.Method";

            this.createBusMutex(mutexName, ref mISABusMutex);

            mutexName = "Global\\Access_SMBUS.HTP.Method";
            this.createBusMutex(mutexName, ref mSMBusMutex);

            mutexName = "Global\\Access_PCI";
            this.createBusMutex(mutexName, ref mPCIMutex);

            // Gigabyte
            if (OptionManager.getInstance().IsGigabyte == true)
            {
                mGigabyte = new Gigabyte();
                mGigabyte.AddChangeValue += addChangeValue;
                mGigabyte.LockBus        += lockBus;
                mGigabyte.UnlockBus      += unlockBus;

                mIsGigabyte = mGigabyte.start();
            }
            else
            {
                mIsGigabyte = false;
                Gigabyte.stopService();
            }

            if (mIsGigabyte == false)
            {
                mGigabyte = null;

                // LibreHardwareMonitor
                if (OptionManager.getInstance().LibraryType == LibraryType.LibreHardwareMonitor)
                {
                    mLHM = new LHM();
                    mLHM.start();
                }

                // OpenHardwareMonitor
                else
                {
                    mOHM = new OHM();
                    mOHM.start();
                }
            }

            // NvAPIWrapper
            if (OptionManager.getInstance().IsNvAPIWrapper == true)
            {
                NVIDIA.Initialize();
            }

            this.createTemp();
            this.createFan();
            this.createControl();

            // NZXT Kraken
            if (OptionManager.getInstance().IsKraken == true)
            {
                try
                {
                    uint num = 1;

                    // X2
                    uint devCount = HidUSBController.getDeviceCount(USBVendorID.NZXT, USBProductID.KrakenX2);
                    for (uint i = 0; i < devCount; i++)
                    {
                        var kraken = new Kraken();
                        if (kraken.start(i, USBProductID.KrakenX2) == true)
                        {
                            mKrakenList.Add(kraken);

                            var sensor = new KrakenLiquidTemp(kraken, num);
                            mSensorList.Add(sensor);

                            var fan = new KrakenFanSpeed(kraken, num);
                            mFanList.Add(fan);

                            var pump = new KrakenPumpSpeed(kraken, num);
                            mFanList.Add(pump);

                            var fanControl = new KrakenFanControl(kraken, num);
                            mControlList.Add(fanControl);
                            this.addChangeValue(30, fanControl);

                            var pumpControl = new KrakenPumpControl(kraken, num);
                            mControlList.Add(pumpControl);
                            this.addChangeValue(50, pumpControl);

                            num++;
                        }
                    }

                    // X3
                    devCount = HidUSBController.getDeviceCount(USBVendorID.NZXT, USBProductID.KrakenX3);
                    for (uint i = 0; i < devCount; i++)
                    {
                        var kraken = new Kraken();
                        if (kraken.start(i, USBProductID.KrakenX3) == true)
                        {
                            mKrakenList.Add(kraken);

                            var sensor = new KrakenLiquidTemp(kraken, num);
                            mSensorList.Add(sensor);

                            var pump = new KrakenPumpSpeed(kraken, num);
                            mFanList.Add(pump);

                            var pumpControl = new KrakenPumpControl(kraken, num);
                            mControlList.Add(pumpControl);
                            this.addChangeValue(50, pumpControl);

                            num++;
                        }
                    }
                }
                catch { }
            }

            // EVGA CLC
            if (OptionManager.getInstance().IsCLC == true)
            {
                try
                {
                    uint num      = 1;
                    uint clcIndex = 0;

                    // SiUSBController
                    uint devCount = SiUSBController.getDeviceCount(USBVendorID.ASETEK, USBProductID.CLC);
                    for (uint i = 0; i < devCount; i++)
                    {
                        var clc = new CLC();
                        if (clc.start(true, clcIndex, i) == true)
                        {
                            mCLCList.Add(clc);

                            var sensor = new CLCLiquidTemp(clc, num);
                            mSensorList.Add(sensor);

                            var fan = new CLCFanSpeed(clc, num);
                            mFanList.Add(fan);

                            var pump = new CLCPumpSpeed(clc, num);
                            mFanList.Add(pump);

                            var fanControl = new CLCFanControl(clc, num);
                            mControlList.Add(fanControl);
                            this.addChangeValue(25, fanControl);

                            var pumpControl = new CLCPumpControl(clc, num);
                            mControlList.Add(pumpControl);
                            this.addChangeValue(50, pumpControl);

                            clcIndex++;
                            num++;
                        }
                    }

                    if (WinUSBController.initUSB() == true)
                    {
                        // WinUSBController
                        devCount = WinUSBController.getDeviceCount(USBVendorID.ASETEK, USBProductID.CLC);
                        for (uint i = 0; i < devCount; i++)
                        {
                            var clc = new CLC();
                            if (clc.start(false, clcIndex, i) == true)
                            {
                                mCLCList.Add(clc);

                                var sensor = new CLCLiquidTemp(clc, num);
                                mSensorList.Add(sensor);

                                var fan = new CLCFanSpeed(clc, num);
                                mFanList.Add(fan);

                                var pump = new CLCPumpSpeed(clc, num);
                                mFanList.Add(pump);

                                var fanControl = new CLCFanControl(clc, num);
                                mControlList.Add(fanControl);
                                this.addChangeValue(25, fanControl);

                                var pumpControl = new CLCPumpControl(clc, num);
                                mControlList.Add(pumpControl);
                                this.addChangeValue(50, pumpControl);

                                clcIndex++;
                                num++;
                            }
                        }
                    }
                }
                catch { }
            }

            if (OptionManager.getInstance().IsRGBnFC == true)
            {
                try
                {
                    uint num      = 1;
                    uint devCount = HidUSBController.getDeviceCount(USBVendorID.NZXT, USBProductID.RGBAndFanController);
                    for (uint i = 0; i < devCount; i++)
                    {
                        var rgb = new RGBnFC();
                        if (rgb.start(i) == true)
                        {
                            mRGBnFCList.Add(rgb);

                            for (int j = 0; j < RGBnFC.MAX_FAN_COUNT; j++)
                            {
                                var fan = new RGBnFCFanSpeed(rgb, j, num);
                                mFanList.Add(fan);

                                var control = new RGBnFCControl(rgb, j, num);
                                mControlList.Add(control);
                                this.addChangeValue(control.getMinSpeed(), control);

                                num++;
                            }
                        }
                    }
                }
                catch { }
            }

            // DIMM thermal sensor
            if (OptionManager.getInstance().IsDimm == true)
            {
                this.lockSMBus(0);
                if (SMBusController.open(false) == true)
                {
                    int num      = 1;
                    int busCount = SMBusController.getCount();

                    for (int i = 0; i < busCount; i++)
                    {
                        var detectBytes = SMBusController.i2cDetect(i);
                        if (detectBytes != null)
                        {
                            // 0x18 ~ 0x20
                            for (int j = 0; j < detectBytes.Length; j++)
                            {
                                if (j < 24)
                                {
                                    continue;
                                }
                                else if (j > 32)
                                {
                                    break;
                                }

                                if (detectBytes[j] == (byte)j)
                                {
                                    var sensor = new DimmTemp("DIMM #" + num++, i, detectBytes[j]);
                                    sensor.onSetDimmTemperature += onSetDimmTemperature;
                                    mSensorList.Add(sensor);
                                }
                            }
                        }
                    }
                }
                this.unlockSMBus();
            }

            // Motherboard temperature
            this.createMotherBoardTemp();

            // GPU
            this.createGPUTemp();
            this.createGPUFan();
            this.createGPUControl();

            // osd sensor
            this.createOSDSensor();

            Monitor.Exit(mLock);
        }
示例#11
0
        private static void Main()
        {
            NVIDIA.Initialize();
            var navigation = new Dictionary <object, Action>
            {
                {
                    "Connected Displays",
                    () =>
                    ConsoleNavigation.PrintObject(Display.GetDisplays(),
                                                  display => ConsoleNavigation.PrintObject(display.DisplayDevice, "Display.DisplayDevice"),
                                                  "Display.GetDisplays()", "Select a display to show device information")
                },
                {
                    "Disconnected Displays",
                    () =>
                    ConsoleNavigation.PrintObject(UnAttachedDisplay.GetUnAttachedDisplays(),
                                                  display =>
                                                  ConsoleNavigation.PrintObject(display.PhysicalGPU, "UnAttachedDisplay.PhysicalGPU"),
                                                  "UnAttachedDisplay.GetUnAttachedDisplays()", "Select a display to show GPU information")
                },
                {
                    "Display Configurations",
                    () =>
                    ConsoleNavigation.PrintObject(PathInfo.GetDisplaysConfig().ToArray(),
                                                  pathInfo =>
                                                  ConsoleNavigation.PrintObject(pathInfo.TargetsInfo,
                                                                                targetInfo =>
                                                                                ConsoleNavigation.PrintObject(targetInfo.DisplayDevice,
                                                                                                              "PathTargetInfo.DisplayDevice"), "PathInfo.TargetsInfo[]",
                                                                                "Select a path target info to show display device information"),
                                                  "PathInfo.GetDisplaysConfig()", "Select a path info to show target information")
                },
                {
                    "Physical GPUs", () =>
                    ConsoleNavigation.PrintObject(PhysicalGPU.GetPhysicalGPUs(),
                                                  gpu => ConsoleNavigation.PrintObject(gpu.ActiveOutputs, "PhysicalGPU.ActiveOutputs"),
                                                  "PhysicalGPU.GetPhysicalGPUs()", "Select a GPU to show active outputs")
                },
                {
                    "GPU Temperatures", () =>
                    ConsoleNavigation.PrintNavigation(
                        PhysicalGPU.GetPhysicalGPUs()
                        .ToDictionary(gpu => (object)gpu.ToString(), gpu => new Action(
                                          () =>
                    {
                        ConsoleNavigation.PrintObject(gpu.ThermalSensors, "PhysicalGPU.ThermalSensors");
                    })),
                        "PhysicalGPU.GetPhysicalGPUs()", "Select a GPU to show thermal sensor values")
                },
                {
                    "GPU Clock Frequencies", () =>
                    ConsoleNavigation.PrintNavigation(
                        PhysicalGPU.GetPhysicalGPUs()
                        .ToDictionary(gpu => (object)gpu.ToString(), gpu => new Action(
                                          () =>
                    {
                        ConsoleNavigation.PrintObject(gpu.ClockFrequencies, "gpu.ClockFrequencies");
                    })),
                        "PhysicalGPU.GetPhysicalGPUs()", "Select a GPU to show thermal sensor values")
                },
                {
                    "GPU Dynamic Performance States", () =>
                    ConsoleNavigation.PrintNavigation(
                        PhysicalGPU.GetPhysicalGPUs()
                        .ToDictionary(gpu => (object)gpu.ToString(), gpu => new Action(
                                          () =>
                    {
                        ConsoleNavigation.PrintObject(gpu.DynamicPerformanceStatesInfo,
                                                      "PhysicalGPU.DynamicPerformanceStatesInfo");
                    })),
                        "PhysicalGPU.GetPhysicalGPUs()", "Select a GPU to show dynamic performance state domains")
                },
                {
                    "TCC GPUs", () =>
                    ConsoleNavigation.PrintObject(PhysicalGPU.GetTCCPhysicalGPUs(),
                                                  "PhysicalGPU.GetTCCPhysicalGPUs()")
                },
                {
                    "Grid Topologies (Mosaic)",
                    () =>
                    ConsoleNavigation.PrintObject(GridTopology.GetGridTopologies(),
                                                  grid =>
                                                  ConsoleNavigation.PrintObject(grid.Displays,
                                                                                display =>
                                                                                ConsoleNavigation.PrintObject(display.DisplayDevice,
                                                                                                              "GridTopologyDisplay.DisplayDevice"), "GridTopology.Displays",
                                                                                "Select a grid topology display to show display device information"),
                                                  "GridTopology.GetGridTopologies()", "Select a grid topology to show display informations")
                },
                {
                    "NVIDIA Driver and API version", () => ConsoleNavigation.PrintObject(new object[]
                    {
                        "Driver Version: " + NVIDIA.DriverVersion,
                        "Driver Branch Version: " + NVIDIA.DriverBranchVersion,
                        "NvAPI Version: " + NVIDIA.InterfaceVersionString
                    }, "NVIDIA")
                },
                { "System Chipset Info", () => ConsoleNavigation.PrintObject(NVIDIA.ChipsetInfo, "NVIDIA.ChipsetInfo") },
                {
                    "Lid and Dock Information",
                    () => ConsoleNavigation.PrintObject(NVIDIA.LidAndDockParameters, "NVIDIA.LidAndDockParameters")
                }
            };

            ConsoleNavigation.PrintNavigation(navigation, "Execution Lines",
                                              "Select an execution line to browse NvAPIWrapper functionalities.");
        }
示例#12
0
 public void Unload()
 {
     NVIDIA.Unload();
 }
示例#13
0
 public void Initialize()
 {
     NVIDIA.Initialize();
 }