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

Fix for 2854 - ConditionRefreshAsync always results in BadNodeIdUnknown #2876

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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);

Check warning on line 1672 in Libraries/Opc.Ua.Client/Subscription/Subscription.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/Subscription.cs#L1672

Added line #L1672 was not covered by tests

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

Check warning on line 1676 in Libraries/Opc.Ua.Client/Subscription/Subscription.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/Subscription.cs#L1676

Added line #L1676 was not covered by tests

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

Check warning on line 1681 in Libraries/Opc.Ua.Client/Subscription/Subscription.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/Subscription.cs#L1678-L1681

Added lines #L1678 - L1681 were not covered by tests

return true;

Check warning on line 1683 in Libraries/Opc.Ua.Client/Subscription/Subscription.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/Subscription.cs#L1683

Added line #L1683 was not covered by tests
}
catch (ServiceResultException sre)
{
Utils.LogError(sre, "SubscriptionId {0}: Item {1} Failed to call ConditionRefresh2 on server",
m_id, monitoredItemId);
}
return false;
}

Check warning on line 1691 in Libraries/Opc.Ua.Client/Subscription/Subscription.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/Subscription.cs#L1687-L1691

Added lines #L1687 - L1691 were not covered by tests

/// <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 @@

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 @@
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);

Check warning on line 474 in Libraries/Opc.Ua.Client/Subscription/SubscriptionAsync.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/SubscriptionAsync.cs#L474

Added line #L474 was not covered by tests

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 ) }
});

Check warning on line 483 in Libraries/Opc.Ua.Client/Subscription/SubscriptionAsync.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/SubscriptionAsync.cs#L476-L483

Added lines #L476 - L483 were not covered by tests

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

Check warning on line 489 in Libraries/Opc.Ua.Client/Subscription/SubscriptionAsync.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Client/Subscription/SubscriptionAsync.cs#L485-L489

Added lines #L485 - L489 were not covered by tests

#endregion
}
}
Expand Down
Loading