A object which maps a segment to a UA object.
Inheritance: Opc.Ua.BaseObjectState
Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComAeSubscriptionClient"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="cache">The cache for known types.</param>
        /// <param name="namespaceIndex">The namespace index for the event types.</param>
        /// <param name="manager">The manager.</param>
        /// <param name="monitoredItem">The monitored item.</param>
        public ComAeSubscriptionClient(
            ServerSystemContext context,
            ComAeClientConfiguration configuration,
            AeTypeCache cache,
            ushort namespaceIndex,
            ComAeClientManager manager,
            MonitoredItem monitoredItem)
        {
            m_defaultContext  = context;
            m_separators      = configuration.SeperatorChars;
            m_cache           = cache;
            m_namespaceIndex  = namespaceIndex;
            m_manager         = manager;
            m_refreshComplete = new ManualResetEvent(false);
            m_monitoredItems  = new List <MonitoredItem>();
            m_monitoredItems.Add(monitoredItem);
            m_qualifiedName = null;
            m_isSource      = false;

            NodeHandle  handle = monitoredItem.ManagerHandle as NodeHandle;
            AeAreaState area   = handle.Node as AeAreaState;

            if (area != null)
            {
                m_qualifiedName = area.QualifiedName;
                m_isSource      = false;
            }
            else
            {
                AeSourceState source = handle.Node as AeSourceState;

                if (source != null)
                {
                    m_qualifiedName = source.QualifiedName;
                    m_isSource      = true;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the next AE area or source.
        /// </summary>
        /// <returns>A DA element. Null if nothing left to browse.</returns>
        public BaseObjectState Next(ISystemContext context, ushort namespaceIndex)
        {
            // check if already completed.
            if (m_completed)
            {
                return(null);
            }

            // create the browser.
            if (base.Unknown == null)
            {
                base.Unknown = m_client.CreateAreaBrowser();

                if (base.Unknown == null)
                {
                    return(null);
                }

                if (!ChangeBrowsePosition(OPCAEBROWSEDIRECTION.OPCAE_BROWSE_TO, m_qualifiedName))
                {
                    return(null);
                }
            }

            // create the enumerator if not already created.
            if (m_enumerator == null)
            {
                m_enumerator = CreateEnumerator(false);
                m_sources    = false;

                // a null indicates an error.
                if (m_enumerator == null)
                {
                    m_completed = true;
                    return(null);
                }
            }

            // need a loop in case errors occur fetching element metadata.
            BaseObjectState node = null;

            do
            {
                // fetch the next name.
                string name = m_enumerator.Next();

                // a null indicates the end of list.
                if (name == null)
                {
                    if (!m_sources)
                    {
                        m_enumerator.Dispose();
                        m_enumerator = CreateEnumerator(true);
                        m_sources    = true;
                        continue;
                    }

                    m_completed = true;
                    return(null);
                }

                // create the node.
                if (m_sources)
                {
                    string qualifiedName = GetQualifiedSourceName(name);

                    if (String.IsNullOrEmpty(qualifiedName))
                    {
                        continue;
                    }

                    node = new AeSourceState(context, m_qualifiedName, qualifiedName, name, namespaceIndex);
                }
                else
                {
                    string qualifiedName = GetQualifiedAreaName(name);

                    if (String.IsNullOrEmpty(qualifiedName))
                    {
                        continue;
                    }

                    node = new AeAreaState(context, qualifiedName, name, namespaceIndex);
                }

                break;
            }while (node == null);

            // return node.
            return(node);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the next AE area or source.
        /// </summary>
        /// <returns>A DA element. Null if nothing left to browse.</returns>
        public BaseObjectState Next(ISystemContext context, ushort namespaceIndex)
        {
            // check if already completed.
            if (m_completed)
            {
                return null;
            }

            // create the browser.
            if (base.Unknown == null)
            {
                base.Unknown = m_client.CreateAreaBrowser();

                if (base.Unknown == null)
                {
                    return null;
                }

                if (!ChangeBrowsePosition(OPCAEBROWSEDIRECTION.OPCAE_BROWSE_TO, m_qualifiedName))
                {
                    return null;
                }
            }

            // create the enumerator if not already created.
            if (m_enumerator == null)
            {
                m_enumerator = CreateEnumerator(false);
                m_sources = false;

                // a null indicates an error.
                if (m_enumerator == null)
                {
                    m_completed = true;
                    return null;
                }
            }

            // need a loop in case errors occur fetching element metadata.
            BaseObjectState node = null;

            do
            {
                // fetch the next name.
                string name = m_enumerator.Next();

                // a null indicates the end of list.
                if (name == null)
                {
                    if (!m_sources)
                    {
                        m_enumerator.Dispose();
                        m_enumerator = CreateEnumerator(true);
                        m_sources = true;
                        continue;
                    }

                    m_completed = true;
                    return null;
                }

                // create the node.
                if (m_sources)
                {
                    string qualifiedName = GetQualifiedSourceName(name);

                    if (String.IsNullOrEmpty(qualifiedName))
                    {
                        continue;
                    }

                    node = new AeSourceState(context, m_qualifiedName, qualifiedName, name, namespaceIndex);
                }
                else
                {
                    string qualifiedName = GetQualifiedAreaName(name);

                    if (String.IsNullOrEmpty(qualifiedName))
                    {
                        continue;
                    }

                    node = new AeAreaState(context, qualifiedName, name, namespaceIndex);
                }

                break;
            }
            while (node == null);

            // return node.
            return node;
        }