diff --git a/Stack/Opc.Ua.Core/Schema/UANodeSetHelpers.cs b/Stack/Opc.Ua.Core/Schema/UANodeSetHelpers.cs index 33af85f8d..913e6ddbe 100644 --- a/Stack/Opc.Ua.Core/Schema/UANodeSetHelpers.cs +++ b/Stack/Opc.Ua.Core/Schema/UANodeSetHelpers.cs @@ -184,9 +184,9 @@ public void Export(ISystemContext context, NodeState node, bool outputRedundantN UAMethod value = new UAMethod(); value.Executable = o.Executable; - if (o.TypeDefinitionId != null && !o.TypeDefinitionId.IsNullNodeId && o.TypeDefinitionId != o.NodeId) + if (o.MethodDeclarationId != null && !o.MethodDeclarationId.IsNullNodeId && o.MethodDeclarationId != o.NodeId) { - value.MethodDeclarationId = Export(o.TypeDefinitionId, context.NamespaceUris); + value.MethodDeclarationId = Export(o.MethodDeclarationId, context.NamespaceUris); } if (o.Parent != null) @@ -530,7 +530,7 @@ private NodeState Import(ISystemContext context, UANode node) MethodState value = new MethodState(null); value.Executable = o.Executable; value.UserExecutable = o.Executable; - value.TypeDefinitionId = ImportNodeId(o.MethodDeclarationId, context.NamespaceUris, true); + value.MethodDeclarationId = ImportNodeId(o.MethodDeclarationId, context.NamespaceUris, true); importedNode = value; break; } diff --git a/Stack/Opc.Ua.Core/Stack/State/BaseInstanceState.cs b/Stack/Opc.Ua.Core/Stack/State/BaseInstanceState.cs index f774e5886..e6acfea16 100644 --- a/Stack/Opc.Ua.Core/Stack/State/BaseInstanceState.cs +++ b/Stack/Opc.Ua.Core/Stack/State/BaseInstanceState.cs @@ -529,7 +529,7 @@ protected override void Export(ISystemContext context, Node node) node.ReferenceTable.Add(referenceTypeId, true, this.Parent.NodeId); } - if (!NodeId.IsNull(this.TypeDefinitionId) && (NodeClass == NodeClass.Object || NodeClass == NodeClass.Variable)) + if (!NodeId.IsNull(m_typeDefinitionId) && m_typeDefinitionId != this.NodeId) { node.ReferenceTable.Add(ReferenceTypeIds.HasTypeDefinition, false, this.TypeDefinitionId); } @@ -556,7 +556,7 @@ public override void Save(ISystemContext context, XmlEncoder encoder) encoder.WriteNodeId("ReferenceTypeId", m_referenceTypeId); } - if (!NodeId.IsNull(m_typeDefinitionId) && (NodeClass == NodeClass.Object || NodeClass == NodeClass.Variable)) + if (!NodeId.IsNull(m_typeDefinitionId) && m_typeDefinitionId != this.NodeId) { encoder.WriteNodeId("TypeDefinitionId", m_typeDefinitionId); } @@ -588,7 +588,7 @@ public override AttributesToSave GetAttributesToSave(ISystemContext context) attributesToSave |= AttributesToSave.ReferenceTypeId; } - if (!NodeId.IsNull(m_typeDefinitionId) && (NodeClass == NodeClass.Object || NodeClass == NodeClass.Variable)) + if (!NodeId.IsNull(m_typeDefinitionId) && m_typeDefinitionId != this.NodeId) { attributesToSave |= AttributesToSave.TypeDefinitionId; } diff --git a/Stack/Opc.Ua.Core/Stack/State/MethodState.cs b/Stack/Opc.Ua.Core/Stack/State/MethodState.cs index 3755891c5..08c2713f5 100644 --- a/Stack/Opc.Ua.Core/Stack/State/MethodState.cs +++ b/Stack/Opc.Ua.Core/Stack/State/MethodState.cs @@ -255,6 +255,11 @@ public override AttributesToSave GetAttributesToSave(ISystemContext context) attributesToSave |= AttributesToSave.UserExecutable; } + if (!NodeId.IsNull(this.MethodDeclarationId) && MethodDeclarationId != NodeId) + { + attributesToSave |= AttributesToSave.TypeDefinitionId; + } + return attributesToSave; }