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