public static ushort[] i2cWordData(int index, byte address, int length) { Monitor.Enter(sLock); if (sIsOpen == false) { Monitor.Exit(sLock); return(null); } try { var pByteArrayData = SMBusController.getI2CWordData(index, address, length); var datas = SMBusController.getBytes(pByteArrayData); SMBusController.deleteByteArrayData(pByteArrayData); var retData = new ushort[length]; for (int i = 0; i < length; i++) { retData[i] = BitConverter.ToUInt16(datas, i * 2); } Monitor.Exit(sLock); return(retData); } catch { } Monitor.Exit(sLock); return(null); }
private void onSetDimmTemperature(object sender, int busIndex, byte address) { var sensor = (DimmTemp)sender; if (this.lockSMBus(10) == false) { return; } var wordArray = SMBusController.i2cWordData(busIndex, address, 10); if (wordArray == null) { this.unlockSMBus(); return; } this.unlockSMBus(); if (wordArray != null && wordArray.Length == 10) { var temp = BitConverter.GetBytes(wordArray[5]); temp[1] = (byte)(temp[1] & 0x0F); ushort count = BitConverter.ToUInt16(temp, 0); double value = Math.Round(count * 0.0625f); if (value > 0) { sensor.Value = (int)value; } } return; }
public override void update() { if (LockBus(10) == false) { return; } ushort data = SMBusController.smbusWordData(mAddress, 5); UnlockBus(); if (data > 0) { var temp = BitConverter.GetBytes(data); Array.Reverse(temp); temp[1] = (byte)(temp[1] & 0x0F); ushort count = BitConverter.ToUInt16(temp, 0); double value = Math.Round(count * 0.0625f); if (value > 0) { Value = (int)value; } } Util.sleep(10); }
private static byte[] getBytes(IntPtr pByteArrayData) { var datas = SMBusController.getData(pByteArrayData); int dataSize = SMBusController.getDataSize(pByteArrayData); var retData = new byte[dataSize]; Marshal.Copy(datas, retData, 0, dataSize); return(retData); }
public static void close() { Monitor.Enter(sLock); if (sIsOpen == false) { Monitor.Exit(sLock); return; } try { SMBusController.closeSMBus(); } catch { } sIsOpen = false; Monitor.Exit(sLock); }
public static int getCount() { Monitor.Enter(sLock); if (sIsOpen == false) { Monitor.Exit(sLock); return(0); } try { int count = SMBusController.getSMBusCount(); Monitor.Exit(sLock); return(count); } catch { } Monitor.Exit(sLock); return(0); }
public static byte i2cDetectWithAddress(int index, byte address) { Monitor.Enter(sLock); if (sIsOpen == false) { Monitor.Exit(sLock); return(0x00); } try { byte data = SMBusController.getI2CDetectWithAddress(index, address); Monitor.Exit(sLock); return(data); } catch { } Monitor.Exit(sLock); return(0x00); }
public static bool open(bool isCreateCOM) { Monitor.Enter(sLock); if (sIsOpen == true) { Monitor.Exit(sLock); return(true); } try { sIsOpen = (SMBusController.openSMBus(isCreateCOM) > 0); } catch { sIsOpen = false; } Monitor.Exit(sLock); return(sIsOpen); }
public static byte[] i2cDetect(int index) { Monitor.Enter(sLock); if (sIsOpen == false) { Monitor.Exit(sLock); return(null); } try { var pByteArrayData = SMBusController.getI2CDetect(index); var retData = SMBusController.getBytes(pByteArrayData); SMBusController.deleteByteArrayData(pByteArrayData); Monitor.Exit(sLock); return(retData); } catch { } Monitor.Exit(sLock); return(null); }
public static byte[] i2cByteData(int index, byte address, int length) { Monitor.Enter(sLock); if (sIsOpen == false) { Monitor.Exit(sLock); return(null); } try { var pByteArrayData = SMBusController.getI2CByteData(index, address, length); var retData = SMBusController.getBytes(pByteArrayData); SMBusController.deleteByteArrayData(pByteArrayData); Monitor.Exit(sLock); return(retData); } catch { } Monitor.Exit(sLock); return(null); }
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); }
public void stop() { Monitor.Enter(mLock); if (mIsStart == false) { Monitor.Exit(mLock); return; } mIsStart = false; mChangeControlList.Clear(); mChangeValueList.Clear(); mUpdateTimer.Stop(); if (mLHM != null) { mLHM.stop(); mLHM = null; } if (mOHM != null) { mOHM.stop(); mOHM = null; } try { if (mKraken != null) { mKraken.stop(); mKraken = null; } } catch { } try { if (mCLC != null) { mCLC.stop(); mCLC = null; } } catch { } try { if (mRGBnFC != null) { mRGBnFC.stop(); mRGBnFC = null; } } catch { } if (mIsGigabyte == true && mGigabyte != null) { mIsGigabyte = false; mGigabyte.stop(); mGigabyte = null; } mSensorList.Clear(); mFanList.Clear(); mControlList.Clear(); SMBusController.close(); if (mISABusMutex != null) { mISABusMutex.Close(); mISABusMutex = null; } if (mSMBusMutex != null) { mSMBusMutex.Close(); mSMBusMutex = null; } if (mPCIMutex != null) { mPCIMutex.Close(); mPCIMutex = null; } OSDController.releaseOSD(); Monitor.Exit(mLock); }
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); }
public void stop() { Monitor.Enter(mLock); if (mIsStart == false) { Monitor.Exit(mLock); return; } mIsStart = false; mChangeControlList.Clear(); mChangeValueList.Clear(); mUpdateTimer.Stop(); if (mLHM != null) { mLHM.stop(); mLHM = null; } if (mOHM != null) { mOHM.stop(); mOHM = null; } for (int i = 0; i < mKrakenList.Count; i++) { try { mKrakenList[i].stop(); } catch { } } mKrakenList.Clear(); for (int i = 0; i < mCLCList.Count; i++) { try { mCLCList[i].stop(); } catch { } } mCLCList.Clear(); for (int i = 0; i < mRGBnFCList.Count; i++) { try { mRGBnFCList[i].stop(); } catch { } } mRGBnFCList.Clear(); if (mIsGigabyte == true && mGigabyte != null) { mIsGigabyte = false; mGigabyte.stop(); mGigabyte = null; } mSensorList.Clear(); mFanList.Clear(); mControlList.Clear(); SMBusController.close(); if (mISABusMutex != null) { mISABusMutex.Close(); mISABusMutex = null; } if (mSMBusMutex != null) { mSMBusMutex.Close(); mSMBusMutex = null; } if (mPCIMutex != null) { mPCIMutex.Close(); mPCIMutex = null; } OSDController.releaseOSD(); WinUSBController.exitUSB(); Monitor.Exit(mLock); }