Guid-ParentNodeId not implemented?

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
User avatar
h2k_toy
Sr. Member
Sr. Member
Posts: 14
Joined: 24 Sep 2020, 09:13

Guid-ParentNodeId not implemented?

Post by h2k_toy »

Hello,

the following code throws an exception at the commented line.

Code: Select all

            {
                ObjectNode aObjectNode1;
                ObjectNode aObjectNode2;

                var aNodeManager = this;
                var aServer = aNodeManager.Server;
                var aNamespaceIndex = aNodeManager.DefaultNamespaceIndex;
                var aRequestContext = aServer.DefaultRequestContext;
                var aTypeDefinitionId = UnifiedAutomation.UaBase.ObjectTypeIds.FolderType;
                {
                    var aParentNodeId = UnifiedAutomation.UaBase.ObjectIds.ObjectsFolder;
                    var aEigenschaftName = "Root";
                    var aBrowseName = new QualifiedName(aEigenschaftName, aNamespaceIndex);
                    var aCreateObjectSettings = new CreateObjectSettings()
                    {
                        ParentNodeId = aParentNodeId,
                        ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
                        TypeDefinitionId = aTypeDefinitionId,
                        BrowseName = aBrowseName,
                    };
                    var aObjectNode = aNodeManager.CreateObject(aRequestContext, aCreateObjectSettings);
                    aObjectNode1 = aObjectNode;
                }
                

                {
                    var aParentNodeId = aObjectNode1.NodeId;
                    var aEigenschaftName = "Root";
                    var aBrowseName = new QualifiedName(aEigenschaftName, aNamespaceIndex);
                    var aCreateObjectSettings = new CreateObjectSettings()
                    {
                        ParentNodeId = aParentNodeId,
                        ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
                        TypeDefinitionId = aTypeDefinitionId,
                        BrowseName = aBrowseName,
                    };
                    var aObjectNode = aNodeManager.CreateObject(aRequestContext, aCreateObjectSettings);
                    aObjectNode2 = aObjectNode; // throw exception "BadParentNodeIdInvalid"
                }
            }
The first call to createObject succeeds and generates a guid-Node id for the created object as expected.
But the second call to createObject fails with BadParentNodeIdInvalid.

I guess the framework can not handle node ids if it's a guid one? Am i right?

If this is true my next question would be: What node ids shall i use if the server's tree is built dynamically? I don't have a model that defines node ids.
Is the value range starting from 6000... ? for custom nodes or how shall i proceed? I have a unique number for the server's node of type int available. (For instance nodes, not for type nodes) May i just add 6000 to this number?

Or (idea before i leave here) can i just choose any int number if i register a new namespace?

Thanks!

User avatar
h2k_toy
Sr. Member
Sr. Member
Posts: 14
Joined: 24 Sep 2020, 09:13

Re: Guid-ParentNodeId not implemented?

Post by h2k_toy »

Ok it worked with a simple uint incremented each time i create a node.
I registered an own namespace for these numbers.
The Guid-NodeId seems not to work.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Guid-ParentNodeId not implemented?

Post by Support Team »

Hello,

It is a better approach to specify the RequestedNodeId in the CreateObjectSettings. In this case the NodeIds of the created nodes are the same after a server restart. We are specifying the NodeIds in all of our examples. If GUID NodeIds are used, the NodeIds change after every server restart.

GUID NodeIds are supported by the sdk. I added the code you have posted to the StartUp method of the DemoServer and it is working as expected.
Best regards
Unified Automation Support Team

Post Reply