duheng
2024-03-26 11c7908bcc2ca699e88b7a0a17bc32e45521c349
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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;
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData()
        {
            _timeViewDict = new Dictionary<string, List<TimeValue>>();
            this.timeValueChartView1.ClearSeries();
 
            this.multiMonitorPointListCtrl1.SetBindingData();
        }
 
        private Dictionary<string, List<TimeValue>> _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<TimeValue>();
                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);
            }
        }
 
 
    }
}