Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable call of methods that are part of the types or super types of the objectId on which the method is called #1698

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions Libraries/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs
Expand Up @@ -463,6 +463,49 @@ public NodeState FindNodeInAddressSpace(NodeId nodeId)
}
return null;
}

/// <summary>
/// Find a method in the type or any of the supertypes of a provided objectId on which the method is called
/// </summary>
/// <param name="context"></param>
/// <param name="objectId"></param>
/// <param name="methodId"></param>
/// <returns></returns>
public MethodState FindMethodInType(
ServerSystemContext context,
NodeState objectId,
NodeId methodId)
{
MethodState methodState = null;
NodeState typeNode = FindNodeInAddressSpace(((BaseInstanceState)objectId).TypeDefinitionId);
if (typeNode != null)
{
methodState = typeNode.FindMethod(context, methodId);

// Search super types
if (methodState == null)
{
NodeId superTypeNid = ((BaseTypeState)typeNode).SuperTypeId;

while ((superTypeNid != null) && (superTypeNid != ObjectTypeIds.BaseObjectType))
{
typeNode = FindNodeInAddressSpace(superTypeNid);
if (typeNode != null)
{
methodState = typeNode.FindMethod(context, methodId);
if (methodState != null)
{
break;
}
}
superTypeNid = ((BaseTypeState)typeNode).SuperTypeId;
}

}
}

return methodState;
}
#endregion

#region INodeManager Members
Expand Down Expand Up @@ -2955,6 +2998,12 @@ private void CheckIfSemanticsHaveChanged(ServerSystemContext systemContext, Prop
method = (MethodState)FindPredefinedNode(methodToCall.MethodId, typeof(MethodState));
}

// check the type for method to call
if (method == null)
{
method = FindMethodInType(systemContext, source, methodToCall.MethodId);
}

if (method == null)
{
errors[ii] = StatusCodes.BadMethodInvalid;
Expand Down