private void initialize() { var command = new byte[] { 0x10, 0x01 }; mUSBController.send(command); command = new byte[] { 0x20, 0x03 }; mUSBController.send(command); command = new byte[] { 0x60, 0x03 }; mUSBController.send(command); command = new byte[] { 0x60, 0x02, 0x01, 0xe8, 0x03, 0x01, 0xe8, 0x03 }; mUSBController.send(command); if (mIsSendCustomData == false) { command = new byte[] { 0x28, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; mUSBController.send(command); command = new byte[] { 0x28, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; mUSBController.send(command); } }
private void onTimer(object sender, EventArgs e) { if (Monitor.TryEnter(mLock) == false) { return; } try { long startTime = Util.getNowMS(); // pump if (mPumpSpeed != mLastPumpSpeed || mPumpLastSendTime == 0 || startTime - mPumpLastSendTime >= mSendDelayTime) { mLastPumpSpeed = mPumpSpeed; mPumpLastSendTime = startTime; // X3 if (mUSBController.ProductID == USBProductID.KrakenX3) { var commandList = new List <byte>(); commandList.Add(0x72); commandList.Add(0x01); commandList.Add(0x00); commandList.Add(0x00); for (int i = 0; i < 40; i++) { commandList.Add(Convert.ToByte(mPumpSpeed)); } mUSBController.send(commandList.ToArray()); } // X2 else { var command = new byte[] { 0x02, 0x4d, 0x40, 0x00, Convert.ToByte(mPumpSpeed) }; mUSBController.send(command); } } // fan if ((mUSBController.ProductID == USBProductID.KrakenX2) && (mFanPercent != mLastFanPercent || mFanLastSendTime == 0 || startTime - mFanLastSendTime >= mSendDelayTime)) { mLastFanPercent = mFanPercent; mFanLastSendTime = startTime; var command = new byte[] { 0x02, 0x4d, 0x00, 0x00, Convert.ToByte(mFanPercent) }; mUSBController.send(command); } // lighting if (mIsSendCustomData == true && mCustomDataList.Count > 0) { for (int i = 0; i < mCustomDataList.Count; i++) { mUSBController.send(mCustomDataList[i]); } mIsSendCustomData = false; } } catch { } Monitor.Exit(mLock); }
private void onTimer(object sender, EventArgs e) { if (Monitor.TryEnter(mLock) == false) { return; } try { // ping var list = new List <byte[]>(); var command = new byte[] { 0x14, 0x00, 0x00, 0x00 }; list.Add(command); mUSBController.send(list); // pump if (mPumpSpeed != mLastPumpSpeed) { mLastPumpSpeed = mPumpSpeed; double pumpSpeed = Math.Ceiling((mPumpSpeed - 50) / 3.125 + 50); var list2 = new List <byte[]>(); var command2 = new byte[] { 0x13, Convert.ToByte(pumpSpeed) }; list2.Add(command2); mUSBController.send(list2); } // fan if (mFanPercent != mLastFanPercent) { mLastFanPercent = mFanPercent; var list3 = new List <byte[]>(); var commandList = new List <byte>(); commandList.Add(0x11); commandList.Add(0x00); commandList.Add(0x14); commandList.Add(0x20); commandList.Add(0x2a); commandList.Add(0x33); commandList.Add(0x39); commandList.Add(0x3c); for (int i = 0; i < 6; i++) { commandList.Add(Convert.ToByte(mFanPercent)); } list3.Add(commandList.ToArray()); mUSBController.send(list3); } // lighting if (mIsSendCustomData == true && mCustomDataList.Count > 0) { Console.WriteLine("CLC.onTimer() : send lighting -----------------------"); for (int i = 0; i < mCustomDataList.Count; i++) { Util.printHex(mCustomDataList[i].ToArray()); } mUSBController.send(mCustomDataList); mIsSendCustomData = false; } } catch { } Monitor.Exit(mLock); }