//清除数据 private void ClearData(object sender, EventArgs e) { foreach (var item in _device429.ReceiveComponents) { Channe429Receive sendChanel = (Channe429Receive)item; sendChanel.count = 0; sendChanel.errCount = 0; sendChanel.DeviceCount = 0; sendChanel.errDeviceCount = 0; for (int i = 0; i <= 377; i++) { ReceiveLabel429 label = (ReceiveLabel429)sendChanel.GetSpecificItem(i); if (label != null) { sendChanel.Delete(label); } } Channel429DriverRx channel429DriverRx = new Channel429DriverRx(_device429.DevID, sendChanel.ChannelID); uint ret = channel429DriverRx.ChannelMibClearRx(); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when clear receive data", ret)); } } }
protected void OnProcess() { while (true) { int countRe = 0; int totalError = 0; uint totalDviceCount = 0; uint totalDeviceErrCount = 0; string result = string.Empty; foreach (var ch in _device429.ReceiveComponents) { uint data = 0; Channe429Receive chennel = (Channe429Receive)ch; countRe += chennel.count; totalError += chennel.errCount; totalDviceCount += chennel.DeviceCount; totalDeviceErrCount += chennel.errDeviceCount; if (chennel.isSend == true) { if (chennel.rxpA429Result.data != 0) { data = chennel.rxpA429Result.data; } if (data != 0) { //对data进行解析 AnalysisLabel label = new AnalysisLabel(); label.ActualValue = (int)data; ReceiveLabel429 receiveLabel = new ReceiveLabel429("label_" + label.Label.ToString()); receiveLabel.ActualValue = label.ActualValue; ReceiveLabel429 receiveLabelExactHas = (ReceiveLabel429)chennel.GetSpecificItem("label_" + label.Label.ToString()); if (receiveLabelExactHas == null) { chennel.Add(receiveLabel); } result += DateTime.Now.ToString() + "\r\n" + "label:\n"; if (checkBox1.Checked == false) { result += data.ToString("x2"); } else { result += data.ToString("x8"); } //这里需要保存log textBox1.Text += result + "\r\n"; } } } if (!this.IsDisposed)//如果窗口没有释放,那么就不停的刷新tree,释放了就不在使用刷新这个方法 { UpdateTreeView1(); } label_totalCount.Text = countRe.ToString(); label_totalError.Text = totalError.ToString(); label4.Text = totalDviceCount.ToString(); label6.Text = totalDeviceErrCount.ToString(); Thread.Sleep(500); } }