using CommunityToolkit.Mvvm.ComponentModel; namespace ZB.MOM.WW.OtOpcUa.Client.UI.ViewModels; /// /// Represents a single alarm event row. /// public class AlarmEventViewModel : ObservableObject { /// /// Creates an alarm row model from an OPC UA condition event so the alarms tab can display and acknowledge it. /// /// The source object or variable name associated with the alarm. /// The OPC UA condition name reported by the server. /// The alarm severity value presented to the operator. /// The alarm message text shown in the UI. /// Indicates whether the server is retaining the alarm condition. /// Indicates whether the alarm is currently active. /// Indicates whether the alarm has already been acknowledged. /// The event timestamp associated with the alarm state. /// The OPC UA event identifier used for acknowledgment calls. /// The condition node identifier used when acknowledging the alarm. public AlarmEventViewModel( string sourceName, string conditionName, ushort severity, string message, bool retain, bool activeState, bool ackedState, DateTime time, byte[]? eventId = null, string? conditionNodeId = null) { SourceName = sourceName; ConditionName = conditionName; Severity = severity; Message = message; Retain = retain; ActiveState = activeState; AckedState = ackedState; Time = time; EventId = eventId; ConditionNodeId = conditionNodeId; } /// /// Gets the source object or variable name associated with the alarm. /// public string SourceName { get; } /// /// Gets the OPC UA condition name reported for the alarm event. /// public string ConditionName { get; } /// /// Gets the severity value shown to the operator. /// public ushort Severity { get; } /// /// Gets the alarm message text shown in the UI. /// public string Message { get; } /// /// Gets a value indicating whether the server is retaining the condition. /// public bool Retain { get; } /// /// Gets a value indicating whether the alarm is currently active. /// public bool ActiveState { get; } /// /// Gets a value indicating whether the alarm has already been acknowledged. /// public bool AckedState { get; } /// /// Gets the event timestamp displayed for the alarm row. /// public DateTime Time { get; } /// /// Gets the OPC UA event identifier needed to acknowledge the alarm. /// public byte[]? EventId { get; } /// /// Gets the condition node identifier used for acknowledgment method calls. /// public string? ConditionNodeId { get; } /// Whether this alarm can be acknowledged (active, not yet acked, has EventId). public bool CanAcknowledge => ActiveState && !AckedState && EventId != null && ConditionNodeId != null; }