Skip to content

Commit

Permalink
Client fix for ConditionRefreshAsync always returns NodIdUnknown, add…
Browse files Browse the repository at this point in the history
… ConditionRefresh2Async support(OPCFoundation#2876)

Fixes OPCFoundation#2854
  • Loading branch information
Archie-Miller authored Dec 3, 2024
1 parent 6925e15 commit bc0b181
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Libraries/Opc.Ua.Client/Subscription/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,33 @@ public bool ConditionRefresh()
return false;
}

/// <summary>
/// Tells the server to refresh all conditions being monitored by the subscription for a specific
/// monitoredItem for events.
/// </summary>
public bool ConditionRefresh2(uint monitoredItemId)
{
VerifySubscriptionState(true);

try
{
object[] inputArguments = new object[] { m_id, monitoredItemId };

m_session.Call(
ObjectTypeIds.ConditionType,
MethodIds.ConditionType_ConditionRefresh2,
inputArguments);

return true;
}
catch (ServiceResultException sre)
{
Utils.LogError(sre, "SubscriptionId {0}: Item {1} Failed to call ConditionRefresh2 on server",
m_id, monitoredItemId);
}
return false;
}

/// <summary>
/// Call the ResendData method on the server for this subscription.
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions Libraries/Opc.Ua.Client/Subscription/SubscriptionAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ public async Task ConditionRefreshAsync(CancellationToken ct = default)

var methodsToCall = new CallMethodRequestCollection();
methodsToCall.Add(new CallMethodRequest() {
ObjectId = ObjectTypeIds.ConditionType,
MethodId = MethodIds.ConditionType_ConditionRefresh,
InputArguments = new VariantCollection() { new Variant(m_id) }
});
Expand All @@ -464,6 +465,29 @@ public async Task ConditionRefreshAsync(CancellationToken ct = default)
ct).ConfigureAwait(false);
}

/// <summary>
/// Tells the server to refresh all conditions being monitored by the subscription for a specific
/// monitoredItem for events.
/// </summary>
public async Task ConditionRefresh2Async(uint monitoredItemId, CancellationToken ct = default)
{
VerifySubscriptionState(true);

var methodsToCall = new CallMethodRequestCollection();
methodsToCall.Add(new CallMethodRequest() {
ObjectId = ObjectTypeIds.ConditionType,
MethodId = MethodIds.ConditionType_ConditionRefresh2,
InputArguments = new VariantCollection() {
new Variant(m_id),
new Variant( monitoredItemId ) }
});

var response = await m_session.CallAsync(
null,
methodsToCall,
ct).ConfigureAwait(false);
}

#endregion
}
}
Expand Down

0 comments on commit bc0b181

Please sign in to comment.