using ZB.MOM.WW.OtOpcUa.Core.Abstractions; namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Sql.Common; /// The query shape that serves an aggregate. One query per family. public enum AggregateFamily { /// Average / Minimum / Maximum / Count / Range / PercentGood / PercentBad: one GROUP BY. Simple, /// Start / End / Delta: first + last usable sample per bucket. StartEnd, /// MinimumActualTime / MaximumActualTime: extreme usable sample per bucket, ties ⇒ earliest. ActualTime, /// /// TimeAverage / TimeAverage2 / Total / Total2 / Interpolative: Part 13 time-weighted, with bounding values. /// The backend streams the window's samples plus the bounding rows and /// evaluates them (identically for every backend). /// TimeWeighted, } /// Which aggregates the SQL historian backends serve, and by which family. public static class AggregateFamilies { /// The family that serves , or null when the backends do not. /// Requested aggregate. /// The family, or null for an unsupported aggregate. public static AggregateFamily? FamilyOf(HistoryAggregateType aggregate) => aggregate switch { HistoryAggregateType.Average or HistoryAggregateType.Minimum or HistoryAggregateType.Maximum or HistoryAggregateType.Count or HistoryAggregateType.Range or HistoryAggregateType.PercentGood or HistoryAggregateType.PercentBad => AggregateFamily.Simple, HistoryAggregateType.Start or HistoryAggregateType.End or HistoryAggregateType.Delta => AggregateFamily.StartEnd, HistoryAggregateType.MinimumActualTime or HistoryAggregateType.MaximumActualTime => AggregateFamily.ActualTime, HistoryAggregateType.TimeAverage or HistoryAggregateType.TimeAverage2 or HistoryAggregateType.Total or HistoryAggregateType.Total2 or HistoryAggregateType.Interpolative => AggregateFamily.TimeWeighted, _ => null, }; }