using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browse;
///
/// Populates the five sub-attribute references on
/// by Galaxy convention. The server-level AlarmConditionService (PR 2.2) uses
/// these to subscribe to live alarm-state attributes and to route ack writes back to
/// the alarm tag.
///
///
/// Galaxy alarms expose four runtime attributes plus a write-only ack target,
/// consistently named on every alarm-bearing object:
///
/// - <tag>.<attr>.InAlarm
/// - <tag>.<attr>.Priority
/// - <tag>.<attr>.DescAttrName
/// - <tag>.<attr>.Acked
/// - <tag>.<attr>.AckMsg
///
/// This is the same convention the legacy GalaxyAlarmTracker hard-coded; we
/// concentrate it here so PR 2.2's service receives complete AlarmConditionInfo
/// rows during discovery without the server needing to know the convention.
///
internal static class AlarmRefBuilder
{
private const string InAlarmSuffix = ".InAlarm";
private const string PrioritySuffix = ".Priority";
private const string DescAttrNameSuffix = ".DescAttrName";
private const string AckedSuffix = ".Acked";
private const string AckMsgSuffix = ".AckMsg";
///
/// Build an for an alarm-bearing attribute with all
/// five sub-attribute references populated. is the
/// attribute's full reference (e.g. "Tank1.Level.HiHi"); the convention prefixes
/// each suffix to it.
///
public static AlarmConditionInfo Build(
string fullReference,
AlarmSeverity initialSeverity = AlarmSeverity.Medium,
string? initialDescription = null) => new(
SourceName: fullReference,
InitialSeverity: initialSeverity,
InitialDescription: initialDescription,
InAlarmRef: fullReference + InAlarmSuffix,
PriorityRef: fullReference + PrioritySuffix,
DescAttrNameRef: fullReference + DescAttrNameSuffix,
AckedRef: fullReference + AckedSuffix,
AckMsgWriteRef: fullReference + AckMsgSuffix);
}