Skip to content

[Server] Add Support for Sampling Groups to CustomNodeManager#3075

Merged
marcschier merged 23 commits into
OPCFoundation:masterfrom
romanett:rewriteCoreNodeManager
Aug 6, 2025
Merged

[Server] Add Support for Sampling Groups to CustomNodeManager#3075
marcschier merged 23 commits into
OPCFoundation:masterfrom
romanett:rewriteCoreNodeManager

Conversation

@romanett

@romanett romanett commented May 16, 2025

Copy link
Copy Markdown
Contributor

Proposed changes

This PR introduces a MonitoredItemManager that manages MonitoredItems for the CustomNodeManager this IMonitoredItemManager abstraction has two default implementations, the MonitoredNodeMonitoredItemManager and the SamplingGroupMonitoredItemManager. These allow the CustomNodeManger to manage DataChangeMonitoredItems using the Sampling Group mechanism instead of using the MonitoredNode functionality.

This PR is a first step to allow to obsolete the CoreNodeManager having it´s own implementation of the INodeManager Interface, but instead relying on the proven mechanims of the CustomNodeManager.

This PR also allows to increase the test coverage of the SamplingGroup implementation, that is not covered by tests yet.

The CustomNodeManger has a new constructor overload, that allows to specify if the sampling group mechanism shall be used.

The Reference Server is extended with a new Property UseSamplingGroupsInReferenceNodeManager that allows to enable the use of Sampling Groups in the Reference Node Manager so CTT tests can be carried out with the Sampling Groups.

The Parameter is also enabled in the Reference Server Test to verify the implementation of the sampling group.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

@codecov

codecov Bot commented May 16, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.72852% with 91 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.95%. Comparing base (6df0d13) to head (2899b34).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...MonitoredItem/SamplingGroupMonitoredItemManager.cs 47.87% 43 Missing and 6 partials ⚠️
...ies/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs 73.00% 26 Missing and 1 partial ⚠️
...MonitoredItem/MonitoredNodeMonitoredItemManager.cs 88.04% 6 Missing and 5 partials ⚠️
....Server/NodeManager/MonitoredItem/SamplingGroup.cs 0.00% 0 Missing and 3 partials ⚠️
.../NodeManager/MonitoredItem/SamplingGroupManager.cs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3075      +/-   ##
==========================================
+ Coverage   57.44%   57.95%   +0.50%     
==========================================
  Files         357      358       +1     
  Lines       69245    69339      +94     
  Branches    14235    14266      +31     
==========================================
+ Hits        39780    40186     +406     
+ Misses      25194    24833     -361     
- Partials     4271     4320      +49     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@romanett
romanett marked this pull request as ready for review May 26, 2025 04:56
@mregen
mregen requested a review from Copilot May 27, 2025 16:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for sampling groups to the CustomNodeManager by abstracting monitored item management into an IMonitoredItemManager interface with two implementations: one for sampling groups and one for the traditional monitored node mechanism. Key changes include adding new methods (e.g., SetMonitoringMode) to both server and client test services, updating the CustomNodeManager to use the new abstraction, and enabling sampling groups via the ReferenceServer and related configuration.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/Opc.Ua.Server.Tests/ServerTestServices.cs Added SetMonitoringMode method to forward calls to the underlying server, aligning with the new sampling group support.
Tests/Opc.Ua.Server.Tests/ServerFixture.cs Added a sampling groups flag and integrated a call to enable sampling groups in the ReferenceServer during startup.
Tests/Opc.Ua.Server.Tests/ReferenceServerTest.cs Updated tests to set UseSamplingGroupsInReferenceNodeManager and added a delay when sampling groups are active.
Tests/Opc.Ua.Client.Tests/ClientTestServices.cs Added a SetMonitoringMode method in the client test services to complement server changes.
Libraries/Opc.Ua.Server/NodeManager/MonitoredItem/SamplingGroupMonitoredItemManager.cs New implementation for managing monitored items when using sampling groups, including adjustments for zero sampling intervals.
Libraries/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs Refactored to delegate monitored item management to the new IMonitoredItemManager and updated event subscription and restoration code.
Applications/Quickstarts.Servers/ReferenceServer/* Updated the ReferenceServer and related utilities to respect the sampling groups flag and pass it to the CustomNodeManager.

Comment thread Tests/Opc.Ua.Server.Tests/ReferenceServerTest.cs
@romanett
romanett requested a review from mrsuciu June 1, 2025 11:09
@romanett
romanett requested a review from marcschier June 27, 2025 11:55
@romanett

Copy link
Copy Markdown
Contributor Author

@marcschier The changes are nonbreaking

Comment thread Libraries/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs Outdated
Comment thread Libraries/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs Outdated
Comment thread Libraries/Opc.Ua.Server/Diagnostics/CustomNodeManager.cs Outdated
@mrsuciu

mrsuciu commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

Still some work to be done on the SamplingGroup since it might leak instances with the current logic.

@romanett

romanett commented Aug 4, 2025

Copy link
Copy Markdown
Contributor Author

@mrsuciu I fixed the disposal of Sampling groups, as soon as a subscription times out it deletes all MIs and this triggers a disposal of the sampling group.

@romanett
romanett requested a review from salihgoncu August 4, 2025 14:22
@marcschier
marcschier merged commit 978dfe9 into OPCFoundation:master Aug 6, 2025
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants