feat(communication): map enriched alarm fields across gRPC (server + client)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.Communication.Grpc;
|
||||
|
||||
/// <summary>
|
||||
/// Maps <see cref="AlarmShelveState"/> to/from the wire string carried in the
|
||||
/// <c>AlarmStateUpdate.shelve_state</c> proto field. The wire form is the enum
|
||||
/// member name; an empty or unrecognized string parses back to
|
||||
/// <see cref="AlarmShelveState.Unshelved"/> (the safe default).
|
||||
/// </summary>
|
||||
public static class AlarmShelveStateCodec
|
||||
{
|
||||
/// <summary>Returns the wire string for a shelve state (the enum member name).</summary>
|
||||
public static string ToWire(AlarmShelveState state) => state.ToString();
|
||||
|
||||
/// <summary>Parses a wire string back to a shelve state; defaults to <see cref="AlarmShelveState.Unshelved"/>.</summary>
|
||||
public static AlarmShelveState Parse(string? wire) =>
|
||||
Enum.TryParse<AlarmShelveState>(wire, ignoreCase: true, out var state)
|
||||
? state
|
||||
: AlarmShelveState.Unshelved;
|
||||
}
|
||||
Reference in New Issue
Block a user