You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
BaseObjectStatenewDevice=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.
sorry for the delay in responding. From what you have written it is not clear to me how you defined the types for which you want to create the instances. It would be easier if you could post a more complete description of what you have done.
If you want to use you own types you have to provide classes which can represent these types at runtime - do you have these in place?
Typically this is done with the help of the model compiler which generates the types, which then have to be loaded into the server. This is done, for example, in the TestData subfolder in the Quickstarts.Servers project which is used in the Console Reference Server. Unfortunately in that example the instances are also defined through the model, so you cannot just proceed as in that case.
(I have to admit I don't know what the CreateNode method in the CustomNodeManager2 is supposed to do - it is used only in three places, as it seems).
Can you please provide some more details on what you have in place already?
Hi @ThomasNehring,
I was trying to avoid using the generated code from the model compiler and do the following instead.
Import all the type nodes required for my server through a Nodeset, using UANodeSet.Import and then adding the resulting NodeStateCollection to the address space.
Create instances of my loaded types by calling CreateNode and thus filling my address space with the needed instances.
From what I have found out so far the currently best supported way is the usage of the model compiler. In my opinion is unfortunate since the generated code is not compatible with the current versions of .net.
Am I wrong and there is another way to achieve what I am trying to do without using the model compiler?
Type of issue
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 methodCreateNode(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:
What I am observing is a
ArgumentNullException
withinAddPredefinedNode()
where the node is assigned to the dictionary.m_predefinedNodes[activeNode.NodeId] = activeNode;
This is caused by the fact that theNew()
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
andCustomNodeManager2.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
Anything else?
No response
The text was updated successfully, but these errors were encountered: