Hello
I am trying to implement a client with which I can add/modify nodes on a UA server..
I am using the UA .NET SDK
I start with, I am trying to add a new variable Node to an object in an existing data model on a running UA server..
I call the AddNodes function with the following AddNodesItem:
AddNodesItem NewNode = new AddNodesItem()
{
ParentNodeId = parentNodeId,
ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.HasComponent,
TypeDefinition = UnifiedAutomation.UaBase.VariableTypeIds.AnalogItemType,
BrowseName = "Test Var",
NodeClass = UnifiedAutomation.UaBase.NodeClass.Variable
};
The AddNodes function returns a result with a StatusCode "BadTypeDefinitionInvalid"..
I tried changing the TypeDefinition property to other values like DataItemType or BaseDataVariableType, with no change in the result..
Note: parentNodeId is previously assigned to the NodeID of an object in the server datamodel. It is of type BaseObjectType and already references a few variable nodes.
Am I missing any crucial step before I can add Nodes to the server..??
Regards
Vijay
StatusCode "BadTypeDefinitionInvalid" after AddNodes call
Moderator: uasdknet
-
- Jr. Member
- Posts: 3
- Joined: 07 Jun 2014, 01:26
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re: StatusCode "BadTypeDefinitionInvalid" after AddNodes cal
Hello,
You need to specify the VariableAttributes within the AddNodesItem.
Here is some sample code to add a node to the DemoServer.
NOTE: You have to override
in your NodeManager to allow clients to add nodes with the AddNodes service.
Best regards
Support Team
You need to specify the VariableAttributes within the AddNodesItem.
Here is some sample code to add a node to the DemoServer.
Code: Select all
ushort namespaceIndex = (ushort) m_Session.NamespaceUris.IndexOf("http://www.unifiedautomation.com/DemoServer/");
VariableAttributes variableAttributes = new VariableAttributes()
{
AccessLevel = AccessLevels.CurrentReadOrWrite,
DataType = DataTypeIds.Double,
Historizing = false,
SpecifiedAttributes = Attributes.AccessLevel|Attributes.DataType|Attributes.Historizing
};
AddNodesItem addNodesItem = new AddNodesItem()
{
NodeClass = NodeClass.Variable,
ReferenceTypeId = ReferenceTypeIds.Organizes,
RequestedNewNodeId = new NodeId("TestVar", namespaceIndex),
TypeDefinition = VariableTypeIds.AnalogItemType,
BrowseName = new QualifiedName("TestVar", namespaceIndex),
ParentNodeId = new ExpandedNodeId("Demo", namespaceIndex),
NodeAttributes = new ExtensionObject(variableAttributes)
};
IList<AddNodesItem> nodesToAdd = new List<AddNodesItem>();
nodesToAdd.Add(addNodesItem);
List<AddNodesResult> results = m_Session.AddNodes(nodesToAdd, null);
Code: Select all
protected override bool HasAccessToAddNode(
RequestContext context,
BrowseHandle parent,
NodeId referenceTypeId,
NodeId typeDefinitionId)
Best regards
Support Team