-
Notifications
You must be signed in to change notification settings - Fork 979
[Server] Add Support for Sampling Groups to CustomNodeManager #3075
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3075 +/- ##
==========================================
+ Coverage 57.33% 57.97% +0.63%
==========================================
Files 357 359 +2
Lines 69012 69176 +164
Branches 14164 14184 +20
==========================================
+ Hits 39571 40105 +534
+ Misses 25195 24784 -411
- Partials 4246 4287 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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. |
//If sampling groups are used, samplingInterval needs to be waited before values are queued | ||
if (m_fixture.UseSamplingGroupsInReferenceNodeManager) | ||
{ | ||
Thread.Sleep((int)(100.0 * 1.1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a fixed Thread.Sleep in tests may lead to flaky behavior; consider replacing it with a more robust waiting or polling mechanism that ensures the sampling interval delay is properly met.
//If sampling groups are used, samplingInterval needs to be waited before values are queued | |
if (m_fixture.UseSamplingGroupsInReferenceNodeManager) | |
{ | |
Thread.Sleep((int)(100.0 * 1.1)); | |
// If sampling groups are used, wait for the sampling interval to elapse before queuing values | |
if (m_fixture.UseSamplingGroupsInReferenceNodeManager) | |
{ | |
var samplingInterval = TimeSpan.FromMilliseconds(100.0 * 1.1); | |
var timeout = TimeSpan.FromSeconds(5); // Set a reasonable timeout | |
var startTime = DateTime.UtcNow; | |
while (DateTime.UtcNow - startTime < timeout) | |
{ | |
if (HasSamplingIntervalElapsed(samplingInterval)) | |
{ | |
break; | |
} | |
Thread.Sleep(10); // Polling interval | |
} |
Copilot uses AI. Check for mistakes.
Func<ISystemContext, NodeHandle, NodeState, NodeState> AddNodeToComponentCache) | ||
{ | ||
// set min sampling interval if 0 | ||
if(samplingInterval.CompareTo(0.0) == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider validating that the samplingInterval is not only equal to zero but also not negative, ensuring adherence to a proper minimum sampling interval requirement.
if(samplingInterval.CompareTo(0.0) == 0) | |
if (samplingInterval <= 0.0) |
Copilot uses AI. Check for mistakes.
Proposed changes
This PR introduces a
MonitoredItemManager
that manages MonitoredItems for theCustomNodeManager
thisIMonitoredItemManager
abstraction has two default implementations, theMonitoredNodeMonitoredItemManager
and theSamplingGroupMonitoredItemManager
. These allow theCustomNodeManger
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 theINodeManager
Interface, but instead relying on the proven mechanims of theCustomNodeManager
.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
Checklist
Further comments