A object which maps a segment to a UA object.
Наследование: Opc.Ua.FolderState
Пример #1
0
 /// <summary>
 /// Creates a new browser object with a set of filters.
 /// </summary>
 /// <param name="context">The system context to use.</param>
 /// <param name="view">The view which may restrict the set of references/nodes found.</param>
 /// <param name="referenceType">The type of references being followed.</param>
 /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param>
 /// <param name="browseDirection">Which way the references are being followed.</param>
 /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param>
 /// <param name="additionalReferences">Any additional references that should be included.</param>
 /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param>
 /// <param name="source">The segment being accessed.</param>
 public SegmentBrowser(
     ISystemContext context,
     ViewDescription view,
     NodeId referenceType,
     bool includeSubtypes,
     BrowseDirection browseDirection,
     QualifiedName browseName,
     IEnumerable <IReference> additionalReferences,
     bool internalOnly,
     SegmentState source)
     :
     base(
         context,
         view,
         referenceType,
         includeSubtypes,
         browseDirection,
         browseName,
         additionalReferences,
         internalOnly)
 {
     m_source = source;
     m_stage  = Stage.Begin;
 }
Пример #2
0
 /// <summary>
 /// Creates a new browser object with a set of filters.
 /// </summary>
 /// <param name="context">The system context to use.</param>
 /// <param name="view">The view which may restrict the set of references/nodes found.</param>
 /// <param name="referenceType">The type of references being followed.</param>
 /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param>
 /// <param name="browseDirection">Which way the references are being followed.</param>
 /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param>
 /// <param name="additionalReferences">Any additional references that should be included.</param>
 /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param>
 /// <param name="source">The segment being accessed.</param>
 public SegmentBrowser(
     ISystemContext context,
     ViewDescription view,
     NodeId referenceType,
     bool includeSubtypes,
     BrowseDirection browseDirection,
     QualifiedName browseName,
     IEnumerable<IReference> additionalReferences,
     bool internalOnly,
     SegmentState source)
 :
     base(
         context,
         view,
         referenceType,
         includeSubtypes,
         browseDirection,
         browseName,
         additionalReferences,
         internalOnly)
 {
     m_source = source;
     m_stage = Stage.Begin;
 }
Пример #3
0
        /// <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.
                if (handle.ParsedNodeId == null)
                {
                    return(null);
                }

                NodeState root = null;

                // validate a segment.
                if (handle.ParsedNodeId.RootType == ModelUtils.Segment)
                {
                    UnderlyingSystemSegment segment = m_system.FindSegment(handle.ParsedNodeId.RootId);

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

                    NodeId rootId = ModelUtils.ConstructIdForSegment(segment.Id, NamespaceIndex);

                    // create a temporary object to use for the operation.
                    root = new SegmentState(context, rootId, segment);
                }

                // validate segment.
                else if (handle.ParsedNodeId.RootType == ModelUtils.Block)
                {
                    // validate the block.
                    UnderlyingSystemBlock block = m_system.FindBlock(handle.ParsedNodeId.RootId);

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

                    NodeId rootId = ModelUtils.ConstructIdForBlock(block.Id, NamespaceIndex);

                    // check for check for blocks that are being currently monitored.
                    BlockState node = null;

                    if (m_blocks.TryGetValue(rootId, out node))
                    {
                        root = node;
                    }

                    // create a temporary object to use for the operation.
                    else
                    {
                        root = new BlockState(this, rootId, block);
                    }
                }

                // unknown root type.
                else
                {
                    return(null);
                }

                // all done if no components to validate.
                if (String.IsNullOrEmpty(handle.ParsedNodeId.ComponentPath))
                {
                    handle.Validated = true;
                    handle.Node      = target = root;
                    return(handle.Node);
                }

                // validate component.
                NodeState component = root.FindChildBySymbolicName(context, handle.ParsedNodeId.ComponentPath);

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

                // found a valid component.
                handle.Validated = true;
                handle.Node      = target = component;
                return(handle.Node);
            }
            finally
            {
                // store the node in the cache to optimize subsequent lookups.
                if (cache != null)
                {
                    cache.Add(handle.NodeId, target);
                }
            }
        }
        /// <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.
                if (handle.ParsedNodeId == null)
                {
                    return null;
                }

                NodeState root = null;

                // validate a segment.
                if (handle.ParsedNodeId.RootType == ModelUtils.Segment)
                {
                    UnderlyingSystemSegment segment = m_system.FindSegment(handle.ParsedNodeId.RootId);

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

                    NodeId rootId = ModelUtils.ConstructIdForSegment(segment.Id, NamespaceIndex);

                    // create a temporary object to use for the operation.
                    root = new SegmentState(context, rootId, segment);
                }

                // validate segment.
                else if (handle.ParsedNodeId.RootType == ModelUtils.Block)
                {
                    // validate the block.
                    UnderlyingSystemBlock block = m_system.FindBlock(handle.ParsedNodeId.RootId);

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

                    NodeId rootId = ModelUtils.ConstructIdForBlock(block.Id, NamespaceIndex);

                    // check for check for blocks that are being currently monitored.
                    BlockState node = null;

                    if (m_blocks.TryGetValue(rootId, out node))
                    {
                        root = node;
                    }

                    // create a temporary object to use for the operation.
                    else
                    {
                        root = new BlockState(this, rootId, block);
                    }
                }

                // unknown root type.
                else
                {
                    return null;
                }

                // all done if no components to validate.
                if (String.IsNullOrEmpty(handle.ParsedNodeId.ComponentPath))
                {
                    handle.Validated = true;
                    handle.Node = target = root;
                    return handle.Node;
                }

                // validate component.
                NodeState component = root.FindChildBySymbolicName(context, handle.ParsedNodeId.ComponentPath);

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

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