// Update HMI and counters void MessageReceivedIndication(byte frame_type, byte source_address) { treeView.BeginUpdate(); // Find the node BacnetNode noeud = NoeudsMstp.Find(item => item.Num == source_address); if (noeud == null) // Not here, creation { noeud = MakeNewNode(source_address); } // Update node data noeud.NewFrameSend((int)frame_type); // TreeView update TreeNode[] Tn = treeView.Nodes.Find(source_address.ToString(), false); for (int i = 0; i < 10; i++) { Tn[0].Nodes[1].Nodes[i].Text = noeud.FrameTypeStatistic[i].ToString() + " - " + GetNiceName((SnifferDisplayBacnetMstpFrameTypes)i); } Tn[0].Nodes[0].Nodes[0].Text = noeud.TotalFrames.ToString() + " Total"; Tn[0].Nodes[0].Nodes[1].Text = noeud.MeanTimeTokenRotation.ToString() + " ms MTTR"; treeView.EndUpdate(); }
// A new node on Mstp, add it to the list and into the treeview BacnetNode MakeNewNode(byte source_address) { BacnetNode noeud = new BacnetNode(source_address); NoeudsMstp.Add(noeud); // New TreeView node : Key and value are the address, Tag also but in int format TreeNode T = treeView.Nodes.Add(source_address.ToString(), Master + source_address.ToString(), 0, 0); T.Tag = (int)source_address; // used to sort the treeview by source address criteria treeView.Sort(); TreeNode T2 = T.Nodes.Add("Global", "Global", 1, 1); TreeNode T3 = T2.Nodes.Add("", "", 3, 3); T3.Tag = 0; T3 = T2.Nodes.Add("", "", 3, 3); T3.Tag = 1; TreeNode T4 = T.Nodes.Add("Detail", "Detail", 2, 2); T4.Tag = 1; // No need to put a real content, it will be overwrite just after for (int i = 0; i < 10; i++) { TreeNode T5 = T4.Nodes.Add(i.ToString(), "", 3, 3); T5.Tag = i; } return(noeud); }