826312befe
Clears CommentChecker findings in src/ (3,280 -> 209, the remainder being false positives like PLC-5/IEEE-754/M0.0) by adding missing summaries/params/returns, normalising inheritdoc usage, and removing Gitea/review tracking IDs while keeping the rationale they annotated. Comment-only: comment-stripped sources are identical to the parent commit.
40 lines
1.7 KiB
C#
40 lines
1.7 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport;
|
|
|
|
public static class AbStatusCodes
|
|
{
|
|
/// <summary>Maps a CIP general status (and optional extended status words) to an <see cref="AbStatus"/>.</summary>
|
|
/// <param name="general">The CIP general status byte.</param>
|
|
/// <param name="extended">The extended status words, if any.</param>
|
|
/// <returns>The mapped status.</returns>
|
|
public static AbStatus FromCip(byte general, ReadOnlySpan<ushort> extended) => general switch
|
|
{
|
|
0x00 or 0x0B => AbStatus.Ok,
|
|
0x04 or 0x05 or 0x16 => AbStatus.NotFound,
|
|
0x06 => AbStatus.Partial,
|
|
0x08 => AbStatus.Unsupported,
|
|
0x0A => AbStatus.OutOfBounds,
|
|
0x0C or 0x10 => AbStatus.DeviceStateConflict,
|
|
0x0E or 0x0F => AbStatus.NotAllowed,
|
|
0x13 => AbStatus.TooSmall,
|
|
0x15 => AbStatus.TooLarge,
|
|
0xFF when extended.Length > 0 && extended[0] == 0x2105 => AbStatus.OutOfBounds,
|
|
0xFF when extended.Length > 0 && extended[0] == 0x2107 => AbStatus.TypeMismatch,
|
|
_ => AbStatus.BadReply,
|
|
};
|
|
|
|
/// <summary>Maps a PCCC status byte (and optional extended status) to an <see cref="AbStatus"/>.</summary>
|
|
/// <param name="sts">The PCCC STS byte.</param>
|
|
/// <param name="extSts">The extended status byte, when present.</param>
|
|
/// <returns>The mapped status.</returns>
|
|
public static AbStatus FromPccc(byte sts, byte? extSts) => sts switch
|
|
{
|
|
0x00 => AbStatus.Ok,
|
|
0x10 => AbStatus.Unsupported,
|
|
0x20 => AbStatus.NotFound,
|
|
0x30 => AbStatus.NotAllowed,
|
|
0x40 or 0x50 => AbStatus.DeviceStateConflict,
|
|
0xF0 when extSts is 0x06 or 0x07 => AbStatus.NotFound,
|
|
_ => AbStatus.BadReply,
|
|
};
|
|
}
|