Skip to content

fix(opcua): per-source ConditionRefresh, ordered report and clear, array event fields - #782

Closed
mfaferek93 wants to merge 4 commits into
feat/opcua-enum-state-gatesfrom
feat/opcua-companion-spec-machines
Closed

mfaferek93 wants to merge 4 commits into
feat/opcua-enum-state-gatesfrom
feat/opcua-companion-spec-machines

Conversation

@mfaferek93

Copy link
Copy Markdown
Collaborator

Summary

Four OPC UA plugin fixes found running the plugin against a companion-spec server with two machines, each machine object its own alarm notifier. Stacked on #781 (it needs fault_enum.ok_values and the array read fix from there); the diff below is only the four commits on top.

  • ConditionRefresh reconciled per event monitored item. Part 9 brackets the refresh replay on every event item of the subscription, and each item carries only its own notifier's conditions. With two event_alarms sources, the second item's RefreshEnd reconciled every tracked condition against its own burst and cleared the first source's live alarms after every reconnect. The replayed set and the reconcile are now per source, and a RefreshEnd without its RefreshStart reconciles nothing.
  • Report and clear of one fault code kept in order. ReportFault and ClearFault are separate services, so an alarm that came and went inside one publishing interval could reach fault_manager clear first and stay raised for good (seen: Fault cleared: X followed by New fault reported: X). Calls for one code now go out one at a time, each after the previous was answered (FaultCodeLanes). Other codes do not wait, and an unanswered call holds its code for at most 5 s.
  • Array event fields. feat(opcua): state registers with several healthy values and gates #781 makes an array value a bad read in the read path. The event path had the same isType<T>() + getScalarCopy pattern: an array Severity, Message, ConditionName or associated value threw out of on_event, and the notification was dropped. Same in the read-based condition replay. Those reads now check isScalar().
  • auto_browse.infer_writable alone no longer enables the walk. The object form defaulted enabled to true, so a read-only guard set beside a curated node map (auto_browse: false) turned the walk on. Without enabled, only a walk knob (root_nodes, max_depth, ...) turns it on now. Also match_message is accepted by the mapping key check: it was parsed but logged as an unknown key and "ignored".

Issue

  • No issue filed. Found while testing a node map with one event_alarms entry per machine object.

Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

  • test_opcua_poller: ConditionRefreshTest.EachSourceReconcilesOnlyItsOwnConditions (two sources, refresh bracketed on both, then one source alone, then a stray End) and EventFieldsTest.AnArrayFieldDoesNotDropTheEvent. With the old reconcile the first fails ({ "B_ALARM", "A_ALARM" } cleared, want { "A_ALARM" }); without the event-path guard the second fails.
  • test_fault_code_lanes (new, no ROS): order kept for one code, other codes do not wait, several calls in a row, stale call released and its late answer ignored, synchronous answers.
  • test_opcua_plugin: InferWritableAloneKeepsTheWalkOff, WalkKnobWithoutEnabledTurnsTheWalkOn.
  • Local (jazzy, arm64, read-only build, in the released gateway image): fault_detection and ros2_medkit_opcua unit tests, 311 tests, 0 failures.
  • End to end with a real gateway and fault_manager against an asyncua server with two machine objects as notifiers: before these fixes a reconnect cleared live alarms and a raise followed by a clear inside one publishing interval left the fault raised (about 1 run in 3). After: 11 consecutive full runs passed (8 with link reset, 3 with silent link loss).

Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

Part 9 brackets the refresh replay on every event item of the subscription,
and each item only carries its own notifier's conditions. With two alarm
sources the second RefreshEnd reconciled every tracked condition against its
own burst and cleared the first source's live alarms. The replayed set and
the reconcile are now kept per source, and an End without a Start is ignored.
isType<T>() is true for an array of T, so getScalarCopy threw
BadVariantAccess when an event field (Severity, Message, ConditionName, an
associated value) or a condition property read in the read-based replay was
an array: the notification was dropped, or the throw left the poll thread.
Every scalar read in those paths now checks isScalar() first.
ReportFault and ClearFault are separate services, so an alarm that came and
went inside one publishing interval could reach fault_manager clear first and
stay raised for good. Calls for one code now go out one at a time, each after
the previous was answered (an unanswered call holds its code for at most 5 s).
plugins.opcua.auto_browse.infer_writable: false, set on its own beside a
curated node map, enabled the walk because "enabled" defaulted to true for
any object. Without "enabled" only a walk knob turns it on now. Also accept
match_message in the event_alarms mapping key check: it was parsed but
reported as an unknown key.
@mfaferek93

Copy link
Copy Markdown
Collaborator Author

Superseded by #783, which carries this change as its own commit.

@mfaferek93 mfaferek93 closed this Nov 9, 2026
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.

1 participant