Skip to content

Commit

Permalink
NetworkIdentifier is missing in generated Model Design for DI model #629
Browse files Browse the repository at this point in the history


- the model contains 0 nodes and no errors/warnings reported
  • Loading branch information
mpostol committed Mar 16, 2022
1 parent 045b62d commit 02b1837
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
10 changes: 6 additions & 4 deletions SemanticData/UANodeSetValidation/AddressSpaceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ IEnumerable<UAReferenceContext> IAddressSpaceBuildContext.GetReferences2Me(IUANo
/// </summary>
/// <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>
//TODO NetworkIdentifier is missing in generated Model Design for DI model #629
public IEnumerable<IUANodeBase> GetChildren(IUANodeBase node)
{
return m_References.Values.Where<UAReferenceContext>(x => Object.ReferenceEquals(x.SourceNode, node)).
Expand Down Expand Up @@ -312,7 +311,6 @@ private IUANodeContext TryGetUANodeContext(NodeId nodeId)
return _ret;
}

//TODO NetworkIdentifier is missing in generated Model Design for DI model #629
private void ValidateAndExportModel(int nameSpaceIndex)
{
IValidator validator = new Validator(this, m_TraceEvent);
Expand Down Expand Up @@ -340,8 +338,11 @@ where Object.ReferenceEquals(node.UANode, null)
InformationModelFactory.CreateNamespace(modelTableEntry.ModelUri.ToString(), _publicationDate, _version);
}
//NetworkIdentifier is missing in generated Model Design for DI model #629
int nodesCount = nodes.Count;
do
{
string doMessage = $"Do Validator.ValidateExportModel - now the model contains {nodesCount} nodes";
m_TraceEvent.TraceData(TraceEventType.Information, 1606585634, doMessage);
NodesCollection embededNodes = new NodesCollection();
foreach (IUANodeBase item in nodes)
{
Expand All @@ -356,16 +357,17 @@ where Object.ReferenceEquals(node.UANode, null)
}
}
nodes = embededNodes.ToList();
nodesCount += nodes.Count;
} while (nodes.Count > 0);
string message = null;
if (m_TraceEvent.Errors == 0)
{
message = $"Finishing Validator.ValidateExportModel - the model contains {nodes.Count} nodes and no errors/warnings reported";
message = $"Finishing Validator.ValidateExportModel - the model contains {nodesCount} nodes and no errors/warnings reported";
m_TraceEvent.TraceData(TraceEventType.Information, 711552454, message);
}
else
{
message = $"Finishing Validator.ValidateExportModel - the model contains {nodes.Count} nodes and {m_TraceEvent.Errors} errors reported.";
message = $"Finishing Validator.ValidateExportModel - the model contains {nodesCount} nodes and {m_TraceEvent.Errors} errors reported.";
m_TraceEvent.TraceData(TraceEventType.Warning, 226242104, message);
}
}
Expand Down
46 changes: 46 additions & 0 deletions SemanticData/UANodeSetValidation/NodesCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//__________________________________________________________________________________________________
//
// Copyright (C) 2022, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GitHub: https://github.com/mpostol/OPC-UA-OOI/discussions
//__________________________________________________________________________________________________

using System.Collections.Generic;
using System.Linq;

namespace UAOOI.SemanticData.UANodeSetValidation
{
/// <summary>
/// Class NodesCollection - manages a collection of nodes.
/// Implements the <see cref="Dictionary{String, IUANodeBase}" />
/// </summary>
/// <seealso cref="Dictionary{String, IUANodeBase}" />
internal class NodesCollection : Dictionary<string, IUANodeBase>
{
/// <summary>
/// Adds the {<paramref name="item"/> to the collection. Replace existing if required.
/// </summary>
/// <param name="item">The item to be added to the collection.</param>
/// <param name="replaceIfExist">if set to <c>true</c> replace the existing entity in the collection</param>
internal void AddOrReplace(IUANodeBase item, bool replaceIfExist)
{
string _key = item.UANode.BrowseNameQualifiedName.Name;
if (!this.ContainsKey(_key))
{
this.Add(_key, item); //add derived item
return;
}
if (replaceIfExist)
this[_key] = item; //replace by current item that overrides the base one
}

/// <summary>
/// Converts to list.
/// </summary>
/// <returns>returns an instance of <see cref="List{IUANodeBase}"/></returns>
internal List<IUANodeBase> ToList()
{
return this.Values.ToList<IUANodeBase>();
}
}
}
7 changes: 2 additions & 5 deletions SemanticData/UANodeSetValidation/UANodeContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,13 @@ void IUANodeBase.CalculateNodeReferences(INodeFactory nodeFactory, IValidator va
//validator..ValidateExportNode(_rc.TargetNode, nodeFactory, _rc);
break;

//TODO NetworkIdentifier is missing in generated Model Design for DI model #629
case NodeClassEnum.UAObject:
case NodeClassEnum.UAVariable:
validateExportNode2Model(_rfx.TargetNode);
//validator.ValidateExportNode(_rfx.TargetNode, nodeFactory, _rfx);
break;

//TODO NetworkIdentifier is missing in generated Model Design for DI model #629
case NodeClassEnum.UAVariable:
_TraceEvent(TraceMessage.DiagnosticTraceMessage($"Removed the graph of nodes at {_rfx.TargetNode} from the model"));
break;

case NodeClassEnum.UAView:
_TraceEvent(TraceMessage.DiagnosticTraceMessage($"Removed the graph of nodes at {_rfx.TargetNode} from the model"));
break;
Expand Down

0 comments on commit 02b1837

Please sign in to comment.