Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <summary>
        /// Changes the filter used to select the events.
        /// </summary>
        public void ChangeFilter(FilterDeclaration filter, bool fetchRecent)
        {
            m_filter = filter;
            EventsLV.Items.Clear();

            int index = 0;

            // add or update existing columns.
            for (int ii = 0; ii < m_filter.Fields.Count; ii++)
            {
                if (m_filter.Fields[ii].DisplayInList)
                {
                    if (index >= EventsLV.Columns.Count)
                    {
                        EventsLV.Columns.Add(new ColumnHeader());
                    }

                    EventsLV.Columns[index].Text      = m_filter.Fields[ii].InstanceDeclaration.DisplayName;
                    EventsLV.Columns[index].TextAlign = HorizontalAlignment.Left;
                    index++;
                }
            }

            // remove extra columns.
            while (index < EventsLV.Columns.Count)
            {
                EventsLV.Columns.RemoveAt(EventsLV.Columns.Count - 1);
            }

            // adjust the width of the columns.
            for (int ii = 0; ii < EventsLV.Columns.Count; ii++)
            {
                EventsLV.Columns[ii].Width = -2;
            }

            // fetch recent history.
            if (fetchRecent)
            {
                ReadRecentHistory();
            }

            // update subscription.
            if (m_subscription != null)
            {
                m_monitoredItem.Filter = m_filter.GetFilter();
                m_subscription.ApplyChanges();
            }
        }
Пример #3
0
        /// <summary>
        /// Fetches the recent history.
        /// </summary>
        private void ReadRecentHistory()
        {
            // check if session is active.
            if (m_session != null)
            {
                // check if area supports history.
                IObject area = m_session.NodeCache.Find(m_areaId) as IObject;

                if (area != null && ((area.EventNotifier & EventNotifiers.HistoryRead) != 0))
                {
                    // get the last hour or 10 events.
                    ReadEventDetails details = new ReadEventDetails();
                    details.StartTime        = DateTime.UtcNow.AddSeconds(30);
                    details.EndTime          = details.StartTime.AddHours(-1);
                    details.NumValuesPerNode = 10;
                    details.Filter           = m_filter.GetFilter();

                    // read the history.
                    ReadHistory(details, m_areaId);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Changes the filter used to select the events.
        /// </summary>
        public void ChangeFilter(FilterDeclaration filter, bool fetchRecent)
        {
            m_filter = filter;
            EventsLV.Items.Clear();

            int index = 0;

            // add or update existing columns.
            for (int ii = 0; ii < m_filter.Fields.Count; ii++)
            {
                if (m_filter.Fields[ii].DisplayInList)
                {
                    if (index >= EventsLV.Columns.Count)
                    {
                        EventsLV.Columns.Add(new ColumnHeader());
                    }

                    EventsLV.Columns[index].Text = m_filter.Fields[ii].InstanceDeclaration.DisplayName;
                    EventsLV.Columns[index].TextAlign = HorizontalAlignment.Left;
                    index++;
                }
            }

            // remove extra columns.
            while (index < EventsLV.Columns.Count)
            {
                EventsLV.Columns.RemoveAt(EventsLV.Columns.Count - 1);
            }

            // adjust the width of the columns.
            for (int ii = 0; ii < EventsLV.Columns.Count; ii++)
            {
                EventsLV.Columns[ii].Width = -2;
            }

            // fetch recent history.
            if (fetchRecent)
            {
                ReadRecentHistory();
            }

            // update subscription.
            if (m_subscription != null)
            {
                m_monitoredItem.Filter = m_filter.GetFilter();
                m_subscription.ApplyChanges();
            }
        }