using ZB.MOM.WW.HistorianGateway.Contracts.Grpc; using ZB.MOM.WW.OtOpcUa.Core.Abstractions; namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Mapping; /// /// Maps the driver-agnostic (OPC UA Part 13 aggregate) onto the /// gateway's native . /// /// /// /// Average/Minimum/Maximum line up with the legacy Wonderware client's aggregate mapping. The two /// remaining members are now served by native gateway retrieval modes: /// and /// . /// /// /// This replaces the Wonderware-era client-side workarounds (Total derived as Average × interval, /// Count approximated from a value count): no client-side scaling is performed any more, so the /// gateway path is a strict improvement. /// /// internal static class AggregateModeMapper { /// Maps an aggregate function to the gateway retrieval mode. /// The driver-agnostic aggregate function. /// The matching gateway . /// A future, unmapped enum member (fails the matrix guard). public static RetrievalMode ToRetrievalMode(HistoryAggregateType aggregate) => aggregate switch { HistoryAggregateType.Average => RetrievalMode.TimeWeightedAverage, HistoryAggregateType.Minimum => RetrievalMode.MinimumWithTime, HistoryAggregateType.Maximum => RetrievalMode.MaximumWithTime, HistoryAggregateType.Total => RetrievalMode.Integral, HistoryAggregateType.Count => RetrievalMode.Counter, _ => throw new ArgumentOutOfRangeException( nameof(aggregate), aggregate, "Unmapped HistoryAggregateType — add a RetrievalMode mapping."), }; }