Add support for restoring triggered monitored items on session reconnect #3377
+328
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This PR adds automatic restoration of triggering item relationships when an OPC UA session reconnects or subscriptions are transferred. Previously, when a server restarted and the client reconnected, monitored items that were configured with triggering relationships (via
SetTriggering) would lose those links, requiring manual re-establishment by the application.The implementation includes:
Persistent storage for triggering relationships - New properties in
MonitoredItemStateandMonitoredItemclasses to track which items trigger which other items:TriggeringItemId: Identifies the triggering item for a monitored itemTriggeredItems: Collection of client handles for items triggered by this itemAutomatic restoration logic - A new
RestoreTriggeringAsyncmethod that automatically re-establishes triggering links:User-friendly API - New
Subscription.SetTriggeringAsyncmethod that:MonitoredItemobjects instead of just server IDsTest coverage - Added
SetTriggeringTrackingAsynctest that validates:Related Issues
Types of changes
What types of changes does your code introduce?
Checklist
Further comments
This change eliminates the need for applications to manually track and restore triggering relationships after reconnection. Users can now use the new
Subscription.SetTriggeringAsyncmethod, and the SDK will automatically handle restoration during reconnection or transfer scenarios.The implementation is backward compatible - existing code using
Session.SetTriggeringdirectly will continue to work, but won't benefit from automatic restoration unless migrated to useSubscription.SetTriggeringAsync.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.