feat(alarms): carry transition Kind on AlarmEventArgs; Galaxy populates it (Phase B WS-1)

This commit is contained in:
Joseph Doherty
2026-06-14 03:04:44 -04:00
parent a996f03b5b
commit f44d8d1e6b
5 changed files with 87 additions and 2 deletions
@@ -42,6 +42,39 @@ public sealed class GalaxyDriverAlarmSourceTests
observed[0].SubscriptionHandle.ShouldBe(handle);
}
/// <summary>
/// Verifies that the driver maps each Galaxy transition kind onto the matching
/// <see cref="AlarmTransitionKind"/> on the surfaced <see cref="AlarmEventArgs"/>,
/// so a Part 9 consumer can derive active/ack state. The Galaxy kind is passed by
/// name because <c>GalaxyAlarmTransitionKind</c> is internal to the driver and so
/// cannot appear in a public test method signature.
/// </summary>
/// <param name="galaxyKindName">The <c>GalaxyAlarmTransitionKind</c> member name fed into the alarm feed.</param>
/// <param name="expectedKind">The expected <see cref="AlarmTransitionKind"/> on the surfaced event.</param>
[Theory]
[InlineData(nameof(GalaxyAlarmTransitionKind.Raise), AlarmTransitionKind.Raise)]
[InlineData(nameof(GalaxyAlarmTransitionKind.Acknowledge), AlarmTransitionKind.Acknowledge)]
[InlineData(nameof(GalaxyAlarmTransitionKind.Clear), AlarmTransitionKind.Clear)]
[InlineData(nameof(GalaxyAlarmTransitionKind.Retrigger), AlarmTransitionKind.Retrigger)]
[InlineData(nameof(GalaxyAlarmTransitionKind.Unspecified), AlarmTransitionKind.Unspecified)]
public async Task Transition_kind_maps_onto_AlarmEventArgs_Kind(
string galaxyKindName, AlarmTransitionKind expectedKind)
{
var galaxyKind = Enum.Parse<GalaxyAlarmTransitionKind>(galaxyKindName);
var feed = new FakeAlarmFeed();
var ack = new RecordingAcknowledger();
using var driver = NewDriver(feed, ack);
var handle = await driver.SubscribeAlarmsAsync(["Tank01"], CancellationToken.None);
var observed = new List<AlarmEventArgs>();
driver.OnAlarmEvent += (_, args) => observed.Add(args);
feed.Emit(NewTransition("Tank01.Level.HiHi", "Tank01", galaxyKind, AlarmSeverity.High));
observed.ShouldHaveSingleItem();
observed[0].Kind.ShouldBe(expectedKind);
}
/// <summary>Verifies that OnAlarmEvent does not fire before any alarm subscription.</summary>
[Fact]
public void OnAlarmEvent_does_not_fire_before_any_alarm_subscription()
@@ -6,6 +6,11 @@ using Xunit;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Runtime;
// Core.Abstractions now also defines an AlarmTransitionKind (the AlarmEventArgs surface
// kind). This file drives the gateway proto, so pin the bare token to the proto enum to
// preserve the existing references unchanged.
using AlarmTransitionKind = ZB.MOM.WW.MxGateway.Contracts.Proto.AlarmTransitionKind;
namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Tests.Runtime;
/// <summary>