Skip to content

Commit

Permalink
Merge pull request #540 from mpostol/SemanticData-6.1.3
Browse files Browse the repository at this point in the history
Semantic data 6.1.3
  • Loading branch information
mpostol authored Feb 23, 2021
2 parents 9e99d84 + 8f64a31 commit 74fa3c4
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void QualifiedNameTestMethod1()
[TestMethod]
public void QualifiedNameParseTestMethod3()
{
//TODO Enhance/Improve BrowseName parser #538
QualifiedName _qn = QualifiedName.Parse("Name"); //Cannot find information that the NamespaceIndex is optional
Assert.IsNotNull(_qn);
Assert.AreEqual<int>(_qn.NamespaceIndex, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class NodeFactoryBase : NodesContainer, INodeFactory
/// <value>The BrowseName of the node.</value>
public string BrowseName
{
set { }
set; get;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void ADITest()
Assert.AreEqual<string>(BuildError.ModelsCannotBeNull.Identifier, traceContext.TraceList[0].BuildError.Identifier);
traceContext.Clear();
addressSpace.ValidateAndExportModel(model);
//TODO ADI model from Embedded example import fails #509
//TODO Enhance/Improve BrowseName parser #538
Assert.AreEqual<int>(0, traceContext.TraceList.Where<TraceMessage>(x => x.BuildError.Focus == Focus.DataEncoding).Count<TraceMessage>());
Assert.AreEqual<int>(0, traceContext.TraceList.Where<TraceMessage>(x => x.BuildError.Focus == Focus.DataType).Count<TraceMessage>());
Assert.AreEqual<int>(0, traceContext.TraceList.Where<TraceMessage>(x => x.BuildError.Focus == Focus.Naming).Count<TraceMessage>());
Expand Down Expand Up @@ -68,23 +68,29 @@ public void eoursel510Test()
addressSpace.ValidateAndExportModel(model);
Assert.AreEqual<int>(5, traceContext.TraceList.Count);
IEnumerable<NodeFactoryBase> nodes = testingModelFixture.Export();
Assert.AreEqual(21, nodes.Count< NodeFactoryBase>());
Assert.AreEqual(21, nodes.Count<NodeFactoryBase>());
Dictionary<string, NodeFactoryBase> nodesDictionary = nodes.ToDictionary<NodeFactoryBase, string>(x => x.SymbolicName.Name);
AddressSpaceContext asContext = addressSpace as AddressSpaceContext;
//TODO Add a warning that the AS contains nodes orphaned and inaccessible for browsing starting from the Root node #529
IEnumerable<IUANodeContext> allNodes = null;
asContext.UTValidateAndExportModel(1, x => allNodes = x);
Assert.IsNotNull(allNodes);
List<IUANodeContext> orphanedNodes = new List<IUANodeContext>();
List<IUANodeContext> processedNodes = new List<IUANodeContext>();
foreach (IUANodeContext item in allNodes)
{
if (!nodesDictionary.ContainsKey(item.BrowseName.Name))
{
orphanedNodes.Add(item);
Debug.WriteLine($"The following node has been removed from the model: {item.ToString()}");
}
else
processedNodes.Add(item);
}
Debug.WriteLine($"After removing inherited and instance declaration nodes the recovered information model contains {nodes.Count<NodeFactoryBase>()}");
Debug.WriteLine($"The recovered information model contains {nodesDictionary.Count} nodes");
Debug.WriteLine($"The source information model contains {allNodes.Count<IUANodeContext>()} nodes");
Debug.WriteLine($"Number of nodes not considered for export {orphanedNodes.Count}");
Debug.WriteLine($"Number of processed nodes {processedNodes.Count}");
}
}

Expand Down
10 changes: 8 additions & 2 deletions SemanticData/UANodeSetValidation/AddressSpaceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,14 @@ private Uri ImportNodeSet(UANodeSet model)
IUAModelContext _modelContext = model.ParseUAModelContext(m_NamespaceTable, m_TraceEvent.TraceEvent);
m_TraceEvent.TraceEvent(TraceMessage.DiagnosticTraceMessage($"Entering AddressSpaceContext.ImportNodeSet - starting import {_modelContext}."));
m_TraceEvent.TraceEvent(TraceMessage.DiagnosticTraceMessage("AddressSpaceContext.ImportNodeSet - the context for the imported model is created and starting import nodes."));
foreach (UANode _nd in model.Items)
ImportUANode(_nd);
Dictionary<string, UANode> itemsDictionary = new Dictionary<string, UANode>();
foreach (UANode node in model.Items)
{
if (itemsDictionary.ContainsKey(node.NodeId.ToString()))
m_TraceEvent.TraceEvent(TraceMessage.BuildErrorTraceMessage(BuildError.NodeIdDuplicated, $"The {node.NodeId.ToString()} is already defined in the imported model and is removed from further processing."));
else
ImportUANode(node);
}
m_TraceEvent.TraceEvent(TraceMessage.DiagnosticTraceMessage($"Finishing AddressSpaceContext.ImportNodeSet - imported {model.Items.Length} nodes."));
return _modelContext.ModelUri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace UAOOI.SemanticData.UANodeSetValidation.DataSerialization
/// <i>1:MyName</i>
/// <br/></para>
/// </remarks>
//TODO Enhance/Improve BrowseName parser #538
public partial class QualifiedName : IFormattable, ICloneable, IComparable
{
#region Constructors
Expand Down
7 changes: 4 additions & 3 deletions SemanticData/UANodeSetValidation/UANodeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void Update(UANode node, Action<UAReferenceContext> addReference)
return;
}
UANode = node;
//TODO Enhance/Improve BrowseName parser #538
this.BrowseName = node.BrowseName.Parse(_TraceEvent);
if (QualifiedName.IsNull(this.BrowseName))
{
Expand Down Expand Up @@ -328,9 +329,9 @@ public bool Equals(IUANodeBase other)
{
if (Object.ReferenceEquals(other, null))
return false;
//TODO ADI model from Embedded example import fails #509
if (this.BrowseName != other.BrowseName) //1:TransitionNumber vs TransitionNumber; 1:StateNumber vs StateNumber
return false; // throw new ArgumentOutOfRangeException("The browse name of compared nodes musty be equal.");
//TODO Enhance/Improve BrowseName parser #538
if (this.BrowseName != other.BrowseName)
return false;
return
this.UANode.Equals(other.UANode);
}
Expand Down
1 change: 1 addition & 0 deletions SemanticData/UANodeSetValidation/XML/UANode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public virtual bool Equals(UANode other)
ParentEquals(other) &&
this.AccessRestrictions == other.AccessRestrictions &&
this.BrowseName.AreEqual(other.BrowseName) &&
//TODO Enhance/Improve BrowseName parser #538
this.Description.LocalizedTextArraysEqual(other.Description) &&
this.DisplayName.LocalizedTextArraysEqual(other.DisplayName) &&
this.Documentation.AreEqual(other.Documentation) &&
Expand Down
Loading

0 comments on commit 74fa3c4

Please sign in to comment.