fix(opcua): restore alarm component reference after SDK creation

This commit is contained in:
Joseph Doherty
2026-11-10 12:13:56 -05:00
parent 8be3bb1734
commit 41e65f6a22
3 changed files with 100 additions and 3 deletions
@@ -1533,9 +1533,6 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
alarm.ShelvingState = new ShelvedStateMachineState(alarm);
alarm.MaxTimeShelved = new PropertyState<double>.Implementation<VariantBuilder>(alarm);
alarm.SymbolicName = displayName;
// HasComponent so the parent folder "owns" the condition (matches the T13 notes' pattern).
alarm.ReferenceTypeId = ReferenceTypeIds.HasComponent;
// Create builds the full mandatory Part 9 child set (EnabledState, AckedState,
// ActiveState, the Acknowledge/Confirm/AddComment/Enable/Disable methods, ...) from the
// type's embedded definition; we do not hand-build them.
@@ -1545,6 +1542,10 @@ public sealed class OtOpcUaNodeManager : CustomNodeManager2
new QualifiedName(displayName, ns),
new LocalizedText(displayName),
assignNodeIds: true);
// Create initializes the embedded definition and resets ReferenceTypeId in SDK 2.0.1.
// Restore the application's parent ownership before AddChild: hierarchical folder browses
// must expose the alarm as a HasComponent object, as they did before the SDK upgrade.
alarm.ReferenceTypeId = ReferenceTypeIds.HasComponent;
// Main-branch id MUST be a concrete (null) NodeId before any Set* call: SetEnableState ->
// UpdateRetainState -> GetRetainState -> IsBranch() dereferences BranchId.Value, which