Exemplo n.º 1
0
 public static bool init()
 {
     try
     {
         return(WinUSBController.initUSB());
     }
     catch { }
     return(false);
 }
Exemplo n.º 2
0
        public override bool start()
        {
            Monitor.Enter(mLock);
            try
            {
                if (WinUSBController.initUSB() == false)
                {
                    Console.WriteLine("WinUSBController.start() : Failed init");
                    Monitor.Exit(mLock);
                    this.stop();
                    return(false);
                }

                mDeviceHandle = WinUSBController.open((ushort)VendorID, (ushort)ProductID);
                mIsDeviceOpen = WinUSBController.isOpen(mDeviceHandle);
                if (mIsDeviceOpen == false)
                {
                    Console.WriteLine("WinUSBController.start() : Failed open, vendor(0x{0:X4}), product(0x{1:X4})", (ushort)VendorID, (ushort)ProductID);
                    Monitor.Exit(mLock);
                    this.stop();
                    return(false);
                }

                int ret = WinUSBController.controlTransfer(mDeviceHandle, USBXPRESS, USBXPRESS_REQUEST, USBXPRESS_CLEAR_TO_SEND, 0, null, 0, 0);
                if (ret < 0)
                {
                    Console.WriteLine(String.Format("WinUSBController.start() : Failed controlTransfer({0})", ret));
                    Monitor.Exit(mLock);
                    this.stop();
                    return(false);
                }

                mThreadState = true;
                mThread      = new Thread(threadFunc);
                mThread.Start();
            }
            catch (Exception e)
            {
                Console.WriteLine("SiUSBController.start() : Failed catch({0})", e.Message);
                Monitor.Exit(mLock);
                this.stop();
                return(false);
            }
            Monitor.Exit(mLock);
            return(true);
        }
Exemplo n.º 3
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);
        }