Skip to content

feat(opcua): route alarms to distinct faults by message substring#506

Open
mfaferek93 wants to merge 4 commits into
mainfrom
feat/opcua-alarm-message-routing
Open

feat(opcua): route alarms to distinct faults by message substring#506
mfaferek93 wants to merge 4 commits into
mainfrom
feat/opcua-alarm-message-routing

Conversation

@mfaferek93

Copy link
Copy Markdown
Collaborator

Adds a match_message field to event_alarms[].mappings - a case-sensitive substring match on the event Message, AND-combined with the existing condition_name / source_node / event_type matchers. This lets one OPC UA source route alarms that share an EventType and SourceNode (e.g. Program_Alarms from one Siemens S7-1500 FB) to distinct SOVD faults by their text.

  • AlarmMapping gains match_message; resolve_alarm takes the event Message and skips a mapping whose non-empty match_message is not a substring of it. condition_name / source_node / event_type stay equality matches.
  • Parsed from mappings[].match_message; the poller passes the live event Message (and the read-path snapshot message).
  • README example + unit test (MatchByMessageSubstring) covering a match, the catch-all fallback, and an empty message.

Closes #505

event_alarms mappings gained a match_message field: a case-sensitive
substring match on the event Message, AND-combined with the existing
condition_name/source_node/event_type matchers. Lets one OPC UA source
route alarms that share an EventType and SourceNode (e.g. Program_Alarms
from one Siemens S7-1500 FB) to their own SOVD fault by text.
Copilot AI review requested due to automatic review settings July 5, 2026 19:24
@mfaferek93 mfaferek93 self-assigned this Jul 5, 2026

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

Adds OPC UA alarm-routing support to disambiguate alarms that share condition_name / source_node / event_type by additionally matching on a case-sensitive substring of the event Message, enabling distinct SOVD fault codes for same-source PLC alarms (per #505).

Changes:

  • Extend AlarmMapping with match_message and update NodeMap::resolve_alarm(...) to AND-combine substring matching with existing equality matchers.
  • Plumb the live/snapshot event message through OpcuaPoller into alarm resolution.
  • Update plugin documentation and add unit coverage for message-substring routing and fallback behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/ros2_medkit_plugins/ros2_medkit_opcua/test/test_node_map.cpp Updates existing resolve-alarm tests for new signature and adds MatchByMessageSubstring coverage.
src/ros2_medkit_plugins/ros2_medkit_opcua/src/opcua_poller.cpp Passes event/snapshot message into NodeMap::resolve_alarm for runtime + read-replay paths.
src/ros2_medkit_plugins/ros2_medkit_opcua/src/node_map.cpp Parses match_message from YAML and applies substring routing in resolve_alarm.
src/ros2_medkit_plugins/ros2_medkit_opcua/README.md Documents match_message behavior and clarifies matcher semantics.
src/ros2_medkit_plugins/ros2_medkit_opcua/include/ros2_medkit_opcua/node_map.hpp Adds match_message to AlarmMapping and updates the resolve-alarm API surface.

match_message is a substring match, not equality like the other match
fields; the struct doc said all fields must equal the observed event.

@bburda bburda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Additional findings outside the diff (both in ros2_medkit_opcua/README.md):

  • The event_alarms example uses PLC_OVERPRESSURE twice: once on the simple-form source (entity_id: tank_process) and once in the first mapping of the line_1 source. The loader rejects a fault code reused across sources, which the comment just above this example states, so this example fails to load if copied as-is. It predates this PR, but since you are editing this block, renaming one PLC_OVERPRESSURE would make the documented example loadable.
  • The multi-alarm form comment still says "the first whose non-empty match fields all equal the observed event wins". With match_message being a substring match, this is no longer accurate. You updated the precedence paragraph below (equal to match), so this inline comment can get the same fix.

Comment thread src/ros2_medkit_plugins/ros2_medkit_opcua/test/test_node_map.cpp
Rename the duplicated PLC_OVERPRESSURE so the example config loads (fault
codes are globally unique) and correct the comment to say match_message is
a substring match rather than an equality.
Add a case where a case-mismatched event message falls to the catch-all
and the exact case routes to the mapping, so a case-insensitive find
would regress red.
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.

opcua: route same-source alarms to distinct faults by message text

3 participants