From cd9577b29c222afb8c349694129ec1305a13b1aa Mon Sep 17 00:00:00 2001 From: Erich Barnstedt Date: Thu, 16 Jan 2025 14:26:16 +0100 Subject: [PATCH] Bug fix to remove duplicates. --- I4AASNodeManager.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/I4AASNodeManager.cs b/I4AASNodeManager.cs index 2ee83d2..489e71f 100644 --- a/I4AASNodeManager.cs +++ b/I4AASNodeManager.cs @@ -82,7 +82,24 @@ public void SaveNodestateCollectionAsNodeSet2(string filePath, NodeStateCollecti foreach (NodeState node in nodesToExport) { - nodeSet.Export(SystemContext, node); + // make sure we don't add duplicates + bool alreadyExists = false; + if (nodeSet.Items != null) + { + foreach (UANode existingNode in nodeSet.Items) + { + if (existingNode.NodeId == node.NodeId.ToString().Replace("ns=2", "ns=1")) + { + alreadyExists = true; + break; + } + } + } + + if (!alreadyExists) + { + nodeSet.Export(SystemContext, node); + } } nodeSet.Write(stream.BaseStream);