using NEIntelligentControl2.Models.Datas; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NEIntelligentControl2.Models.AGC { /// /// AGC数据标签 /// public class TagInfo { /// /// 名称 /// public string Name { get; set; } private string tag; /// /// 标签 /// public string Tag { get => tag; set { tag = value; Tags = tag?.Split(','); } } /// /// 倍率 /// public float Multiplier { get; set; } = 1; /// /// 单位 /// public string Unit { get; set; } /// /// 类型 /// public TagType Type { get; set; } /// /// 标签们 /// public string[] Tags { get; set; } /// /// 时间戳 /// public long Ts { get; set; } /// /// 值改变 /// public Action ValueChanged { get; internal set; } /// /// 值 /// private double value; public double Value { get { return value; } set { this.value = value * Multiplier; ValueChanged?.Invoke(this.value); } } /// /// 数据历史值改变 /// public Action> HistoryValueChanged { get; set; } /// /// 更新数据 /// internal void UpdateData(Dictionary vs) { if (vs == null || this.Tags == null) return; double d = 0; foreach (var v in this.Tags) { if (!vs.ContainsKey(v)) continue; var td = vs[v]; d += td.Value; Ts = td.Ts; } this.Value = d; } /// /// 更新历史数据 /// internal void UpdateHistoryData(List dts) { HistoryValueChanged?.Invoke(this, dts); } } }