Skip to content

Commit 9d8fa96

Browse files
139 invalid parent node (#149)
* Found more effective way to get parent node id using reverse references. * Testing for issue 139
1 parent 78fab3c commit 9d8fa96

File tree

2 files changed

+15
-41
lines changed

2 files changed

+15
-41
lines changed

NodeSetToAML.cs

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,19 +2438,6 @@ private string GetExistingCreatedPathName(UANode node)
24382438
return createdPathName;
24392439
}
24402440

2441-
private string EqualizeParentNodeId(UAInstance node, string parentNodeId)
2442-
{
2443-
string[] parentSplit = parentNodeId.Split(";");
2444-
if ( parentSplit.Length > 1)
2445-
{
2446-
ModelInfo modelInfo = m_modelManager.FindModel(node.DecodedNodeId);
2447-
parentNodeId = String.Format("ns={0};{1}",
2448-
modelInfo.NamespaceIndex, parentSplit[1]);
2449-
}
2450-
2451-
return parentNodeId;
2452-
}
2453-
24542441
private string GetCreatedPathName(UANode node)
24552442
{
24562443
string pathName = GetExistingCreatedPathName(node);
@@ -2460,40 +2447,21 @@ private string GetCreatedPathName(UANode node)
24602447
UAInstance uaInstance = node as UAInstance;
24612448
if (uaInstance != null )
24622449
{
2463-
string parentNodeIdString = string.Empty;
2464-
2465-
if ( uaInstance.ParentNodeId != null )
2466-
{
2467-
parentNodeIdString = uaInstance.ParentNodeId;
2468-
}
2469-
else
2450+
var refList = m_modelManager.FindReferences( node.DecodedNodeId );
2451+
foreach( var reference in refList )
24702452
{
2471-
var refList = m_modelManager.FindReferences( node.DecodedNodeId );
2472-
int reversePropertyCount = 0;
2473-
foreach( var reference in refList )
2453+
if( reference.IsForward == false &&
2454+
( reference.ReferenceTypeId.Equals(HasPropertyNodeId) ||
2455+
reference.ReferenceTypeId.Equals( Opc.Ua.ReferenceTypeIds.HasComponent ) ) )
24742456
{
2475-
if( reference.IsForward == false &&
2476-
( reference.ReferenceTypeId.Equals(HasPropertyNodeId) ||
2477-
reference.ReferenceTypeId.Equals( Opc.Ua.ReferenceTypeIds.HasComponent ) ) )
2457+
UANode parentNodeId = m_modelManager.FindNode<UANode>( reference.TargetId );
2458+
if ( parentNodeId != null )
24782459
{
2479-
UANode parentNodeId = m_modelManager.FindNode<UANode>( reference.TargetId );
2480-
if ( parentNodeId != null )
2481-
{
2482-
parentNodeIdString = parentNodeId.NodeId;
2483-
break;
2484-
}
2485-
2486-
reversePropertyCount++;
2460+
pathName = GetCreatedPathName(parentNodeId);
2461+
break;
24872462
}
24882463
}
24892464
}
2490-
2491-
if ( parentNodeIdString.Length > 0)
2492-
{
2493-
string parentNodeId = EqualizeParentNodeId(uaInstance, parentNodeIdString);
2494-
UANode parentNode = FindNode<NodeSet.UANode>(new NodeId(parentNodeId));
2495-
pathName = GetCreatedPathName(parentNode);
2496-
}
24972465
}
24982466

24992467
if (pathName.Length > 0)

SystemTest/TestNonHierarchical.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public class TestNonHierarchical
6767
TestHelper.Uris.AmlFxTest, 5008u,
6868
DisplayName = "Instance Hosts")]
6969

70+
[DataRow("", TestHelper.Uris.Root, 14156u,
71+
"HasCondition",
72+
TestHelper.Uris.Root, Opc.Ua.ObjectTypes.CertificateExpirationAlarmType,
73+
DisplayName = "DefaultApplication Group to Audit Event Issue 139")]
74+
75+
7076
public void TestReference(string prefix, TestHelper.Uris testUri, uint testNodeId, string referenceName,
7177
TestHelper.Uris targetUri, uint targetNodeId)
7278
{

0 commit comments

Comments
 (0)