Skip to content

Commit

Permalink
Handle status code Uncertain according to the specification (#2898)
Browse files Browse the repository at this point in the history
* #2896: Write output arguments for good and uncertain status code

When a method state's call method is invoked the output arguments should be written in case the status code is good or uncertain. This behavior would be conform with the current specification.

* #2896: The service result corresponds the method call result

The result of the Call method in the CustomNodeManager2 class represents the status of the CallMethodResult. It does not correspond to the ServiceResult of the CallResponse, thus returning Good as a general response is incorrect behavior.
  • Loading branch information
larws authored and mregen committed Jan 8, 2025
1 parent 444b2c8 commit df881be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Libraries/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2977,16 +2977,16 @@ protected virtual ServiceResult Call(
List<ServiceResult> argumentErrors = new List<ServiceResult>();
VariantCollection outputArguments = new VariantCollection();

ServiceResult error = method.Call(
ServiceResult callResult = method.Call(
context,
methodToCall.ObjectId,
methodToCall.InputArguments,
argumentErrors,
outputArguments);

if (ServiceResult.IsBad(error))
if (ServiceResult.IsBad(callResult))
{
return error;
return callResult;
}

// check for argument errors.
Expand Down Expand Up @@ -3041,7 +3041,8 @@ protected virtual ServiceResult Call(
// return output arguments.
result.OutputArguments = outputArguments;

return ServiceResult.Good;
// return the actual result of the original call
return callResult;
}


Expand Down
2 changes: 1 addition & 1 deletion Stack/Opc.Ua.Core/Stack/State/MethodState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public virtual ServiceResult Call(
}

// copy out arguments.
if (ServiceResult.IsGood(result))
if (ServiceResult.IsGoodOrUncertain(result))
{
for (int ii = 0; ii < outputs.Count; ii++)
{
Expand Down
13 changes: 13 additions & 0 deletions Stack/Opc.Ua.Core/Types/Utils/ServiceResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,19 @@ public static bool IsUncertain(ServiceResult status)
return false;
}

/// <summary>
/// Returns true if the status code is good or uncertain.
/// </summary>
public static bool IsGoodOrUncertain(ServiceResult status)
{
if (status != null)
{
return StatusCode.IsGood(status.m_code) || StatusCode.IsUncertain(status.m_code);
}

return false;
}

/// <summary>
/// Returns true if the status is good or uncertain.
/// </summary>
Expand Down

0 comments on commit df881be

Please sign in to comment.