private void AckBt_Click(object sender, EventArgs e) { List <TreeNode> listacq = new List <TreeNode>(); foreach (TreeNode t in TAlarmList.SelectedNodes) { TreeNode t2 = t; while (t2.Parent != null) { t2 = t2.Parent; // go to the root element } if (!listacq.Exists((o) => o == t2)) { listacq.Add(t2); } } foreach (TreeNode t in listacq) { BacnetGetEventInformationData alarm = (BacnetGetEventInformationData)t.Tag; // the alam content AcqAlarm(alarm); } FillTreeNode(); }
// Used if the Read without retries has fail private void TAlarmList_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode tn = e.Node; while (tn.Parent != null) { tn = tn.Parent; } if (tn.ToolTipText == "") { BacnetGetEventInformationData alarm = (BacnetGetEventInformationData)tn.Tag; IList <BacnetValue> name; comm.ReadPropertyRequest(adr, alarm.objectIdentifier, BacnetPropertyIds.PROP_OBJECT_NAME, out name); tn.ToolTipText = tn.Text; if (Properties.Settings.Default.DisplayIdWithName) { tn.Text = name[0].Value.ToString() + " (" + System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(tn.ToolTipText) + ")"; } else { tn.Text = name[0].Value.ToString(); } } }
private void AckBt_Click(object sender, EventArgs e) { TreeNode tn = TAlarmList.SelectedNode; if (tn == null) { return; } while (tn.Parent != null) { tn = tn.Parent; // go up } BacnetGetEventInformationData alarm = (BacnetGetEventInformationData)tn.Tag; // the alam content bool SomeChanges = false; for (int i = 0; i < 3; i++) // 3 transitions maybe to be ack To_Normal, To_OfNormal, To_Fault { if (alarm.acknowledgedTransitions.ToString()[i] == '0') // Transition to be ack, 1 means ok/already done { BacnetGenericTime bgt; if (alarm.eventTimeStamps != null) { bgt = alarm.eventTimeStamps[i]; } else // Deprecate Execution of GetAlarmSummary { // Read the event time stamp, we do not have it IList <BacnetValue> values; if (comm.ReadPropertyRequest(adr, alarm.objectIdentifier, BacnetPropertyIds.PROP_EVENT_TIME_STAMPS, out values, 0, (uint)i) == false) { Trace.TraceWarning("Error reading PROP_EVENT_TIME_STAMPS"); return; } String s1 = ((BacnetValue[])(values[0].Value))[0].ToString(); // Date & 00:00:00 for Hour String s2 = ((BacnetValue[])(values[0].Value))[1].ToString(); // 00:00:00 & Time DateTime dt = Convert.ToDateTime(s1.Split(' ')[0] + " " + s2.Split(' ')[1]); bgt = new BacnetGenericTime(dt, BacnetTimestampTags.TIME_STAMP_DATETIME); } // something to clarify : BacnetEventStates or BacnetEventEnable !!! BacnetEventNotificationData.BacnetEventStates eventstate = (BacnetEventNotificationData.BacnetEventStates)(2 - i); if (comm.AlarmAcknowledgement(adr, alarm.objectIdentifier, eventstate, AckText.Text, bgt, new BacnetGenericTime(DateTime.Now, BacnetTimestampTags.TIME_STAMP_DATETIME)) == true) { alarm.acknowledgedTransitions.SetBit((byte)i, true); SomeChanges = true; } } if (SomeChanges) { FillTreeNode(); } } }
// Used if the Read without retries has fail private void TAlarmList_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode tn = e.Node; while (tn.Parent != null) { tn = tn.Parent; } if (tn.ToolTipText == "") { BacnetGetEventInformationData alarm = (BacnetGetEventInformationData)tn.Tag; IList <BacnetValue> name; comm.ReadPropertyRequest(adr, alarm.objectIdentifier, BacnetPropertyIds.PROP_OBJECT_NAME, out name); tn.ToolTipText = tn.Text; tn.Text = name[0].Value.ToString(); } }