fix(opcua): restore alarm component reference after SDK creation
This commit is contained in:
@@ -41,6 +41,31 @@ public sealed class NodeManagerAlarmSourceFieldsTests : IDisposable
|
||||
Path.GetTempPath(),
|
||||
$"otopcua-alarm-src-fields-{Guid.NewGuid():N}");
|
||||
|
||||
[Theory]
|
||||
[InlineData("OffNormalAlarm", AddressSpaceRealm.Raw)]
|
||||
[InlineData("DiscreteAlarm", AddressSpaceRealm.Raw)]
|
||||
[InlineData("AlarmCondition", AddressSpaceRealm.Raw)]
|
||||
[InlineData("OffNormalAlarm", AddressSpaceRealm.Uns)]
|
||||
[InlineData("DiscreteAlarm", AddressSpaceRealm.Uns)]
|
||||
[InlineData("AlarmCondition", AddressSpaceRealm.Uns)]
|
||||
public async Task Created_alarm_retains_the_parent_component_reference(string type, AddressSpaceRealm realm)
|
||||
{
|
||||
await using var host = await BootAsync();
|
||||
var nm = host.Nm;
|
||||
nm.EnsureFolder("browse-parent", null, "Parent", realm);
|
||||
nm.MaterialiseAlarmCondition("browse-alarm", "browse-parent", "Alarm", type, 500, realm, isNative: realm == AddressSpaceRealm.Raw);
|
||||
var condition = nm.TryGetAlarmCondition("browse-alarm", realm)!;
|
||||
condition.ReferenceTypeId.ShouldBe(ReferenceTypeIds.HasComponent);
|
||||
condition.Parent!.NodeId.ShouldBe(new NodeId("browse-parent", nm.NamespaceIndexForRealm(realm)));
|
||||
condition.TypeDefinitionId.ShouldBe(type switch
|
||||
{
|
||||
"OffNormalAlarm" => ObjectTypeIds.OffNormalAlarmType,
|
||||
"DiscreteAlarm" => ObjectTypeIds.DiscreteAlarmType,
|
||||
_ => ObjectTypeIds.AlarmConditionType,
|
||||
});
|
||||
condition.NodeClass.ShouldBe(NodeClass.Object);
|
||||
}
|
||||
|
||||
/// <summary>A NATIVE condition (Raw realm, ConditionId = RawPath) carries all three identity fields:
|
||||
/// EventType = its type definition, SourceNode = its own NodeId, SourceName = the RawPath. The leaf name
|
||||
/// remains on ConditionName so the short name is still available to clients.</summary>
|
||||
|
||||
Reference in New Issue
Block a user