64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public members surfaced by commentchecker — resolves 5,847 of 5,869 issues (99.6%) across three /fixdocs passes.
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using Opc.Ua;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Client.UI.Helpers;
|
|
|
|
/// <summary>
|
|
/// Formats OPC UA status codes as "0xHEX (description)".
|
|
/// </summary>
|
|
internal static class StatusCodeFormatter
|
|
{
|
|
/// <summary>Formats an OPC UA status code as a hexadecimal code with description.</summary>
|
|
/// <param name="statusCode">The OPC UA status code to format.</param>
|
|
/// <returns>A formatted string in the form "0xHEX (description)".</returns>
|
|
public static string Format(StatusCode statusCode)
|
|
{
|
|
var code = statusCode.Code;
|
|
var hex = $"0x{code:X8}";
|
|
|
|
// Try the SDK's browse name lookup first
|
|
var name = StatusCodes.GetBrowseName(code);
|
|
if (!string.IsNullOrEmpty(name))
|
|
return $"{hex} ({name})";
|
|
|
|
// Try masking to just the main code (top 16 bits) for sub-status codes
|
|
var mainCode = code & 0xFFFF0000;
|
|
if (mainCode != code)
|
|
{
|
|
name = StatusCodes.GetBrowseName(mainCode);
|
|
if (!string.IsNullOrEmpty(name))
|
|
return $"{hex} ({name})";
|
|
}
|
|
|
|
// Fallback to severity category
|
|
if (StatusCode.IsGood(statusCode))
|
|
return $"{hex} (Good)";
|
|
if (StatusCode.IsBad(statusCode))
|
|
return $"{hex} (Bad)";
|
|
return $"{hex} (Uncertain)";
|
|
}
|
|
}
|