Skip to content

Commit

Permalink
Resolved Mantis #7927 - Some nodes missing from instance tree and con…
Browse files Browse the repository at this point in the history
…verter crashes on Method nodes.
  • Loading branch information
JimLuth committed Apr 8, 2022
1 parent 47c3fc4 commit e9e920f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 16 additions & 4 deletions NodeSetToAML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class NodeSetToAML
private readonly NodeId HasModellingRuleNodeId = new NodeId(37, 0);
private readonly NodeId BaseInterfaceNodeId = new NodeId(17602, 0);
private readonly NodeId RootNodeId = new NodeId(84, 0);
private readonly NodeId HierarchicalNodeId = new NodeId(33, 0);
private readonly NodeId OrganizesNodeId = new NodeId(35, 0);
private readonly NodeId TypesFolderNodeId = new NodeId(86, 0);
private readonly System.Xml.Linq.XNamespace defaultNS = "http://www.dke.de/CAEX";
Expand Down Expand Up @@ -710,6 +711,7 @@ SystemUnitFamilyType FindOrAddSUC(ref SystemUnitClassLibType scl, ref RoleClassL
string basepath = BuildLibraryReference(SUCPrefix, m_modelManager.FindModelUri(refBaseNode.DecodedNodeId), refBaseNode.DecodedBrowseName.Name);
SystemUnitFamilyType baseSUC = scl.CAEXDocument.FindByPath(basepath) as SystemUnitFamilyType;
if (baseSUC == null)

FindOrAddSUC(ref scl, ref rcl, BaseNodeId);

}
Expand Down Expand Up @@ -1219,9 +1221,20 @@ InternalElementType RecursiveAddModifyInstance<T>(ref T parent, UANode toAdd) wh
var ie = parent.InternalElement[toAdd.DecodedBrowseName.Name];
if (ie == null)
{
SystemUnitFamilyType suc;

var TypeDefNodeId = m_modelManager.FindFirstTarget(toAdd.DecodedNodeId, HasTypeDefinitionNodeId, true);
var path = BaseRefFromNodeId(TypeDefNodeId, SUCPrefix);
SystemUnitFamilyType suc = m_cAEXDocument.FindByPath(path) as SystemUnitFamilyType;
suc = m_cAEXDocument.FindByPath(path) as SystemUnitFamilyType;

if (suc == null && toAdd.NodeClass == NodeClass.Method)
{
suc = m_cAEXDocument.FindByPath( BuildLibraryReference( SUCPrefix, MetaModelName, MethodNodeClass)) as SystemUnitFamilyType;
Debug.Assert(suc != null);
AddBaseNodeClassAttributes(suc, false);
AddModifyAttribute(suc.Attribute, "Executable", "Boolean", true);
AddModifyAttribute(suc.Attribute, "UserExecutable", "Boolean", true);
}
Debug.Assert(suc != null);

ie = suc.CreateClassInstance();
Expand Down Expand Up @@ -1250,16 +1263,15 @@ InternalElementType RecursiveAddModifyInstance<T>(ref T parent, UANode toAdd) wh
// follow forward hierarchical references to add the children

// now add the references and contained objects
var nodeId = toAdd.NodeId;
var nodeId = toAdd.DecodedNodeId;
var refList = m_modelManager.FindReferences(nodeId);
if (refList != null)
{
foreach (var reference in refList)
{
if (reference.IsForward == true)
{
if (m_modelManager.IsTypeOf(reference.ReferenceTypeId, OrganizesNodeId) == true
|| m_modelManager.IsTypeOf(reference.ReferenceTypeId, AggregatesNodeId) == true)
if (m_modelManager.IsTypeOf(reference.ReferenceTypeId, HierarchicalNodeId) == true )
{
string refURI = m_modelManager.FindModelUri(reference.ReferenceTypeId);
var ReferenceTypeNode = m_modelManager.FindNode<UANode>(reference.ReferenceTypeId);
Expand Down
6 changes: 3 additions & 3 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ static void ShowSyntax()
Console.WriteLine("NodesetFile Name of nodeset file in the CWD to be processed");
Console.WriteLine("AmlBaseFilename File name of the AutomationML file to be written (without the .amlx extension).");
Console.WriteLine(" The default name is the NodesetFile if this argument is missing.");
Console.WriteLine("\nWith no optional arguments, all nodeset files in CWD are processed.");
Console.WriteLine("All dependent nodeset files need to be present in the CWD, even if they are not processed. ");
Console.WriteLine("Copyright(c) 2021 OPC Foundation. All rights reserved.");
Console.WriteLine("\nWith no arguments, all nodeset files in CWD are processed.");
Console.WriteLine("NOTE: All dependent nodeset files need to be present in the CWD, even if they are not processed. ");
Console.WriteLine("Copyright(c) 2021-2022 OPC Foundation. All rights reserved.");
Console.WriteLine("+++++++++++++++++++++++++++++++++++++\n\n");
}

Expand Down

0 comments on commit e9e920f

Please sign in to comment.