feat(heidenhain): Part 9 condition class from alarm class/group, ALARM: selectors in the browse picker, unclaimed alarms counted + logged (#839)
- Core: optional AlarmEventArgs.ConditionClass (AlarmConditionClass Base/Process/Maintenance/System/Safety) carried by NativeAlarmProjector on AlarmConditionSnapshot and written to ConditionClassId/Name by OtOpcUaNodeManager (kept across class-less events, carried across a #641 rebuild). - Heidenhain: HeidenhainAlarmClasses — HEIDENHAIN DNC-interface class/group names (corroborated by the captured iTNC 530 record); class 5 => Safety, group 1/2 => Process, 4/5 => System, else Base. - DiscoverAsync offers AlarmConditions/ selector leaves (IsAlarm Boolean); browse-commit seeds the alarm object. - Alarms no selector claims: otopcua.driver.alarms.unmatched counter, /hosts diagnostics, rate-limited Warning. Refs #839
This commit is contained in:
@@ -122,4 +122,27 @@ public sealed class HeidenhainAuthoringTests
|
||||
TagConfigValidator.Validate(DriverTypeNames.Heidenhain, json).ShouldBeNull();
|
||||
HeidenhainTagConfigModel.FromJson(json).Address.ShouldBe(address);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// lmxopcua#839: every <c>ALARM:</c> selector the browse picker offers commits as a complete condition tag — the
|
||||
/// paired <c>alarm</c> object seeded, Boolean, accepted by the driver's own factory and the editor's validator —
|
||||
/// so a browse-commit never lands a tag the deploy gate would refuse.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Browse_committed_alarm_selectors_are_complete_conditions_the_driver_accepts()
|
||||
{
|
||||
HeidenhainAlarmClasses.BrowseSelectors.Count.ShouldBeGreaterThan(2);
|
||||
foreach (var (_, name, address) in HeidenhainAlarmClasses.BrowseSelectors)
|
||||
{
|
||||
var row = RawBrowseCommitMapper.MapLeaf(
|
||||
DriverTypeNames.Heidenhain, address, name, nameof(DriverDataType.Boolean), "String",
|
||||
groupPrefix: null, folderPath: null, createGroups: false);
|
||||
row.Tag.DataType.ShouldBe("Boolean");
|
||||
var json = row.Tag.TagConfig!;
|
||||
JsonNode.Parse(json)!["alarm"].ShouldNotBeNull(address);
|
||||
HeidenhainTagDefinitionFactory.TryFromTagConfig("p", "d", json, out var def, out var error).ShouldBeTrue(error);
|
||||
def!.IsAlarmCondition.ShouldBeTrue();
|
||||
TagConfigValidator.Validate(DriverTypeNames.Heidenhain, json).ShouldBeNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
@@ -123,6 +123,37 @@ public sealed class NodeManagerNativeAlarmRebuildCarryOverTests : IDisposable
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// lmxopcua#839 — a classifying native source's Part 9 ConditionClass lands on the node, a later snapshot
|
||||
/// without one (a quality-only annotation, a non-classifying path) keeps it, and a rebuild carries it.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
[Fact]
|
||||
public async Task A_driver_assigned_condition_class_is_applied_kept_and_carried_across_a_rebuild()
|
||||
{
|
||||
var (host, nm) = await BootAsync();
|
||||
Materialise(nm, native: true);
|
||||
Condition(nm).ConditionClassId!.Value.ShouldBe(ObjectTypeIds.BaseConditionClassType);
|
||||
|
||||
nm.WriteAlarmCondition(Alarm, Fault(acked: false) with { ConditionClass = ZB.MOM.WW.OtOpcUa.Core.Abstractions.AlarmConditionClass.Safety },
|
||||
DateTime.UtcNow, AddressSpaceRealm.Raw);
|
||||
Condition(nm).ConditionClassId!.Value.ShouldBe(ObjectTypeIds.SafetyConditionClassType);
|
||||
Condition(nm).ConditionClassName!.Value.Text.ShouldBe("SafetyConditionClass");
|
||||
|
||||
nm.WriteAlarmCondition(Alarm, Fault(acked: false) with { StatusCode = OpcUaStatus.Bad }, DateTime.UtcNow, AddressSpaceRealm.Raw);
|
||||
Condition(nm).ConditionClassId!.Value.ShouldBe(ObjectTypeIds.SafetyConditionClassType);
|
||||
|
||||
// Even a NORMAL condition keeps its class across a rebuild — the class is not state.
|
||||
nm.WriteAlarmCondition(Alarm, Fault(acked: true) with { Active = false }, DateTime.UtcNow, AddressSpaceRealm.Raw);
|
||||
nm.RebuildAddressSpace();
|
||||
Materialise(nm, native: true);
|
||||
nm.CompleteAddressSpaceApply();
|
||||
Condition(nm).ConditionClassId!.Value.ShouldBe(ObjectTypeIds.SafetyConditionClassType);
|
||||
Condition(nm).ConditionClassName!.Value.Text.ShouldBe("SafetyConditionClass");
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>Falsification control: a condition in the no-event position comes back exactly as a fresh
|
||||
/// materialise builds it, and reports nothing.</summary>
|
||||
[Trait("Category", "Unit")]
|
||||
|
||||
@@ -24,6 +24,26 @@ public class NativeAlarmProjectorTests
|
||||
snap.Message.ShouldBe("boom");
|
||||
}
|
||||
|
||||
/// <summary>lmxopcua#839 — a classifying source's ConditionClass rides the snapshot; an event without one (a
|
||||
/// quality-only annotation, a Clear) keeps the class the condition last carried, and the default is null
|
||||
/// (= leave the node's class alone).</summary>
|
||||
[Fact]
|
||||
public void Condition_class_is_carried_and_kept_until_restated()
|
||||
{
|
||||
var sut = new NativeAlarmProjector();
|
||||
sut.Project("n1", Evt(AlarmTransitionKind.Raise)).ConditionClass.ShouldBeNull();
|
||||
sut.Project("n1", Evt(AlarmTransitionKind.Retrigger) with { ConditionClass = AlarmConditionClass.System })
|
||||
.ConditionClass.ShouldBe(AlarmConditionClass.System);
|
||||
sut.Project("n1", Evt(AlarmTransitionKind.Unspecified) with { QualityStatusCode = 0x80310000u })
|
||||
.ConditionClass.ShouldBe(AlarmConditionClass.System);
|
||||
sut.Project("n1", Evt(AlarmTransitionKind.Clear)).ConditionClass.ShouldBe(AlarmConditionClass.System);
|
||||
sut.MarkAcknowledged("n1");
|
||||
sut.Project("n1", Evt(AlarmTransitionKind.Raise) with { ConditionClass = AlarmConditionClass.Safety });
|
||||
sut.MarkAcknowledged("n1");
|
||||
sut.TryRevertAcknowledge("n1", out var reverted).ShouldBeTrue();
|
||||
reverted!.ConditionClass.ShouldBe(AlarmConditionClass.Safety);
|
||||
}
|
||||
|
||||
/// <summary>Gitea #641 — <c>RetainOnly</c> keeps a still-deployed condition's prior state and forgets a removed
|
||||
/// one's (which then starts from the default inactive + acked).</summary>
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user