Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create an instance node the 'right' way? #2783

Open
2 of 5 tasks
larws opened this issue Oct 2, 2024 · 0 comments
Open
2 of 5 tasks

How to create an instance node the 'right' way? #2783

larws opened this issue Oct 2, 2024 · 0 comments
Assignees

Comments

@larws
Copy link

larws commented Oct 2, 2024

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

I am currently trying to achieve the following. I am writing an OPC UA server application with UA-.NETStandard SDK and am loading my type nodes from a nodeset file. So far so good. Now during start up and runtime I would like to create instance nodes from my type nodes depending on the state of my server application.

I am using a node manager dervied from Opc.Ua.Server.CustomNodeManager2 and found the public method CreateNode(ServerSystemContext context, NodeId parentId, NodeId referenceTypeId, QualifiedName browseName, BaseInstanceState instance) which sounds like what I would like to achieve.

My code basically looks like this:

BaseObjectState newDevice = new BaseObjectState(null)
{
    NodeId = new NodeId(101010, index),
    BrowseName = new QualifiedName("Demo Device", index),
    DisplayName = new Opc.Ua.LocalizedText("Demo Device"),
    TypeDefinitionId = deviceTypeId,
};

// this raises an ArgumentNullException
CreateNode(SystemContext, parentId, ReferenceTypeIds.Organizes, newDevice.BrowseName, newDevice);

What I am observing is a ArgumentNullException within AddPredefinedNode() where the node is assigned to the dictionary. m_predefinedNodes[activeNode.NodeId] = activeNode; This is caused by the fact that the New() method of the node manager is the standard implementation, meaning I am not overriding that behavior.

What strikes me as odd is that this doesn't work out of the box. What am I missing here? Any help would be highly appreciated.

On another note, what is the differences between NodeState.Create and CustomNodeManager2.CreateNode are they meant to solve the same problem or do the target different scenarios?

Expected Behavior

Using an instance of CustomNodeManager2 should work out of the box without having to override more functionality than expected.

Steps To Reproduce

No response

Environment

- OS:
- Environment:
- Runtime:
- Nuget Version:
- Component:
- Server:
- Client:

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants