Skip to content

Commit

Permalink
Import simple NodeSet2 file is incomplete #510
Browse files Browse the repository at this point in the history
- used Object.ReferenceEquals to compare references
- refactoring definitions - unimportant changes
  • Loading branch information
mpostol committed Mar 18, 2021
1 parent e70cfba commit 6496b92
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,11 @@ public IUANodeBase GetBaseTypeNode(NodeClassEnum nodeClass)
return null;
}

/// <summary>
/// Gets the children nodes for the <paramref name="rootNode" />.
/// </summary>
/// <param name="rootNode">The root node of the requested children.</param>
/// <returns>Return an instance of <see cref="T:System.Collections.IEnumerable" /> capturing all children of the selected node.</returns>
public IEnumerable<IUANodeBase> GetChildren(IUANodeContext rootNode)
public IEnumerable<IUANodeBase> GetChildren(IUANodeBase node)
{
return m_References.Values.Where<UAReferenceContext>(x => x.SourceNode == rootNode).
Where<UAReferenceContext>(x => (x.ReferenceKind == ReferenceKindEnum.HasProperty || x.ReferenceKind == ReferenceKindEnum.HasComponent)).
Select<UAReferenceContext, IUANodeContext>(x => x.TargetNode);
return m_References.Values.Where<UAReferenceContext>(x => Object.ReferenceEquals(x.SourceNode, node)).
Where<UAReferenceContext>(x => (x.ReferenceKind == ReferenceKindEnum.HasProperty || x.ReferenceKind == ReferenceKindEnum.HasComponent)).
Select<UAReferenceContext, IUANodeContext>(x => x.TargetNode);
}

public ushort GetIndexOrAppend(string identifier)
Expand All @@ -450,7 +445,7 @@ public IUANodeContext GetOrCreateNodeContext(NodeId nodeId, Func<NodeId, IUANode
return m_NodesDictionary[nodeId.ToString()];
}

public IEnumerable<UAReferenceContext> GetReferences2Me(IUANodeContext node)
public IEnumerable<UAReferenceContext> GetReferences2Me(IUANodeBase node)
{
throw new NotImplementedException();
}
Expand Down
32 changes: 15 additions & 17 deletions SemanticData/UANodeSetValidation/AddressSpaceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,37 +187,35 @@ public string GetNamespace(ushort namespaceIndex)
}

/// <summary>
/// Gets my references from the main collection.
/// Gets my references.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>An instance of the <see cref="IEnumerable{UAReferenceContext}"/> containing references pointed out by index.</returns>
IEnumerable<UAReferenceContext> IAddressSpaceBuildContext.GetMyReferences(IUANodeBase index)
/// <param name="node">The source node</param>
/// <returns>Returns <see cref="IEnumerable{UAReferenceContex}"/> containing references attached to the <paramref name="node"/>.</returns>
IEnumerable<UAReferenceContext> IAddressSpaceBuildContext.GetMyReferences(IUANodeBase node)
{
//TODO Import simple NodeSet2 file is incomplete #510
return m_References.Values.Where<UAReferenceContext>(x => (x.SourceNode == index));
return m_References.Values.Where<UAReferenceContext>(x => (Object.ReferenceEquals(x.SourceNode, node)));
}

/// <summary>
/// Gets the references2 me.
/// </summary>
/// <param name="index">The index.</param>
/// <param name="node">The index.</param>
/// <returns>IEnumerable&lt;UAReferenceContext&gt;.</returns>
IEnumerable<UAReferenceContext> IAddressSpaceBuildContext.GetReferences2Me(IUANodeContext index)
IEnumerable<UAReferenceContext> IAddressSpaceBuildContext.GetReferences2Me(IUANodeBase node)
{
//TODO Import simple NodeSet2 file is incomplete #510 - consider consolidation with GetMyReferences
return m_References.Values.Where<UAReferenceContext>(x => x.TargetNode == index && x.ParentNode != index);
return m_References.Values.Where<UAReferenceContext>(x => Object.ReferenceEquals(x.TargetNode, node) && !Object.ReferenceEquals(x.ParentNode, node));
}

/// <summary>
/// Gets the children nodes for the <paramref name="rootNode" />.
/// Gets the children nodes (<see cref="ReferenceKindEnum.HasProperty" /> or <see cref="ReferenceKindEnum.HasComponent" />) for the <paramref name="node" />.
/// </summary>
/// <param name="rootNode">The root node of the requested children.</param>
/// <returns>Return an instance of <see cref="IEnumerable" /> capturing all children of the selected node.</returns>
public IEnumerable<IUANodeBase> GetChildren(IUANodeContext rootNode)
/// <param name="node">The root node of the requested children.</param>
/// <returns>Return an instance of <see cref="IEnumerable{IUANodeBase}" /> capturing all children of the selected node.</returns>
public IEnumerable<IUANodeBase> GetChildren(IUANodeBase node)
{
return m_References.Values.Where<UAReferenceContext>(x => x.SourceNode == rootNode).
Where<UAReferenceContext>(x => (x.ReferenceKind == ReferenceKindEnum.HasProperty || x.ReferenceKind == ReferenceKindEnum.HasComponent)).
Select<UAReferenceContext, IUANodeContext>(x => x.TargetNode);
return m_References.Values.Where<UAReferenceContext>(x => Object.ReferenceEquals(x.SourceNode, node)).
Where<UAReferenceContext>(x => (x.ReferenceKind == ReferenceKindEnum.HasProperty || x.ReferenceKind == ReferenceKindEnum.HasComponent)).
Select<UAReferenceContext, IUANodeContext>(x => x.TargetNode);
}

public Parameter ExportArgument(DataSerialization.Argument argument)
Expand Down
44 changes: 26 additions & 18 deletions SemanticData/UANodeSetValidation/IAddressSpaceBuildContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//___________________________________________________________________________________
//
// Copyright (C) 2019, Mariusz Postol LODZ POLAND.
// Copyright (C) 2021, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________
Expand All @@ -15,58 +15,66 @@
namespace UAOOI.SemanticData.UANodeSetValidation
{
/// <summary>
/// Interface IAddressSpaceBuildContext Address Space Context used during build operation
/// Interface IAddressSpaceBuildContext representing the Address Space Context used during build operation
/// </summary>
internal interface IAddressSpaceBuildContext
{

/// <summary>
/// Exports the browse name if it is not default value, otherwise null.
/// </summary>
/// <param name="id">The identifier.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns>XmlQualifiedName.</returns>
XmlQualifiedName ExportBrowseName(NodeId id, NodeId defaultValue);

/// <summary>
/// Exports the argument for a method.
/// </summary>
/// <param name="argument">The argument - it defines a Method input or output argument specification. It is for example used in the input and output argument Properties for Methods.</param>
/// <param name="dataType">Type of the data.</param>
Parameter ExportArgument(DataSerialization.Argument argument, XmlQualifiedName dataType);

/// <summary>
/// Gets the or create node context.
/// </summary>
/// <param name="nodeId">The node identifier.</param>
/// <param name="createUAModelContext">Delegated capturing functionality to create ua model context.</param>
/// <param name="createUAModelContext">Delegated capturing functionality to create UA model context.</param>
/// <returns>Returns an instance of <see cref="IUANodeContext"/>.</returns>
IUANodeContext GetOrCreateNodeContext(NodeId nodeId, Func<NodeId, IUANodeContext> createUAModelContext);

/// <summary>
/// Gets the namespace value as the <see cref="string"/>.
/// </summary>
/// <param name="namespaceIndex">Index of the namespace.</param>
/// <returns>The namespace of the index pointed out by the <paramref name="namespaceIndex"/></returns>
string GetNamespace(ushort namespaceIndex);

/// <summary>
/// Gets my references.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>IEnumerable&lt;UAReferenceContext&gt;.</returns>
IEnumerable<UAReferenceContext> GetMyReferences(IUANodeBase index);
/// <param name="node">The source node</param>
/// <returns>Returns <see cref="IEnumerable{UAReferenceContex}"/> containing references attached to the <paramref name="node"/>.</returns>
IEnumerable<UAReferenceContext> GetMyReferences(IUANodeBase node);

/// <summary>
/// Gets the references to me.
/// </summary>
/// <param name="node">The node.</param>
/// <returns>All references targeting the selected by the <paramref name="node"/> node</returns>
IEnumerable<UAReferenceContext> GetReferences2Me(IUANodeContext node);
/// <param name="node">The node in concern.</param>
/// <returns>All references targeting the <paramref name="node"/> node</returns>
IEnumerable<UAReferenceContext> GetReferences2Me(IUANodeBase node);

/// <summary>
/// Gets the children nodes for the <paramref name="rootNode" />.
/// Gets the children nodes (<see cref="ReferenceKindEnum.HasProperty"/> or <see cref="ReferenceKindEnum.HasComponent"/>) for the <paramref name="node" />.
/// </summary>
/// <param name="rootNode">The root node of the requested children.</param>
/// <returns>Return an instance of <see cref="IEnumerable"/> capturing all children of the selected node.</returns>
IEnumerable<IUANodeBase> GetChildren(IUANodeContext rootNode);
/// <param name="node">The root node of the requested children.</param>
/// <returns>Return an instance of <see cref="IEnumerable{IUANodeBase}"/> capturing all children of the selected node.</returns>
IEnumerable<IUANodeBase> GetChildren(IUANodeBase node);

Parameter ExportArgument(DataSerialization.Argument argument);
/// <summary>
/// Exports the argument.
/// </summary>
/// <param name="argument">The argument.</param>
/// <returns>An instance encapsulating <see cref="Parameter"/>.</returns>
Parameter ExportArgument(Argument argument);
}


}
}

0 comments on commit 6496b92

Please sign in to comment.