private void OnDeviceDataReceived(object sender, EventArgs e) { HangingBalanceEventArgs args = e as HangingBalanceEventArgs; if (args.Command == null) { return; } SerialDevice.CommandType type = args.Command.mCmdType; if (type == SerialDevice.CommandType.E0) { CommandE0 e0 = args.Command as CommandE0; ushort ad = e0.GetAD(); if (mHasReadTimes == 1) { mAdWeightFirst = ad; } if (mHasReadTimes == 2) { mAdWeightSecond = ad; } if (mHasReadTimes == 2) { if (Math.Abs(mAdWeightSecond - mAdWeightFirst) <= mStandardError) { mAdWeights.Add((mAdWeightSecond + mAdWeightFirst) / 2); StopTimer(); ShowNextCalibrateTips(); EnableControls(true); } else { //不合格要重新来,否则时钟不会停 mHasReadTimes = 0; mTempAdWeights.Clear(); } } } }
private void OnDetectBalanceDataReceived(object sender, EventArgs e) { HangingBalanceEventArgs args = e as HangingBalanceEventArgs; // args.PortName }