Page 1 of 1

To assign numeric NodeId when I instantiate Custom Object Type

Posted: 19 May 2023, 08:44
by junhoyoun
Dear Team,

When I write codes to create my custom object type and make multiple instances from that type,
I would write as follows:

var settings = new CreateObjectSettings()
{
ParentNodeId = parentFolder.NodeId,
ReferenceTypeId = ReferenceTypeIds.Organizes,
RequestedNodeId = new NodeId($"OBJ_{i:D3}", InstanceNamespaceIndex),
BrowseName = new QualifiedName($"OBJ_{i:D3}", InstanceNamespaceIndex),
TypeDefinitionId = new NodeId(MY_CUSTOM_OBJECT_TYPE_ID, TypeNamespaceIndex)
};
CreateObject(_serverNodeManager.Server.DefaultRequestContext, settings);

When you do this, all the node ids of the nodes under the objects instantiated from "MY_CUSTOM_OBJECT_TYPE_ID" are "string" type.
The string node id which actually is the path of the node (like BrowseName).

I want to assign numeric node id (for better performance)...
Is there any way for me to jump in the process creating the nodes and give numeric node id for each child nodes when they are instantiated?

P.S.
When I worked with UA Modeler, I could assign numeric node ids for all the custome object types and I could see all the instantiated objects has nodes with numeric node ids...

Re: To assign numeric NodeId when I instantiate Custom Object Type

Posted: 19 May 2023, 12:48
by Support Team
Hello,

you are right. Numeric NodeIds are more performant than String NodeIds.

By overriding the method BaseNodeManager.CreateNodeId (https://documentation.unified-automation.com/uasdknet/3.3.0/html/classUnifiedAutomation_1_1UaServer_1_1BaseNodeManager.html#abf3f2c6b58e79017ae81bf1edd90f40c) you can create the NodeIds in your application code.

Re: To assign numeric NodeId when I instantiate Custom Object Type

Posted: 22 May 2023, 06:49
by junhoyoun
Thank you support team!

I can override BaseNodeManager.CreateNodeId to set numerical node id.

One thing to remember as a small tip would be: (for later visitors)
You shouldn't set RequestedNodeId value in CreateObjectSettings, if you set, BaseNodeManager.CreateNodeId overriden never called.