ReportDiscardedValue() public static method

Reports a value discarded because of queue overflow.
public static ReportDiscardedValue ( NodeId nodeId, uint serverHandle, DataValue value ) : void
nodeId NodeId
serverHandle uint
value DataValue
return void
Beispiel #1
0
        /// <summary>
        /// Adds the value to the queue. Discards values if the queue is full.
        /// </summary>
        /// <param name="value">The value to add.</param>
        /// <param name="error">The error to add.</param>
        private void Enqueue(DataValue value, ServiceResult error)
        {
            // check for empty queue.
            if (m_start < 0)
            {
                m_start    = 0;
                m_end      = 1;
                m_overflow = -1;

                Utils.Trace("ENQUEUE VALUE: Value={0}", value.WrappedValue);

                m_values[m_start] = value;

                if (m_errors != null)
                {
                    m_errors[m_start] = error;
                }

                return;
            }

            int next = m_end;

            // check if the latest value has initial dummy data
            if (m_values[m_end - 1].StatusCode != StatusCodes.BadWaitingForInitialData)
            {
                // check for wrap around.
                if (next >= m_values.Length)
                {
                    next = 0;
                }

                // check if queue is full.
                if (m_start == next)
                {
                    m_discardedValueHandler?.Invoke();

                    if (!m_discardOldest)
                    {
                        m_overflow = m_end - 1;
                        ServerUtils.ReportDiscardedValue(null, m_monitoredItemId, value);

                        // overwrite last value
                        m_values[m_overflow] = value;

                        if (m_errors != null)
                        {
                            m_errors[m_overflow] = error;
                        }

                        return;
                    }

                    // remove oldest value.
                    m_start++;

                    if (m_start >= m_values.Length)
                    {
                        m_start = 0;
                    }

                    // set overflow bit.
                    m_overflow = m_start;
                    ServerUtils.ReportDiscardedValue(null, m_monitoredItemId, m_values[m_overflow]);
                }
                else
                {
                    Utils.Trace("ENQUEUE VALUE: Value={0}", value.WrappedValue);
                }
            }
            else
            {
                // overwrite the last value
                next = m_end - 1;
            }

            // add value.
            m_values[next] = value;

            if (m_errors != null)
            {
                m_errors[next] = error;
            }

            m_end = next + 1;
        }