private void EventTypeBTN_Click(object sender, EventArgs e) { try { if (m_session == null) { return; } TypeDeclaration type = new SelectTypeDlg().ShowDialog(m_session, Opc.Ua.ObjectTypeIds.BaseEventType, "Select Event Type"); if (type == null) { return; } m_filter = new FilterDeclaration(type, m_filter); EventTypeTB.Text = m_session.NodeCache.GetDisplayText(m_filter.EventTypeId); EventFilterTB.Text = GetFilterFields(m_filter); ResultsLV.ChangeFilter(m_filter, false); } catch (Exception exception) { ClientUtils.HandleException(this.Text, exception); } }
private void EventAreaBTN_Click(object sender, EventArgs e) { try { if (m_session == null) { return; } NodeId areaId = new SelectNodeDlg().ShowDialog(m_session, Opc.Ua.ObjectIds.Server, "Select Event Area", Opc.Ua.ReferenceTypeIds.HasEventSource); if (areaId == null) { return; } m_areaId = areaId; EventAreaTB.Text = m_session.NodeCache.GetDisplayText(m_areaId); ResultsLV.ChangeArea(areaId, false); } catch (Exception exception) { ClientUtils.HandleException(this.Text, exception); } }
/// <summary> /// Starts a new read operation. /// </summary> private void ReadFirst() { ResultsLV.ClearEventHistory(); // set up the request parameters. ReadEventDetails details = new ReadEventDetails(); details.StartTime = DateTime.MinValue; details.EndTime = DateTime.MinValue; details.NumValuesPerNode = 0; details.Filter = m_filter.GetFilter(); if (StartTimeCK.Checked) { details.StartTime = StartTimeDP.Value.ToUniversalTime(); } if (EndTimeCK.Checked) { details.EndTime = EndTimeDP.Value.ToUniversalTime(); } if (MaxReturnValuesCK.Checked) { details.NumValuesPerNode = (uint)MaxReturnValuesNP.Value; } // read the events from the server. HistoryReadValueId nodeToRead = new HistoryReadValueId(); nodeToRead.NodeId = m_areaId; ReadNext(details, nodeToRead); }
/// <summary> /// Continues a read operation. /// </summary> private void ReadNext(ReadEventDetails details, HistoryReadValueId nodeToRead) { HistoryReadValueIdCollection nodesToRead = new HistoryReadValueIdCollection(); nodesToRead.Add(nodeToRead); HistoryReadResultCollection results = null; DiagnosticInfoCollection diagnosticInfos = null; ResponseHeader responseHeader = m_session.HistoryRead( null, new ExtensionObject(details), TimestampsToReturn.Neither, false, nodesToRead, out results, out diagnosticInfos); Session.ValidateResponse(results, nodesToRead); Session.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead); if (StatusCode.IsBad(results[0].StatusCode)) { throw ServiceResultException.Create(results[0].StatusCode, 0, diagnosticInfos, responseHeader.StringTable); } // display results. HistoryEvent data = ExtensionObject.ToEncodeable(results[0].HistoryData) as HistoryEvent; ResultsLV.AddEventHistory(data); // check if a continuation point exists. if (results[0].ContinuationPoint != null && results[0].ContinuationPoint.Length > 0) { nodeToRead.ContinuationPoint = results[0].ContinuationPoint; NextBTN.Visible = true; StopBTN.Enabled = true; GoBTN.Visible = false; m_details = details; m_nodeToRead = nodeToRead; } // all done. else { NextBTN.Visible = false; StopBTN.Enabled = false; GoBTN.Visible = true; m_details = null; m_nodeToRead = null; } }
/// <summary> /// Displays the dialog. /// </summary> public bool ShowDialog(Session session, NodeId areaId, FilterDeclaration filter) { m_session = session; m_areaId = areaId; m_filter = filter; EventAreaTB.Text = session.NodeCache.GetDisplayText(m_areaId); EventTypeTB.Text = session.NodeCache.GetDisplayText(filter.EventTypeId); EventFilterTB.Text = GetFilterFields(m_filter); ResultsLV.IsSubscribed = false; ResultsLV.ChangeSession(session, false); ResultsLV.ChangeArea(areaId, false); ResultsLV.ChangeFilter(filter, false); // get the beginning of data. DateTime startTime; try { startTime = ReadFirstDate().ToLocalTime(); } catch (Exception) { startTime = new DateTime(2000, 1, 1); } StartTimeDP.Value = startTime; StartTimeCK.Checked = true; EndTimeDP.Value = DateTime.Now; EndTimeCK.Checked = true; MaxReturnValuesNP.Value = 10; MaxReturnValuesCK.Checked = true; GoBTN.Visible = true; NextBTN.Visible = false; StopBTN.Enabled = false; if (ShowDialog() != DialogResult.OK) { return(false); } return(true); }
private void EventFilterBTN_Click(object sender, EventArgs e) { try { if (m_session == null) { return; } if (!new ModifyFilterDlg().ShowDialog(m_filter)) { return; } EventFilterTB.Text = GetFilterFields(m_filter); ResultsLV.ChangeFilter(m_filter, false); } catch (Exception exception) { ClientUtils.HandleException(this.Text, exception); } }