To assign numeric NodeId when I instantiate Custom Object Type

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

Moderator: uasdknet

Post Reply
junhoyoun
Full Member
Full Member
Posts: 6
Joined: 21 Jul 2022, 01:58

To assign numeric NodeId when I instantiate Custom Object Type

Post 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...

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

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

Post 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.
Best regards
Unified Automation Support Team

junhoyoun
Full Member
Full Member
Posts: 6
Joined: 21 Jul 2022, 01:58

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

Post 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.

Post Reply