using DevExpress.XtraEditors; using IStation.Unit; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; namespace IStation.WinFrmUI.Monitor { public partial class DataComparisonCharCtrl : XtraUserControl { public DataComparisonCharCtrl() { InitializeComponent(); this.multiMonitorPointListCtrl1.CheckChangedEvent += MultiMonitorPointListCtrl1_CheckChangedEvent; } /// /// 绑定数据 /// public void SetBindingData() { _timeViewDict = new Dictionary>(); this.timeValueChartView1.ClearSeries(); this.multiMonitorPointListCtrl1.SetBindingData(); } private Dictionary> _timeViewDict = null; //节点变换 private void MultiMonitorPointListCtrl1_CheckChangedEvent(Model.MonitorPointExSignalExSignalType monitorPoint, System.Drawing.Color color, bool check) { if (monitorPoint == null) return; var monitorPointId = monitorPoint.MonitorPointID.ToString(); if (check) { if (_timeViewDict.ContainsKey(monitorPointId)) return; var timeValues = new List(); var packet = new BLL.MonitorDataSet().GetSignalRecordPacket(monitorPoint.MonitorPointID, monitorPoint.SignalID); if (packet != null) { var records = packet.RecordList; if (records != null && records.Any()) { timeValues = records.Where(x => x.Value != IStation.Error.Default && x.Value != IStation.Error.Abnormal). Select(x => new TimeValue(x.Time, Math.Round(x.Value, 4))).ToList(); } } var axisYTitle = monitorPoint.UnitValue; if (int.TryParse(monitorPoint.UnitValue, out int unitValue)) { var dict = UnitHelper.GetEnUnitDict(monitorPoint.UnitType); if (dict != null) axisYTitle = dict[unitValue]; } _timeViewDict.Add(monitorPointId, timeValues); this.timeValueChartView1.AddSwiftPlotSeries(monitorPointId, color, monitorPoint.Name, axisYTitle, timeValues); } else { if (!_timeViewDict.ContainsKey(monitorPointId)) return; _timeViewDict.Remove(monitorPointId); this.timeValueChartView1.RemoveSeries(monitorPointId); } } } }