43 lines
1.8 KiB
C#
43 lines
1.8 KiB
C#
namespace ZB.MOM.WW.MxGateway.Worker.MxAccess;
|
|
|
|
/// <summary>The MXAccess item an acknowledgement writes, or why none exists.</summary>
|
|
public sealed class AlarmAckTarget
|
|
{
|
|
private AlarmAckTarget(string itemAddress, AlarmAckOutcome failure, string reason)
|
|
{
|
|
ItemAddress = itemAddress;
|
|
Failure = failure;
|
|
Reason = reason;
|
|
}
|
|
|
|
/// <summary>Gets a value indicating whether an ack item was resolved.</summary>
|
|
public bool Found => ItemAddress.Length > 0;
|
|
|
|
/// <summary>Gets the ack item address (e.g. <c>TestMachine_001.TestAlarm001.AckMsg</c>), empty when not found.</summary>
|
|
public string ItemAddress { get; }
|
|
|
|
/// <summary>Gets the failure outcome when <see cref="Found"/> is false.</summary>
|
|
public AlarmAckOutcome Failure { get; }
|
|
|
|
/// <summary>Gets a human-readable reason when <see cref="Found"/> is false.</summary>
|
|
public string Reason { get; }
|
|
|
|
/// <summary>Creates a resolved target.</summary>
|
|
/// <param name="itemAddress">The ack item address.</param>
|
|
/// <returns>The target.</returns>
|
|
public static AlarmAckTarget For(string itemAddress) =>
|
|
new AlarmAckTarget(itemAddress ?? string.Empty, AlarmAckOutcome.Applied, string.Empty);
|
|
|
|
/// <summary>Creates a not-found result.</summary>
|
|
/// <param name="reason">Why the alarm was not found.</param>
|
|
/// <returns>The target.</returns>
|
|
public static AlarmAckTarget NotFound(string reason) =>
|
|
new AlarmAckTarget(string.Empty, AlarmAckOutcome.AlarmNotFound, reason);
|
|
|
|
/// <summary>Creates a not-ackable result.</summary>
|
|
/// <param name="reason">Why the alarm cannot be acknowledged over MXAccess.</param>
|
|
/// <returns>The target.</returns>
|
|
public static AlarmAckTarget NotAckable(string reason) =>
|
|
new AlarmAckTarget(string.Empty, AlarmAckOutcome.NotAckable, reason);
|
|
}
|