Skip to content

[Server] Add support for SupportsFilteredRetain#2913

Merged
mrsuciu merged 9 commits intoOPCFoundation:masterfrom
DreamsAndAdventures:archie/2142_Filter_Retain_Redo
Feb 17, 2025
Merged

[Server] Add support for SupportsFilteredRetain#2913
mrsuciu merged 9 commits intoOPCFoundation:masterfrom
DreamsAndAdventures:archie/2142_Filter_Retain_Redo

Conversation

@Archie-Miller
Copy link
Contributor

@Archie-Miller Archie-Miller commented Dec 17, 2024

Proposed changes

Add support for SupportsFilteredRetain - Issue 2142

This pull request introduces a new feature to support filtered retain conditions in the OPC UA server. The most important changes include adding a new method to determine if an event can be sent with filtered retain consideration, updating the MonitoredItem class to use this method, and adding a new property to the ConditionState class.

Enhancements to Event Filtering:

Additions to ConditionState:

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • Bugfix (non-breaking change which fixes an issue)
  • [ x ] 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

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • [ x ] I have read the CONTRIBUTING doc.
  • [ x ] 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.
  • [ x ] 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

One potential issue is that the ConditionState SupportsFilteredRetain property should be handled by the ObjectModeller. When this is implemented, this property and member variable will need to be removed.

@codecov
Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.

Project coverage is 55.73%. Comparing base (23d167a) to head (2422c97).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...raries/Opc.Ua.Server/Subscription/MonitoredItem.cs 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2913      +/-   ##
==========================================
+ Coverage   55.41%   55.73%   +0.31%     
==========================================
  Files         352      352              
  Lines       67899    67930      +31     
  Branches    13931    13939       +8     
==========================================
+ Hits        37629    37861     +232     
+ Misses      26140    25917     -223     
- Partials     4130     4152      +22     

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

@romanett romanett changed the title Archie/2142 filter retain redo [Server] Add support for SupportsFilteredRetain Dec 18, 2024
@romanett romanett linked an issue Dec 18, 2024 that may be closed by this pull request
5 tasks
@mregen mregen requested review from Copilot and mrsuciu December 19, 2024 15:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs:1086

  • [nitpick] The method name 'CanSendFilteredAlarm' is ambiguous. Consider renaming it to 'ShouldSendFilteredAlarm' to better reflect its purpose.
protected bool CanSendFilteredAlarm(FilterContext context, EventFilter filter, IFilterTarget instance)

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs:1086

  • The new behavior introduced by 'CanSendFilteredAlarm' should be covered by tests to ensure it works as expected.
protected bool CanSendFilteredAlarm(FilterContext context, EventFilter filter, IFilterTarget instance)

@mregen mregen requested a review from Copilot December 19, 2024 18:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs:1045

  • [nitpick] The method name 'CanSendFilteredAlarm' is ambiguous and does not clearly convey its purpose. Consider renaming it to 'ShouldSendFilteredAlarm' to better reflect its functionality.
if ( !CanSendFilteredAlarm( context, filter, instance ) )

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs:1135

  • The comment includes a date 'December 17 2024' which may be a typo or placeholder. Ensure the date is correct or remove it if unnecessary.
// Archie - December 17 2024

Libraries/Opc.Ua.Server/Subscription/MonitoredItem.cs:1144

  • The variable 'saved' is used without being initialized in some cases. Ensure 'saved' is properly initialized before use to avoid potential null reference errors.
if ( saved )


bool canSend = passedFilter;

// ConditionId is valid only if FilteredRetain is set for the alarm condition
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the ConditionId only valid if FilteredRetain is set ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic is specifically for SupportsFilterRetain, so if it is not set, the remainder of the function is not required, only the filter check at the top of the function.

This is still a work in progress, I'm going to move it to draft for now.

@Archie-Miller Archie-Miller marked this pull request as draft December 20, 2024 15:57
@romanett
Copy link
Contributor

@Archie-Miller can you describe, what is still missing for this PR to be ready to merge

@Archie-Miller Archie-Miller marked this pull request as ready for review January 23, 2025 17:05
@Archie-Miller
Copy link
Contributor Author

Archie-Miller commented Jan 23, 2025 via email

@mrsuciu mrsuciu self-requested a review February 17, 2025 11:38
@mrsuciu mrsuciu merged commit 37cebe3 into OPCFoundation:master Feb 17, 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.

SupportsFilteredRetain support in NETStandard SDK

3 participants