Construct() public method

Constructs a node identifier.
public Construct ( ) : Opc.Ua.NodeId
return Opc.Ua.NodeId
Exemplo n.º 1
0
        /// <summary>
        /// Constructs a node identifier for a segment.
        /// </summary>
        /// <param name="segmentPath">The segment path.</param>
        /// <param name="namespaceIndex">Index of the namespace that qualifies the identifier.</param>
        /// <returns>The new node identifier.</returns>
        public static NodeId ConstructIdForSegment(string segmentPath, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId = segmentPath;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType = 0;

            return parsedNodeId.Construct();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructs a NodeId for a block.
        /// </summary>
        /// <param name="blockId">The block id.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        /// <returns>The new NodeId.</returns>
        public static NodeId ConstructIdForBlock(string blockId, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId = blockId;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType = 1;

            return parsedNodeId.Construct();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructs a node identifier for a folder object.
        /// </summary>
        public static NodeId ConstructId(string filePath, ushort namespaceIndex)
        {
            ParsedNodeId parsedNodeId = new ParsedNodeId();

            parsedNodeId.RootId = filePath;
            parsedNodeId.NamespaceIndex = namespaceIndex;
            parsedNodeId.RootType = NodeTypes.Folder;

            return parsedNodeId.Construct();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructs a node identifier from the component pieces.
        /// </summary>
        public static NodeId Construct(int rootType, string rootId, ushort namespaceIndex, params string[] componentNames)
        {
            ParsedNodeId pnd = new ParsedNodeId();

            pnd.RootType = rootType;
            pnd.RootId = rootId;
            pnd.NamespaceIndex = namespaceIndex;

            if (componentNames != null)
            {
                StringBuilder path = new StringBuilder();

                for (int ii = 0; ii < componentNames.Length; ii++)
                {
                    if (path.Length > 0)
                    {
                        path.Append('/');
                    }

                    path.Append(componentNames[ii]);
                }

                pnd.ComponentPath = path.ToString();
            }

            return pnd.Construct(null);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Does any initialization required before the address space can be used.
        /// </summary>
        /// <remarks>
        /// The externalReferences is an out parameter that allows the node manager to link to nodes
        /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and
        /// should have a reference to the root folder node(s) exposed by this node manager.  
        /// </remarks>
        public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> externalReferences)
        {
            lock (Lock)
            {
                base.CreateAddressSpace(externalReferences);

                NodeState root = FindPredefinedNode(new NodeId(Quickstarts.Views.Objects.Plant, NamespaceIndex), typeof(NodeState));

                Quickstarts.Views.BoilerState boiler1 = new Quickstarts.Views.BoilerState(null);
                ParsedNodeId pnd1 = new ParsedNodeId() { NamespaceIndex = NamespaceIndex, RootId = "Boiler #1" };

                boiler1.Create(
                    SystemContext,
                    pnd1.Construct(),
                    new QualifiedName("Boiler #1", NamespaceIndex),
                    null,
                    true);

                boiler1.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, true, root.NodeId);
                root.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, false, boiler1.NodeId);

                AddPredefinedNode(SystemContext, boiler1);

                Quickstarts.Views.BoilerState boiler2 = new Quickstarts.Views.BoilerState(null);
                ParsedNodeId pnd2 = new ParsedNodeId() { NamespaceIndex = NamespaceIndex, RootId = "Boiler #2" };

                boiler2.Create(
                    SystemContext,
                    pnd2.Construct(),
                    new QualifiedName("Boiler #2", NamespaceIndex),
                    null,
                    true);

                boiler2.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, true, root.NodeId);
                root.AddReference(Opc.Ua.ReferenceTypeIds.Organizes, false, boiler2.NodeId);

                AddPredefinedNode(SystemContext, boiler2);
            } 
        }
Exemplo n.º 6
0
        /// <summary>
        /// Used to receive notifications when a node is browsed.
        /// </summary>
        public void OnPopulateBrowser(
            ISystemContext context,
            NodeState node,
            NodeBrowser browser)
        {
            ParsedNodeId nodeId = ParsedNodeId.Parse(node.NodeId);
            DirectoryInfo info = new DirectoryInfo(nodeId.RootId);

            if (!info.Exists)
            {
                return;
            }

            if (browser.IsRequired(ReferenceTypeIds.Organizes, false))
            {
                foreach (DirectoryInfo child in info.GetDirectories())
                {
                    ParsedNodeId childId = new ParsedNodeId();
                    childId.RootType = 0;
                    childId.RootId = child.FullName;
                    childId.NamespaceIndex = NamespaceIndex;

                    browser.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, childId.Construct()));
                }
            }

            if (browser.IsRequired(ReferenceTypeIds.Organizes, true))
            {
                ParsedNodeId parentId = new ParsedNodeId();
                parentId.RootType = 0;
                parentId.RootId = info.Parent.FullName;
                parentId.NamespaceIndex = NamespaceIndex;

                browser.Add(new NodeStateReference(ReferenceTypeIds.Organizes, true, parentId.Construct()));
            }
        }
Exemplo n.º 7
0
        private BaseObjectState CreateFolderNode(string path)
        {
            DirectoryInfo info = new DirectoryInfo(path);

            if (!info.Exists)
            {
                return null;
            }

            ParsedNodeId nodeId = new ParsedNodeId();
            nodeId.RootType = 0;
            nodeId.RootId = path;
            nodeId.NamespaceIndex = NamespaceIndex;

            FolderState node = new FolderState(null);

            node.NodeId = nodeId.Construct();
            node.BrowseName = new QualifiedName(info.Name, NamespaceIndex);
            node.DisplayName = node.BrowseName.Name;
            node.TypeDefinitionId = ObjectTypeIds.FolderType;

            node.OnPopulateBrowser = OnPopulateBrowser;

            return node;
        }