Merge hw2-focas: hardware live-gate fixes (hw2-focas)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -79,6 +79,11 @@ public class AlarmsCommand : CommandBase
|
||||
if (!string.IsNullOrEmpty(e.Message))
|
||||
outputChannel.Writer.TryWrite($" Message: {e.Message}");
|
||||
outputChannel.Writer.TryWrite($" Retain: {e.Retain}");
|
||||
// `ack` needs both of these and nothing else in the CLI surfaces them.
|
||||
if (!string.IsNullOrEmpty(e.ConditionNodeId))
|
||||
outputChannel.Writer.TryWrite($" ConditionNodeId: {e.ConditionNodeId}");
|
||||
if (e.EventId is { Length: > 0 })
|
||||
outputChannel.Writer.TryWrite($" EventId: {Convert.ToHexString(e.EventId)}");
|
||||
outputChannel.Writer.TryWrite(string.Empty);
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -82,6 +82,30 @@ public class AlarmsCommandTests
|
||||
output.ShouldContain("Condition refresh requested.");
|
||||
}
|
||||
|
||||
/// <summary>The printed alarm carries the ConditionNodeId and EventId that `ack` requires (hex round-trips).</summary>
|
||||
[Fact]
|
||||
public async Task Execute_PrintsConditionNodeIdAndEventId_ForAck()
|
||||
{
|
||||
var fakeService = new FakeOpcUaClientService();
|
||||
var factory = new FakeOpcUaClientServiceFactory(fakeService);
|
||||
var command = new AlarmsCommand(factory) { Url = "opc.tcp://localhost:4840" };
|
||||
|
||||
using var console = TestConsoleHelper.CreateConsole();
|
||||
var task = Task.Run(async () => { await command.ExecuteAsync(console); });
|
||||
|
||||
await fakeService.SubscribeAlarmsInvoked.WaitAsync(TimeSpan.FromSeconds(10));
|
||||
fakeService.RaiseAlarmEvent(new Client.Shared.Models.AlarmEventArgs(
|
||||
"src", "cond", 500, "msg", true, true, false, DateTime.UtcNow,
|
||||
eventId: [0xAB, 0x01, 0xFF], conditionNodeId: "ns=2;s=Plant/cond"));
|
||||
await Task.Delay(500);
|
||||
console.RequestCancellation();
|
||||
await task;
|
||||
|
||||
var output = TestConsoleHelper.GetOutput(console);
|
||||
output.ShouldContain("ConditionNodeId: ns=2;s=Plant/cond");
|
||||
output.ShouldContain("EventId: AB01FF");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that refresh failure prints error.</summary>
|
||||
[Fact]
|
||||
public async Task Execute_RefreshFailure_PrintsError()
|
||||
|
||||
Reference in New Issue
Block a user