Browses areas and sources in the AE server.
Inheritance: ComObject
示例#1
0
        /// <summary>
        /// Initializes the next stage of browsing.
        /// </summary>
        private void NextStage()
        {
            ComAeClientManager system = (ComAeClientManager)this.SystemContext.SystemHandle;
            ComAeClient        client = system.SelectClient((ServerSystemContext)SystemContext, false);

            // determine which stage is next based on the reference types requested.
            for (Stage next = m_stage + 1; next <= Stage.Done; next++)
            {
                if (next == Stage.Children)
                {
                    if (IsRequired(ReferenceTypeIds.HasNotifier, false))
                    {
                        m_stage = next;
                        break;
                    }
                }

                else if (next == Stage.Parents)
                {
                    if (IsRequired(ReferenceTypeIds.HasNotifier, true))
                    {
                        m_stage = next;
                        break;
                    }
                }

                else if (next == Stage.Done)
                {
                    m_stage = next;
                    break;
                }
            }

            // start enumerating areas.
            if (m_stage == Stage.Children)
            {
                m_browser = new ComAeBrowserClient(client, m_qualifiedName);
                return;
            }

            // start enumerating parents.
            if (m_stage == Stage.Parents)
            {
                return;
            }

            // all done.
        }
        /// <summary>
        /// Verifies that the specified node exists.
        /// </summary>
        protected override NodeState ValidateNode(
            ServerSystemContext context,
            NodeHandle handle,
            IDictionary <NodeId, NodeState> cache)
        {
            // not valid if no root.
            if (handle == null)
            {
                return(null);
            }

            // check if previously validated.
            if (handle.Validated)
            {
                return(handle.Node);
            }

            NodeState target = null;

            // check if already in the cache.
            if (cache != null)
            {
                if (cache.TryGetValue(handle.NodeId, out target))
                {
                    // nulls mean a NodeId which was previously found to be invalid has been referenced again.
                    if (target == null)
                    {
                        return(null);
                    }

                    handle.Node      = target;
                    handle.Validated = true;
                    return(handle.Node);
                }

                target = null;
            }

            try
            {
                // check if the node id has been parsed.
                AeParsedNodeId parsedNodeId = handle.ParsedNodeId as AeParsedNodeId;

                if (parsedNodeId == null)
                {
                    return(null);
                }

                ComAeClient client = m_system.SelectClient(context, false);

                switch (parsedNodeId.RootType)
                {
                case AeModelUtils.AeSimpleEventType:
                case AeModelUtils.AeTrackingEventType:
                case AeModelUtils.AeConditionEventType:
                {
                    if (m_typeCache == null)
                    {
                        return(null);
                    }

                    BaseObjectTypeState eventTypeNode = null;
                    NodeId rootId = AeParsedNodeId.Construct(parsedNodeId.RootType, parsedNodeId.CategoryId, parsedNodeId.ConditionName, parsedNodeId.NamespaceIndex);

                    if (!m_typeCache.EventTypeNodes.TryGetValue(rootId, out eventTypeNode))
                    {
                        return(null);
                    }

                    target = eventTypeNode;
                    break;
                }

                case AeModelUtils.AeArea:
                {
                    ComAeBrowserClient browser = new ComAeBrowserClient(client, null);
                    target = browser.FindArea(context, parsedNodeId.RootId, NamespaceIndex);
                    browser.Dispose();

                    handle.Validated = true;
                    handle.Node      = target;
                    return(handle.Node);
                }

                case AeModelUtils.AeSource:
                {
                    ComAeBrowserClient browser = new ComAeBrowserClient(client, null);
                    target = browser.FindSource(context, parsedNodeId.RootId, parsedNodeId.ComponentPath, NamespaceIndex);
                    browser.Dispose();

                    handle.Validated = true;
                    handle.Node      = target;
                    return(handle.Node);
                }

                case AeModelUtils.AeCondition:
                {
                    target = new AeConditionState(context, handle, m_templateAlarm.Acknowledge);
                    break;
                }
                }

                // node does not exist.
                if (target == null)
                {
                    return(null);
                }

                if (!String.IsNullOrEmpty(parsedNodeId.ComponentPath))
                {
                    // validate component.
                    NodeState component = target.FindChildBySymbolicName(context, parsedNodeId.ComponentPath);

                    // component does not exist.
                    if (component == null)
                    {
                        return(null);
                    }

                    target = component;
                }

                // found a valid component.
                handle.Validated = true;
                handle.Node      = target;
                return(handle.Node);
            }
            finally
            {
                // store the node in the cache to optimize subsequent lookups.
                if (cache != null)
                {
                    cache.Add(handle.NodeId, target);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Initializes the next stage of browsing.
        /// </summary>
        private void NextStage()
        {
            ComAeClientManager system = (ComAeClientManager)this.SystemContext.SystemHandle;
            ComAeClient client = system.SelectClient((ServerSystemContext)SystemContext, false);

            // determine which stage is next based on the reference types requested.
            for (Stage next = m_stage+1; next <= Stage.Done; next++)
            {
                if (next == Stage.Children)
                {
                    if (IsRequired(ReferenceTypeIds.HasNotifier, false))
                    {
                        m_stage = next;
                        break;
                    }
                }

                else if (next == Stage.Parents)
                {
                    if (IsRequired(ReferenceTypeIds.HasNotifier, true))
                    {
                        m_stage = next;
                        break;
                    }
                }

                else if (next == Stage.Done)
                {
                    m_stage = next;
                    break;
                }
            }

            // start enumerating areas.
            if (m_stage == Stage.Children)
            {
                m_browser = new ComAeBrowserClient(client, m_qualifiedName);
                return;
            }

            // start enumerating parents.
            if (m_stage == Stage.Parents)
            {
                return;
            }

            // all done.
        }
        /// <summary>
        /// Verifies that the specified node exists.
        /// </summary>
        protected override NodeState ValidateNode(
            ServerSystemContext context,
            NodeHandle handle,
            IDictionary<NodeId, NodeState> cache)
        {
            // not valid if no root.
            if (handle == null)
            {
                return null;
            }

            // check if previously validated.
            if (handle.Validated)
            {
                return handle.Node;
            }

            NodeState target = null;

            // check if already in the cache.
            if (cache != null)
            {
                if (cache.TryGetValue(handle.NodeId, out target))
                {
                    // nulls mean a NodeId which was previously found to be invalid has been referenced again.
                    if (target == null)
                    {
                        return null;
                    }

                    handle.Node = target;
                    handle.Validated = true;
                    return handle.Node;
                }

                target = null;
            }

            try
            {
                // check if the node id has been parsed.
                AeParsedNodeId parsedNodeId = handle.ParsedNodeId as AeParsedNodeId;

                if (parsedNodeId == null)
                {
                    return null;
                }

                ComAeClient client = m_system.SelectClient(context, false);

                switch (parsedNodeId.RootType)
                {
                    case AeModelUtils.AeSimpleEventType:
                    case AeModelUtils.AeTrackingEventType:
                    case AeModelUtils.AeConditionEventType:
                    {
                        if (m_typeCache == null)
                        {
                            return null;
                        }

                        BaseObjectTypeState eventTypeNode = null;
                        NodeId rootId = AeParsedNodeId.Construct(parsedNodeId.RootType, parsedNodeId.CategoryId, parsedNodeId.ConditionName, parsedNodeId.NamespaceIndex);
                        
                        if (!m_typeCache.EventTypeNodes.TryGetValue(rootId, out eventTypeNode))
                        {
                            return null;
                        }

                        target = eventTypeNode;
                        break;
                    }

                    case AeModelUtils.AeArea:
                    {
                        ComAeBrowserClient browser = new ComAeBrowserClient(client, null);
                        target = browser.FindArea(context, parsedNodeId.RootId, NamespaceIndex);
                        browser.Dispose();

                        handle.Validated = true;
                        handle.Node = target;
                        return handle.Node;
                    }

                    case AeModelUtils.AeSource:
                    {
                        ComAeBrowserClient browser = new ComAeBrowserClient(client, null);
                        target = browser.FindSource(context, parsedNodeId.RootId, parsedNodeId.ComponentPath, NamespaceIndex);
                        browser.Dispose();

                        handle.Validated = true;
                        handle.Node = target;
                        return handle.Node;
                    }

                    case AeModelUtils.AeCondition:
                    {
                        target = new AeConditionState(context, handle, m_templateAlarm.Acknowledge);
                        break;
                    }
                }

                // node does not exist.
                if (target == null)
                {
                    return null;
                }

                if (!String.IsNullOrEmpty(parsedNodeId.ComponentPath))
                {
                    // validate component.
                    NodeState component = target.FindChildBySymbolicName(context, parsedNodeId.ComponentPath);

                    // component does not exist.
                    if (component == null)
                    {
                        return null;
                    }

                    target = component;
                }

                // found a valid component.
                handle.Validated = true;
                handle.Node = target;
                return handle.Node;
            }
            finally
            {
                // store the node in the cache to optimize subsequent lookups.
                if (cache != null)
                {
                    cache.Add(handle.NodeId, target);
                }
            }
        }