private void AddPropertyRefentry(BacnetDeviceObjectPropertyReference bopr, int IdxRemove) { String newText; if (bopr.deviceIndentifier.type != BacnetObjectTypes.OBJECT_DEVICE) { newText = bopr.objectIdentifier.ToString().Substring(7) + " - " + ((BacnetPropertyIds)bopr.propertyIdentifier).ToString().Substring(5) + " on localDevice"; } else { newText = bopr.objectIdentifier.ToString().Substring(7) + " - " + ((BacnetPropertyIds)bopr.propertyIdentifier).ToString().Substring(5) + " on DEVICE:" + bopr.deviceIndentifier.instance.ToString(); } if (IdxRemove != -1) { listReferences.Items.RemoveAt(IdxRemove); // remove an old entry } ListViewItem lvi = new ListViewItem(); // add a new one lvi.Text = newText; lvi.Tag = bopr; lvi.ImageIndex = MainDialog.GetIconNum(bopr.objectIdentifier.type); listReferences.Items.Add(lvi); }
private void FillTreeNode() { bool EmptyList = (TAlarmList.Nodes.Count == 0); int icon; TAlarmList.BeginUpdate(); // Only one network read request to get the object name int _retries = comm.Retries; comm.Retries = 1; int Idx = 0; // fill the Treenode foreach (BacnetGetEventInformationData alarm in Alarms) { TreeNode currentTn; // get or set the Node if (EmptyList == true) { String nameStr = null; lock (DevicesObjectsName) DevicesObjectsName.TryGetValue(new Tuple <String, BacnetObjectId>(adr.FullHashString(), alarm.objectIdentifier), out nameStr); if (nameStr == null) { // Get the property Name, network activity, time consuming IList <BacnetValue> name; bool retcode = comm.ReadPropertyRequest(adr, alarm.objectIdentifier, BacnetPropertyIds.PROP_OBJECT_NAME, out name); if (retcode) { nameStr = name[0].Value.ToString(); lock (DevicesObjectsName) DevicesObjectsName.Add(new Tuple <String, BacnetObjectId>(adr.FullHashString(), alarm.objectIdentifier), nameStr); } } icon = MainDialog.GetIconNum(alarm.objectIdentifier.type); if (nameStr != null) { currentTn = new TreeNode(nameStr, icon, icon); currentTn.ToolTipText = alarm.objectIdentifier.ToString(); } else { currentTn = new TreeNode(alarm.objectIdentifier.ToString(), icon, icon); } currentTn.Tag = alarm; TAlarmList.Nodes.Add(currentTn); } else { currentTn = TAlarmList.Nodes[Idx++]; currentTn.Nodes.Clear(); } if (Properties.Settings.Default.DescriptionInAlarmSummary) { String Descr = ""; try { // Get the Description, network activity, time consuming IList <BacnetValue> name; bool retcode = comm.ReadPropertyRequest(adr, alarm.objectIdentifier, BacnetPropertyIds.PROP_DESCRIPTION, out name); if (retcode) { Descr = name[0].Value.ToString(); } } catch { } currentTn.Nodes.Add(new TreeNode("Description : " + Descr, Int32.MaxValue, Int32.MaxValue)); } icon = Int32.MaxValue; // out bound currentTn.Nodes.Add(new TreeNode("Alarm state : " + GetEventStateNiceName(alarm.eventState.ToString()), icon, icon)); bool SomeTodo = false; TreeNode tn2 = new TreeNode("Ack Required :", icon, icon); for (int i = 0; i < 3; i++) { if (alarm.acknowledgedTransitions.ToString()[i] == '0') { BacnetEventNotificationData.BacnetEventEnable bee = (BacnetEventNotificationData.BacnetEventEnable)(1 << i); String text = GetEventEnableNiceName(bee.ToString()) + " since " + alarm.eventTimeStamps[i].Time.ToString(); tn2.Nodes.Add(new TreeNode(text, icon, icon)); SomeTodo = true; } } if (SomeTodo == false) { tn2 = new TreeNode("No Ack Required, already done", icon, icon); } currentTn.Nodes.Add(tn2); } // set back the request retries number comm.Retries = _retries; TAlarmList.EndUpdate(); TAlarmList.ExpandAll(); if (Alarms.Count == 0) { LblInfo.Visible = true; LblInfo.Text = "Empty event list ... all is OK"; } }