Skip to content

Commit

Permalink
Assign a default value to anu variable in namespace 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsuciu committed Jan 27, 2022
1 parent b638bb4 commit e512174
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 11 additions & 0 deletions Libraries/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,17 @@ protected virtual void AddPredefinedNode(ISystemContext context, NodeState node)
m_predefinedNodes = new NodeIdDictionary<NodeState>();
}

// assign a default value to any variable in namespace 0
if (node is BaseVariableState nodeStateVar)
{
if (nodeStateVar.NodeId.NamespaceIndex == 0 && nodeStateVar.Value == null)
{
nodeStateVar.Value = TypeInfo.GetDefaultValue(nodeStateVar.DataType,
nodeStateVar.ValueRank,
Server.TypeTree);
}
}

NodeState activeNode = AddBehaviourToPredefinedNode(context, node);
m_predefinedNodes[activeNode.NodeId] = activeNode;

Expand Down
9 changes: 0 additions & 9 deletions Stack/Opc.Ua.Core/Stack/State/NodeState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1827,15 +1827,6 @@ protected BaseInstanceState UpdateChild(ISystemContext context, XmlDecoder decod
// update any children.
child.UpdateChildren(context, decoder);

// Set the status code to Good for BaseVariableState nodes with namespace 0
if (child is BaseVariableState childVar)
{
if (childVar.NodeId.NamespaceIndex == 0)
{
childVar.StatusCode = StatusCodes.Good;
}
}

return child;
}

Expand Down

0 comments on commit e512174

Please sign in to comment.