Stores the elements of a NodeId after it is parsed.
The NodeIds used by the samples are strings with an optional path appended. The RootType identifies the type of Root Node. The RootId is the unique identifier for the Root Node. The ComponentPath is constructed from the SymbolicNames of one or more children of the Root Node.
コード例 #1
0
        /// <summary>
        /// Creates the NodeId for the specified node.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="node">The node.</param>
        /// <returns>The new NodeId.</returns>
        /// <remarks>
        /// This method is called by the NodeState.Create() method which initializes a Node from
        /// the type model. During initialization a number of child nodes are created and need to
        /// have NodeIds assigned to them. This implementation constructs NodeIds by constructing
        /// strings. Other implementations could assign unique integers or Guids and save the new
        /// Node in a dictionary for later lookup.
        /// </remarks>
        public override NodeId New(ISystemContext context, NodeState node)
        {
            if (node is ServerStatusState)
            {
                return(node.NodeId);
            }

            return(ParsedNodeId.ConstructIdForComponent(node, NamespaceIndex));
        }
コード例 #2
0
        /// <summary>
        /// Constructs a NodeId from the BrowseName of an internal node.
        /// </summary>
        /// <param name="browseName">The browse name.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns>The node id.</returns>
        public static NodeId ConstructIdForInternalNode(QualifiedName browseName, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId = browseName.Name;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType = InternalNode;

            return parsedNodeId.Construct();
        }
コード例 #3
0
ファイル: AeModelUtils.cs プロジェクト: neobox3000/UA-.NET
        /// <summary>
        /// Constructs the id for an area.
        /// </summary>
        /// <param name="areaId">The area id.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns></returns>
        public static NodeId ConstructIdForArea(string areaId, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId         = areaId;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType       = AeArea;

            return(parsedNodeId.Construct());
        }
コード例 #4
0
ファイル: HdaModelUtils.cs プロジェクト: fr830/OPCUA.NET
        /// <summary>
        /// Constructs the node id for a branch.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        public static NodeId ConstructIdForHdaBranch(string itemId, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId         = itemId;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType       = HdaBranch;

            return(parsedNodeId.Construct());
        }
コード例 #5
0
ファイル: AeModelUtils.cs プロジェクト: neobox3000/UA-.NET
        /// <summary>
        /// Constructs the id for a source.
        /// </summary>
        /// <param name="areaId">The area id.</param>
        /// <param name="sourceName">Name of the source.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns></returns>
        public static NodeId ConstructIdForSource(string areaId, string sourceName, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootType       = AeSource;
            parsedNodeId.RootId         = areaId;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.ComponentPath  = sourceName;

            return(parsedNodeId.Construct());
        }
コード例 #6
0
ファイル: HdaModelUtils.cs プロジェクト: fr830/OPCUA.NET
        /// <summary>
        /// Constructs the node id for an item attribute.
        /// </summary>
        /// <param name="itemId">The item id.</param>
        /// <param name="attributeId">The attribute id.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns></returns>
        public static NodeId ConstructIdForHdaItemAttribute(string itemId, uint attributeId, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId         = itemId;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType       = HdaItemAttribute;
            parsedNodeId.ComponentPath  = attributeId.ToString();

            return(parsedNodeId.Construct());
        }
コード例 #7
0
ファイル: HdaModelUtils.cs プロジェクト: fr830/OPCUA.NET
        /// <summary>
        /// Constructs the node id for an aggregate function.
        /// </summary>
        /// <param name="aggregateId">The aggregate id.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns></returns>
        public static NodeId ConstructIdForHdaAggregate(uint aggregateId, ushort namespaceIndex)
        {
            // check for built in aggregates.
            NodeId nodeId = ComUtils.GetHdaAggregateId(aggregateId);

            if (nodeId != null)
            {
                return(nodeId);
            }

            // server specific aggregates.
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId         = aggregateId.ToString();
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType       = HdaAggregate;

            return(parsedNodeId.Construct());
        }
コード例 #8
0
 /// <summary>
 /// Constructs the node identifier for a component.
 /// </summary>
 /// <param name="component">The component.</param>
 /// <param name="namespaceIndex">Index of the namespace.</param>
 /// <returns>The node identifier for a component.</returns>
 public static NodeId ConstructIdForComponent(NodeState component, ushort namespaceIndex)
 {
     return ParsedNodeId.ConstructIdForComponent(component, namespaceIndex);
 }
コード例 #9
0
ファイル: ParsedNodeId.cs プロジェクト: OPCFoundation/UA-.NET
        /// <summary>
        /// Parses the specified node identifier.
        /// </summary>
        /// <param name="nodeId">The node identifier.</param>
        /// <returns>The parsed node identifier. Null if the identifier cannot be parsed.</returns>
        public static ParsedNodeId Parse(NodeId nodeId)
        {
            // can only parse non-null string node identifiers.
            if (NodeId.IsNull(nodeId))
            {
                return null;
            }

            string identifier = nodeId.Identifier as string;

            if (String.IsNullOrEmpty(identifier))
            {
                return null;
            }

            ParsedNodeId parsedNodeId = new ParsedNodeId();
            parsedNodeId.NamespaceIndex = nodeId.NamespaceIndex;
            
            int start = 0;

            // extract the type of identifier.
            parsedNodeId.RootType = (int)ExtractNumber(identifier, ref start);
            
            if (start >= identifier.Length || identifier[start] != ':')
            {
                return null;
            }

            // extract any component path.
            StringBuilder buffer = new StringBuilder();

            int index = start+1;
            int end = identifier.Length;

            bool escaped = false;

            while (index < end)
            {
                char ch = identifier[index++];

                // skip any escape character but keep the one after it.
                if (ch == '&')
                {
                    escaped = true;
                    continue;
                }

                if (!escaped && ch == '?')
                {
                    end = index;
                    break;
                }

                buffer.Append(ch);
                escaped = false;
            }

            // extract any component.
            parsedNodeId.RootId = buffer.ToString();
            parsedNodeId.ComponentPath = null;

            if (end < identifier.Length)
            {
                parsedNodeId.ComponentPath = identifier.Substring(end);
            }

            return parsedNodeId;
        }
コード例 #10
0
ファイル: ParsedNodeId.cs プロジェクト: neobox3000/UA-.NET
        /// <summary>
        /// Parses the specified node identifier.
        /// </summary>
        /// <param name="nodeId">The node identifier.</param>
        /// <returns>The parsed node identifier. Null if the identifier cannot be parsed.</returns>
        public static ParsedNodeId Parse(NodeId nodeId)
        {
            // can only parse non-null string node identifiers.
            if (NodeId.IsNull(nodeId))
            {
                return(null);
            }

            string identifier = nodeId.Identifier as string;

            if (String.IsNullOrEmpty(identifier))
            {
                return(null);
            }

            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.NamespaceIndex = nodeId.NamespaceIndex;

            int start = 0;

            // extract the type of identifier.
            parsedNodeId.RootType = (int)ExtractNumber(identifier, ref start);

            if (start >= identifier.Length || identifier[start] != ':')
            {
                return(null);
            }

            // extract any component path.
            StringBuilder buffer = new StringBuilder();

            int index = start + 1;
            int end   = identifier.Length;

            bool escaped = false;

            while (index < end)
            {
                char ch = identifier[index++];

                // skip any escape character but keep the one after it.
                if (ch == '&')
                {
                    escaped = true;
                    continue;
                }

                if (!escaped && ch == '?')
                {
                    end = index;
                    break;
                }

                buffer.Append(ch);
                escaped = false;
            }

            // extract any component.
            parsedNodeId.RootId        = buffer.ToString();
            parsedNodeId.ComponentPath = null;

            if (end < identifier.Length)
            {
                parsedNodeId.ComponentPath = identifier.Substring(end);
            }

            return(parsedNodeId);
        }