feat(cli): print array values; docs: #615 G9 PASS with otopcua-cli, G8 waived
v2-ci / unit-tests (push) Has been cancelled

G9 ran on an isolated 2-node pair (otopcua-g9, 003c7f89, Mode unset as
deployed) with otopcua-cli as the owner-approved client: A1-A3, A5, A7, A8
(graceful, ~11 s gap), B2 (docker kill, failover <1 s, ~2 s gap, 0 Bad,
survivor 250 at +44 s) and B3 (no failback) pass; A4/A5b unmet under Unset,
met under Warm (#717). G8 (CTT) waived by the owner for GA; G5 is the only
open exit criterion.

The run found the CLI printing every array as System.String[] (ServerArray
unreadable); ValueFormatter now renders [a, b] / hex for read, subscribe and
historyread, with tests. Runbook A4/A5b text updated for the #717 modes.
Evidence: docs/plans/evidence/2026-11-13-615-g9/RESULTS.md.
This commit is contained in:
Joseph Doherty
2026-11-13 07:46:56 -05:00
parent a59dbd4f07
commit c9bc358dc9
25 changed files with 861 additions and 20 deletions
@@ -211,7 +211,7 @@ public class HistoryReadCommand : CommandBase
: StatusCode.IsBad(dv.StatusCode) ? "Bad"
: "Uncertain";
await console.Output.WriteLineAsync(
$"{dv.SourceTimestamp.ToString("O"),-35} {ValueConverter.ToClrObject(dv.WrappedValue)?.ToString() ?? "(none)",-15} {status,-10} " +
$"{dv.SourceTimestamp.ToString("O"),-35} {(ValueConverter.ToClrObject(dv.WrappedValue) is { } hv ? ValueFormatter.Format(hv) : "(none)"),-15} {status,-10} " +
$"{e.UpdateType,-8} {e.UserName ?? "",-20} {e.ModificationTime:O}");
}
@@ -245,7 +245,7 @@ public class HistoryReadCommand : CommandBase
: StatusCode.IsBad(dv.StatusCode) ? "Bad"
: "Uncertain";
await console.Output.WriteLineAsync(
$"{dv.SourceTimestamp.ToString("O"),-35} {ValueConverter.ToClrObject(dv.WrappedValue),-15} {status}");
$"{dv.SourceTimestamp.ToString("O"),-35} {ValueFormatter.Format(ValueConverter.ToClrObject(dv.WrappedValue)),-15} {status}");
}
await console.Output.WriteLineAsync();
@@ -65,7 +65,7 @@ public class ReadCommand : CommandBase
}
await console.Output.WriteLineAsync($"Node: {NodeId}");
await console.Output.WriteLineAsync($"Value: {ValueConverter.ToClrObject(value.WrappedValue)}");
await console.Output.WriteLineAsync($"Value: {ValueFormatter.Format(ValueConverter.ToClrObject(value.WrappedValue))}");
await console.Output.WriteLineAsync($"Status: {value.StatusCode}");
await console.Output.WriteLineAsync($"Source Time: {value.SourceTimestamp:O}");
await console.Output.WriteLineAsync($"Server Time: {value.ServerTimestamp:O}");
@@ -131,7 +131,7 @@ public class SubscribeCommand : CommandBase
if (!Quiet)
{
var line =
$"[{e.Value.SourceTimestamp:O}] {displayNameByNodeId.GetValueOrDefault(key, key)} = {ValueConverter.ToClrObject(e.Value.WrappedValue)} ({e.Value.StatusCode})";
$"[{e.Value.SourceTimestamp:O}] {displayNameByNodeId.GetValueOrDefault(key, key)} = {ValueFormatter.Format(ValueConverter.ToClrObject(e.Value.WrappedValue))} ({e.Value.StatusCode})";
outputChannel.Writer.TryWrite(line);
}
}
@@ -0,0 +1,25 @@
using System.Collections;
using System.Globalization;
namespace ZB.MOM.WW.OtOpcUa.Client.CLI.Helpers;
/// <summary>
/// Renders a converted OPC UA value for console output. Interpolating a CLR array prints its type name
/// (<c>System.String[]</c>), which hid the content of every array-valued node (e.g. <c>ServerArray</c>
/// <c>i=2254</c>, found during the #615 G9 run); this prints the elements instead.
/// </summary>
public static class ValueFormatter
{
/// <summary>Formats a value for display.</summary>
/// <param name="value">The value, as returned by <c>ValueConverter.ToClrObject</c>.</param>
/// <returns><c>[a, b, …]</c> for a collection (recursively), hex for a byte string, otherwise the invariant text.</returns>
public static string Format(object? value) => value switch
{
null => string.Empty,
string s => s,
byte[] bytes => "0x" + Convert.ToHexString(bytes),
IEnumerable items => "[" + string.Join(", ", items.Cast<object?>().Select(Format)) + "]",
IFormattable f => f.ToString(null, CultureInfo.InvariantCulture),
_ => value.ToString() ?? string.Empty,
};
}