341417f193
- Ab.Transport: AbOpcUaStatusMap is the single AbStatus->OPC UA table; AbCip/AbLegacy mappers delegate. - Remove dead MapCipGeneralStatus / MapPcccStatus / AbLegacy MapException (+ tests). - LibplctagOrphanRelease is one source file (Ab.LibplctagShared) compiled into both drivers. - LibplctagConfinementGuardTests: tokenising comment/literal stripper, block comments, csproj PackageReference guard. - LibplctagStatusTranslationTests: real LibPlcTagException round trip, WrapSync/Wrap OCE pass-through, adapter routes decode via WrapSync. - AbCipTypeMismatchTests: libplctag width-mismatch path (BadTypeMismatch, handle kept, no Degraded, warn once). - Host: AddAbCipDriverDefaults extension + Program.cs source pin for Drivers:AbCip:DefaultTransport. - docs/drivers/AbCip.md: layout rows + benign Degraded-after-outage note. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
56 lines
2.6 KiB
C#
56 lines
2.6 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport;
|
|
|
|
/// <summary>
|
|
/// The single <see cref="AbStatus"/> to OPC UA StatusCode table shared by <c>AbCipStatusMapper</c> and
|
|
/// <c>AbLegacyStatusMapper</c> (#580) — the two drivers used to carry identical copies.
|
|
/// </summary>
|
|
public static class AbOpcUaStatusMap
|
|
{
|
|
/// <summary>OPC UA <c>Good</c>.</summary>
|
|
public const uint Good = 0u;
|
|
/// <summary>OPC UA <c>GoodMoreData</c>.</summary>
|
|
public const uint GoodMoreData = 0x00A60000u;
|
|
/// <summary>OPC UA <c>BadNodeIdUnknown</c>.</summary>
|
|
public const uint BadNodeIdUnknown = 0x80340000u;
|
|
/// <summary>OPC UA <c>BadNotWritable</c>.</summary>
|
|
public const uint BadNotWritable = 0x803B0000u;
|
|
/// <summary>OPC UA <c>BadOutOfRange</c>.</summary>
|
|
public const uint BadOutOfRange = 0x803C0000u;
|
|
/// <summary>OPC UA <c>BadNotSupported</c>.</summary>
|
|
public const uint BadNotSupported = 0x803D0000u;
|
|
/// <summary>OPC UA <c>BadDeviceFailure</c>.</summary>
|
|
public const uint BadDeviceFailure = 0x808B0000u;
|
|
/// <summary>OPC UA <c>BadCommunicationError</c>.</summary>
|
|
public const uint BadCommunicationError = 0x80050000u;
|
|
/// <summary>OPC UA <c>BadTimeout</c>.</summary>
|
|
public const uint BadTimeout = 0x800A0000u;
|
|
/// <summary>OPC UA <c>BadTypeMismatch</c>.</summary>
|
|
public const uint BadTypeMismatch = 0x80740000u;
|
|
|
|
/// <summary>Maps a transport-neutral <see cref="AbStatus"/> to an OPC UA StatusCode.</summary>
|
|
/// <param name="status">The transport status.</param>
|
|
/// <returns>The corresponding OPC UA status code.</returns>
|
|
public static uint MapStatus(AbStatus status) => status switch
|
|
{
|
|
AbStatus.Ok => Good,
|
|
AbStatus.Pending => GoodMoreData,
|
|
AbStatus.Timeout => BadTimeout,
|
|
AbStatus.NotFound => BadNodeIdUnknown,
|
|
AbStatus.NotAllowed => BadNotWritable,
|
|
AbStatus.OutOfBounds or AbStatus.TooLarge or AbStatus.TooSmall => BadOutOfRange,
|
|
AbStatus.Unsupported => BadNotSupported,
|
|
AbStatus.TypeMismatch => BadTypeMismatch,
|
|
AbStatus.DeviceStateConflict => BadDeviceFailure,
|
|
_ => BadCommunicationError, // BadConnection, BadReply, Partial, Abort
|
|
};
|
|
|
|
/// <summary>
|
|
/// Status for an exception thrown while creating / reading a tag: a transport exception maps through its
|
|
/// <see cref="AbStatus"/>; anything else is <see cref="BadCommunicationError"/>.
|
|
/// </summary>
|
|
/// <param name="ex">The exception.</param>
|
|
/// <returns>The OPC UA status code.</returns>
|
|
public static uint MapException(Exception ex) =>
|
|
ex is AbTransportException ate ? MapStatus(ate.Status) : BadCommunicationError;
|
|
}
|