Repository navigation
feat(opcua): state registers with several healthy values and gates - #781
Closed
mfaferek93 wants to merge 2 commits into
Closed
mfaferek93 wants to merge 2 commits into
mfaferek93 wants to merge 2 commits into
Conversation
fault_enum takes ok_values, so a state machine register with many healthy states does not raise its catch-all. A detection entry can be gated on another polled point: inhibit_when keeps a fault from being raised while that point reads one of the listed values, only_when evaluates the rule only then.
The value conversion only handles scalars, and getScalarCopy throws BadVariantAccess on an array of a matching type, which no read path caught. auto_browse on a server with array variables (recipe tables, alarm lists) took the gateway down. A non-scalar read is now not good, so auto_browse skips the node and polling or a subscription drops it.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved gate lookup and fault-clearing issues can silently disable a valid gate or leave a fault active after its only_when condition stops matching.
2 open issues
What changed in this PR
Adds state-aware fault detection to the OPC UA plugin, building on the shared fault-detection library, and prevents array reads from being treated as scalars.
Changes:
- Supports multiple healthy enum values and cross-point gates for suppressing or clearing faults.
- Rejects non-scalar OPC UA values in reads and subscription callbacks.
- Adds configuration validation, documentation, and unit and integration coverage.
| File | Description |
|---|---|
src/ros2_medkit_plugins/ros2_medkit_opcua/test/test_node_map.cpp |
Tests healthy-value lists and gate validation. |
src/ros2_medkit_plugins/ros2_medkit_opcua/test/integration/test_opcua_state_gates.test.py |
Exercises fault transitions and array skipping end to end. |
src/ros2_medkit_plugins/ros2_medkit_opcua/test/fixtures/test_alarm_server/test_alarm_server.cpp |
Adds state registers and a read-only array fixture. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/opcua_poller.cpp |
Applies gates to evaluated fault signals. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/opcua_client.cpp |
Guards scalar conversion against array values. |
src/ros2_medkit_plugins/ros2_medkit_opcua/src/node_map.cpp |
Parses and validates healthy-value lists and gates. |
src/ros2_medkit_plugins/ros2_medkit_opcua/README.md |
Documents state-register configuration and gate behavior. |
src/ros2_medkit_plugins/ros2_medkit_opcua/include/ros2_medkit_opcua/node_map.hpp |
Defines gate configuration on mapped points. |
src/ros2_medkit_plugins/ros2_medkit_opcua/CMakeLists.txt |
Registers and installs the new integration test. |
src/ros2_medkit_fault_detection/test/test_fault_detection.cpp |
Tests multiple healthy enum states. |
src/ros2_medkit_fault_detection/include/ros2_medkit_fault_detection/fault_detection.hpp |
Extends shared enum evaluation with ok_values. |
Review effort: Balanced
| if (!gate) { | ||
| return std::nullopt; | ||
| } | ||
| auto g = snapshot_.values.find(gate->node_id_str); |
Comment on lines
+1495
to
+1497
| for (auto & s : signals) { | ||
| if (only.has_value() && !*only) { | ||
| s.active = false; |
This was referenced Nov 9, 2026
Collaborator
Author
|
Superseded by #783, which carries this change as its own commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Summary
fault_enum.ok_values: more healthy values besideok_value. A state machine register (ISA-TR88 state numbers, Machinery item state) has many healthy states; without the list each of them raises the catch-all.inhibit_when/only_whenon any detection entry, gated on another polled point of the map:inhibit_when: no fault is raised while the gate point reads one ofvalues(changeover, setup, maintenance mode). A fault raised before keeps its state until its own value clears it.only_when: the rule is evaluated only while the gate matches, otherwise its faults clear (a stop reason that stays latched after the machine runs again).nodes:, names the entry itself, orvaluesis not a non-empty integer list. An unread gate point gates nothing.variant_to_valuehandles scalars only andgetScalarCopythrowsBadVariantAccesson an array of a matching type, which no read path caught.auto_browseagainst any server with array variables (seen on the umati sample server) disabled the plugin inset_contextor terminated the process on a later walk. A non-scalar value is now a bad read, soauto_browseskips the node and polling or a subscription drops it.Tests
test_fault_detection:OkValuesAreHealthyStates.test_node_map: parsing ofok_valuesand both gates, rejection of a gate on a missing point, on itself, and malformed lists.test_opcua_state_gates(real gateway, fault manager and fixture server): healthy states, aborted in production raises, a raised fault survives an inhibiting mode, aborted during an inhibiting mode is not raised and is raised once the mode ends, catch-all,only_whenignores a latched reason while running and raises it while stopped, planned reason raises nothing. Against the plugin without this change it fails 7 of its expectations.Recipe.Steps). Without the array fix,test_opcua_read_onlyandtest_opcua_state_gatesfail with the plugin disabled (Plugin 'opcua' threw during set_context(): Variant is not a scalar); with it both pass.colcon testforros2_medkit_fault_detectionandros2_medkit_opcua, 568 tests, 0 failures, ctest 28/28 for the plugin.